summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-11-02 00:43:13 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-11-02 00:43:13 +0000
commit46f26ceba116c0116f67188287e37b96cfd8c05a (patch)
tree73d89c51b5f2d50ec4f24fb34b67f91b2567dd51
parent899a8a3151264e11d3582d1e57052d85123b03da (diff)
downloadclasspath-46f26ceba116c0116f67188287e37b96cfd8c05a.tar.gz
2005-11-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge from HEAD --> generics for 2005/09/20 - 2005/11/01.
-rw-r--r--BUGS2
-rw-r--r--ChangeLog5726
-rw-r--r--INSTALL23
-rw-r--r--LICENSE14
-rw-r--r--NEWS26
-rw-r--r--configure.ac126
-rw-r--r--doc/www.gnu.org/corba.wml37
-rw-r--r--doc/www.gnu.org/include/layout.wml2
-rwxr-xr-xdoc/www.gnu.org/tasks.wml338
-rw-r--r--examples/gnu/classpath/examples/CORBA/NamingService/Demo.java4
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java31
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java)10
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java)32
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java)16
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java40
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java56
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java)9
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java)19
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java)14
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java)9
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java)17
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java)14
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java)15
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java)44
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java)32
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java)11
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java)18
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java)31
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java (renamed from examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java)37
-rw-r--r--examples/gnu/classpath/examples/midi/Demo.java137
-rw-r--r--examples/gnu/classpath/examples/swing/ButtonDemo.java28
-rw-r--r--examples/gnu/classpath/examples/swing/ComboBoxDemo.java360
-rw-r--r--examples/gnu/classpath/examples/swing/Demo.java81
-rw-r--r--examples/gnu/classpath/examples/swing/ScrollBarDemo.java141
-rw-r--r--examples/gnu/classpath/examples/swing/SliderDemo.java249
-rw-r--r--gnu/CORBA/CDR/AbstractCdrInput.java (renamed from gnu/CORBA/CDR/cdrInput.java)704
-rw-r--r--gnu/CORBA/CDR/AbstractCdrOutput.java (renamed from gnu/CORBA/CDR/cdrOutput.java)162
-rw-r--r--gnu/CORBA/CDR/AbstractDataInput.java (renamed from gnu/CORBA/CDR/abstractDataInputStream.java)4
-rw-r--r--gnu/CORBA/CDR/AbstractDataOutput.java (renamed from gnu/CORBA/CDR/abstractDataOutputStream.java)4
-rw-r--r--gnu/CORBA/CDR/AligningInput.java (renamed from gnu/CORBA/CDR/aligningInputStream.java)39
-rw-r--r--gnu/CORBA/CDR/AligningOutput.java (renamed from gnu/CORBA/CDR/aligningOutputStream.java)37
-rw-r--r--gnu/CORBA/CDR/ArrayValueHelper.java254
-rw-r--r--gnu/CORBA/CDR/BigEndianInputStream.java2
-rw-r--r--gnu/CORBA/CDR/BigEndianOutputStream.java2
-rw-r--r--gnu/CORBA/CDR/BufferedCdrOutput.java (renamed from gnu/CORBA/CDR/cdrBufOutput.java)69
-rw-r--r--gnu/CORBA/CDR/BufferredCdrInput.java (renamed from gnu/CORBA/CDR/cdrBufInput.java)58
-rw-r--r--gnu/CORBA/CDR/EncapsulationStream.java (renamed from gnu/CORBA/CDR/encapsulatedOutput.java)12
-rw-r--r--gnu/CORBA/CDR/HeadlessInput.java749
-rw-r--r--gnu/CORBA/CDR/IDLTypeHelper.java169
-rw-r--r--gnu/CORBA/CDR/LittleEndianInputStream.java2
-rw-r--r--gnu/CORBA/CDR/LittleEndianOutputStream.java2
-rw-r--r--gnu/CORBA/CDR/UnknownExceptionCtxHandler.java292
-rw-r--r--gnu/CORBA/CDR/VMVio.java101
-rw-r--r--gnu/CORBA/CDR/Vio.java1459
-rw-r--r--gnu/CORBA/CDR/gnuRuntime.java336
-rw-r--r--gnu/CORBA/CDR/gnuValueStream.java71
-rw-r--r--gnu/CORBA/CDR/noHeaderInput.java166
-rw-r--r--gnu/CORBA/CdrEncapsCodecImpl.java (renamed from gnu/CORBA/cdrEncapsCodec.java)58
-rw-r--r--gnu/CORBA/CorbaList.java (renamed from gnu/CORBA/corbaArrayList.java)8
-rw-r--r--gnu/CORBA/DefaultSocketFactory.java79
-rw-r--r--gnu/CORBA/DynAn/AbstractAny.java (renamed from gnu/CORBA/DynAn/abstractDynAny.java)14
-rw-r--r--gnu/CORBA/DynAn/DivideableAny.java (renamed from gnu/CORBA/DynAn/anyDivideable.java)16
-rw-r--r--gnu/CORBA/DynAn/RecordAny.java (renamed from gnu/CORBA/DynAn/abstractRecord.java)18
-rw-r--r--gnu/CORBA/DynAn/UndivideableAny.java (renamed from gnu/CORBA/DynAn/anyUndivideable.java)6
-rw-r--r--gnu/CORBA/DynAn/ValueChangeListener.java (renamed from gnu/CORBA/DynAn/valueChangedListener.java)4
-rw-r--r--gnu/CORBA/DynAn/gnuDynAny.java28
-rw-r--r--gnu/CORBA/DynAn/gnuDynAnyFactory.java8
-rw-r--r--gnu/CORBA/DynAn/gnuDynArray.java14
-rw-r--r--gnu/CORBA/DynAn/gnuDynEnum.java2
-rw-r--r--gnu/CORBA/DynAn/gnuDynFixed.java2
-rw-r--r--gnu/CORBA/DynAn/gnuDynStruct.java4
-rw-r--r--gnu/CORBA/DynAn/gnuDynUnion.java10
-rw-r--r--gnu/CORBA/DynAn/gnuDynValue.java14
-rw-r--r--gnu/CORBA/DynAn/gnuDynValueBox.java6
-rw-r--r--gnu/CORBA/EmptyExceptionHolder.java1
-rw-r--r--gnu/CORBA/ExceptionCreator.java245
-rw-r--r--gnu/CORBA/Focused_ORB.java375
-rw-r--r--gnu/CORBA/ForwardRequestHelper.java1
-rw-r--r--gnu/CORBA/GIOP/CharSets_OSF.java5
-rw-r--r--gnu/CORBA/GIOP/CloseMessage.java10
-rw-r--r--gnu/CORBA/GIOP/CodeSetServiceContext.java (renamed from gnu/CORBA/GIOP/cxCodeSet.java)26
-rw-r--r--gnu/CORBA/GIOP/ContextHandler.java (renamed from gnu/CORBA/GIOP/contextSupportingHeader.java)4
-rw-r--r--gnu/CORBA/GIOP/ErrorMessage.java23
-rw-r--r--gnu/CORBA/GIOP/MessageHeader.java200
-rw-r--r--gnu/CORBA/GIOP/ReplyHeader.java10
-rw-r--r--gnu/CORBA/GIOP/RequestHeader.java10
-rw-r--r--gnu/CORBA/GIOP/ServiceContext.java88
-rw-r--r--gnu/CORBA/GIOP/v1_0/ReplyHeader.java14
-rw-r--r--gnu/CORBA/GIOP/v1_0/RequestHeader.java14
-rw-r--r--gnu/CORBA/GIOP/v1_2/ReplyHeader.java16
-rw-r--r--gnu/CORBA/GIOP/v1_2/RequestHeader.java27
-rw-r--r--gnu/CORBA/GeneralHolder.java (renamed from gnu/CORBA/universalHolder.java)26
-rw-r--r--gnu/CORBA/HolderLocator.java (renamed from gnu/CORBA/holderFactory.java)4
-rw-r--r--gnu/CORBA/IOR.java47
-rw-r--r--gnu/CORBA/Interceptor/Registrator.java8
-rw-r--r--gnu/CORBA/Interceptor/gnuIcCurrent.java4
-rw-r--r--gnu/CORBA/IorDelegate.java (renamed from gnu/CORBA/IOR_Delegate.java)92
-rw-r--r--gnu/CORBA/IorObject.java (renamed from gnu/CORBA/IOR_contructed_object.java)21
-rw-r--r--gnu/CORBA/IorProvider.java (renamed from org/omg/CORBA/IDLEntity.java)20
-rw-r--r--gnu/CORBA/Minor.java276
-rw-r--r--gnu/CORBA/NamingService/Ext.java2
-rw-r--r--gnu/CORBA/NamingService/NameComponentComparator.java (renamed from gnu/CORBA/NamingService/cmpNameComponent.java)10
-rw-r--r--gnu/CORBA/NamingService/NameParser.java86
-rw-r--r--gnu/CORBA/NamingService/NameTransformer.java (renamed from gnu/CORBA/NamingService/snConverter.java)6
-rw-r--r--gnu/CORBA/NamingService/NamingMap.java2
-rw-r--r--gnu/CORBA/NamingService/NamingServiceTransient.java10
-rw-r--r--gnu/CORBA/ObjectCreator.java397
-rw-r--r--gnu/CORBA/OctetHolder.java4
-rw-r--r--gnu/CORBA/OrbFocused.java375
-rw-r--r--gnu/CORBA/OrbFunctional.java (renamed from gnu/CORBA/Functional_ORB.java)355
-rw-r--r--gnu/CORBA/OrbRestricted.java (renamed from gnu/CORBA/Restricted_ORB.java)38
-rw-r--r--gnu/CORBA/Poa/AOM.java (renamed from gnu/CORBA/Poa/activeObjectMap.java)6
-rw-r--r--gnu/CORBA/Poa/AccessiblePolicy.java (renamed from gnu/CORBA/Poa/vPolicy.java)4
-rw-r--r--gnu/CORBA/Poa/DynamicImpHandler.java (renamed from gnu/CORBA/Poa/dynImpHandler.java)6
-rw-r--r--gnu/CORBA/Poa/ForwardedServant.java16
-rw-r--r--gnu/CORBA/Poa/LocalDelegate.java79
-rw-r--r--gnu/CORBA/Poa/LocalRequest.java42
-rw-r--r--gnu/CORBA/Poa/ORB_1_4.java47
-rw-r--r--gnu/CORBA/Poa/ServantDelegateImpl.java (renamed from gnu/CORBA/Poa/servantDelegate.java)6
-rw-r--r--gnu/CORBA/Poa/StandardPolicies.java (renamed from gnu/CORBA/Poa/policySets.java)8
-rw-r--r--gnu/CORBA/Poa/gnuAdapterActivator.java2
-rw-r--r--gnu/CORBA/Poa/gnuIdAssignmentPolicy.java2
-rw-r--r--gnu/CORBA/Poa/gnuIdUniquenessPolicy.java2
-rw-r--r--gnu/CORBA/Poa/gnuImplicitActivationPolicy.java2
-rw-r--r--gnu/CORBA/Poa/gnuLifespanPolicy.java2
-rw-r--r--gnu/CORBA/Poa/gnuPOA.java106
-rw-r--r--gnu/CORBA/Poa/gnuRequestProcessingPolicy.java2
-rw-r--r--gnu/CORBA/Poa/gnuServantObject.java60
-rw-r--r--gnu/CORBA/Poa/gnuServantRetentionPolicy.java2
-rw-r--r--gnu/CORBA/Poa/gnuThreadPolicy.java2
-rw-r--r--gnu/CORBA/RawReply.java (renamed from gnu/CORBA/binaryReply.java)12
-rw-r--r--gnu/CORBA/ResponseHandlerImpl.java (renamed from gnu/CORBA/bufferedResponseHandler.java)18
-rw-r--r--gnu/CORBA/ServiceRequestAdapter.java10
-rw-r--r--gnu/CORBA/SimpleDelegate.java (renamed from gnu/CORBA/Simple_delegate.java)20
-rw-r--r--gnu/CORBA/SocketRepository.java55
-rw-r--r--gnu/CORBA/StreamBasedRequest.java (renamed from gnu/CORBA/streamRequest.java)6
-rw-r--r--gnu/CORBA/StreamHolder.java (renamed from gnu/CORBA/streamReadyHolder.java)11
-rw-r--r--gnu/CORBA/StubLocator.java (renamed from gnu/CORBA/stubFinder.java)8
-rw-r--r--gnu/CORBA/TypeCodeHelper.java35
-rw-r--r--gnu/CORBA/TypeKindNamer.java (renamed from gnu/CORBA/typeNamer.java)75
-rw-r--r--gnu/CORBA/Version.java10
-rw-r--r--gnu/CORBA/WCharHolder.java4
-rw-r--r--gnu/CORBA/WStringHolder.java6
-rw-r--r--gnu/CORBA/_PolicyImplBase.java3
-rw-r--r--gnu/CORBA/gnuAny.java113
-rw-r--r--gnu/CORBA/gnuCodecFactory.java2
-rw-r--r--gnu/CORBA/gnuContextList.java2
-rw-r--r--gnu/CORBA/gnuExceptionList.java2
-rw-r--r--gnu/CORBA/gnuNVList.java6
-rw-r--r--gnu/CORBA/gnuRequest.java134
-rw-r--r--gnu/CORBA/gnuValueHolder.java2
-rw-r--r--gnu/CORBA/interfaces/SocketFactory.java95
-rw-r--r--gnu/CORBA/interfaces/gnuSocketFactory.java95
-rw-r--r--gnu/CORBA/interfaces/package.html49
-rw-r--r--gnu/CORBA/typecodes/AliasTypeCode.java (renamed from gnu/CORBA/aliasTypeCode.java)16
-rw-r--r--gnu/CORBA/typecodes/ArrayTypeCode.java (renamed from gnu/CORBA/primitiveArrayTypeCode.java)21
-rw-r--r--gnu/CORBA/typecodes/FixedTypeCode.java (renamed from gnu/CORBA/fixedTypeCode.java)19
-rw-r--r--gnu/CORBA/typecodes/GeneralTypeCode.java (renamed from gnu/CORBA/generalTypeCode.java)40
-rw-r--r--gnu/CORBA/typecodes/PrimitiveTypeCode.java (renamed from gnu/CORBA/primitiveTypeCode.java)15
-rw-r--r--gnu/CORBA/typecodes/RecordTypeCode.java (renamed from gnu/CORBA/recordTypeCode.java)21
-rw-r--r--gnu/CORBA/typecodes/RecursiveTypeCode.java (renamed from gnu/CORBA/recursiveTypeCode.java)16
-rw-r--r--gnu/CORBA/typecodes/StringTypeCode.java (renamed from gnu/CORBA/stringTypeCode.java)16
-rw-r--r--gnu/CORBA/typecodes/package.html48
-rw-r--r--gnu/classpath/ByteArray.java33
-rw-r--r--gnu/classpath/jdwp/event/filters/StepFilter.java2
-rw-r--r--gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java2
-rw-r--r--gnu/java/awt/peer/gtk/GdkFontMetrics.java29
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java10
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics2D.java27
-rw-r--r--gnu/java/awt/peer/gtk/GdkTextLayout.java5
-rw-r--r--gnu/java/awt/peer/gtk/GtkChoicePeer.java3
-rw-r--r--gnu/java/awt/peer/gtk/GtkDialogPeer.java29
-rw-r--r--gnu/java/awt/peer/qt/QtToolkit.java4
-rw-r--r--gnu/java/net/LineInputStream.java13
-rw-r--r--gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java123
-rw-r--r--gnu/java/net/protocol/http/ChunkedInputStream.java2
-rw-r--r--gnu/java/net/protocol/http/Cookie.java2
-rw-r--r--gnu/java/net/protocol/http/HTTPConnection.java174
-rw-r--r--gnu/java/net/protocol/http/HTTPURLConnection.java108
-rw-r--r--gnu/java/net/protocol/http/Headers.java85
-rw-r--r--gnu/java/net/protocol/http/LimitedLengthInputStream.java220
-rw-r--r--gnu/java/net/protocol/http/Request.java191
-rw-r--r--gnu/java/net/protocol/http/Response.java55
-rw-r--r--gnu/java/net/protocol/http/ResponseBodyReader.java70
-rw-r--r--gnu/java/net/protocol/jar/Connection.java23
-rw-r--r--gnu/java/rmi/server/RMIClassLoaderImpl.java350
-rw-r--r--gnu/java/rmi/server/UnicastServer.java5
-rw-r--r--gnu/java/security/der/BitString.java13
-rw-r--r--gnu/java/security/provider/DiffieHellmanKeyFactoryImpl.java123
-rw-r--r--gnu/java/security/provider/DiffieHellmanKeyPairGeneratorImpl.java86
-rw-r--r--gnu/java/security/provider/Gnu.java7
-rw-r--r--gnu/java/security/x509/ext/Extension.java8
-rw-r--r--gnu/java/text/BaseBreakIterator.java7
-rw-r--r--gnu/javax/crypto/DiffieHellmanImpl.java19
-rw-r--r--gnu/javax/imageio/bmp/BMPDecoder.java169
-rw-r--r--gnu/javax/imageio/bmp/BMPException.java47
-rw-r--r--gnu/javax/imageio/bmp/BMPFileHeader.java128
-rw-r--r--gnu/javax/imageio/bmp/BMPImageReader.java153
-rw-r--r--gnu/javax/imageio/bmp/BMPImageReaderSpi.java123
-rw-r--r--gnu/javax/imageio/bmp/BMPInfoHeader.java201
-rw-r--r--gnu/javax/imageio/bmp/DecodeBF16.java104
-rw-r--r--gnu/javax/imageio/bmp/DecodeBF32.java108
-rw-r--r--gnu/javax/imageio/bmp/DecodeRGB1.java96
-rw-r--r--gnu/javax/imageio/bmp/DecodeRGB24.java77
-rw-r--r--gnu/javax/imageio/bmp/DecodeRGB4.java92
-rw-r--r--gnu/javax/imageio/bmp/DecodeRGB8.java (renamed from gnu/javax/rmi/CORBA/ValueHandlerImpl.java)88
-rw-r--r--gnu/javax/imageio/bmp/DecodeRLE4.java176
-rw-r--r--gnu/javax/imageio/bmp/DecodeRLE8.java143
-rw-r--r--gnu/javax/rmi/CORBA/CorbaInput.java297
-rw-r--r--gnu/javax/rmi/CORBA/CorbaOutput.java219
-rw-r--r--gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java85
-rw-r--r--gnu/javax/rmi/CORBA/DelegateFactory.java76
-rw-r--r--gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java352
-rw-r--r--gnu/javax/rmi/CORBA/RmiUtilities.java946
-rw-r--r--gnu/javax/rmi/CORBA/StubDelegateImpl.java262
-rw-r--r--gnu/javax/rmi/CORBA/TieTargetRecord.java93
-rw-r--r--gnu/javax/rmi/CORBA/UtilDelegateImpl.java714
-rw-r--r--gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java163
-rw-r--r--gnu/javax/rmi/PortableServer.java141
-rw-r--r--gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java130
-rw-r--r--gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java216
-rw-r--r--gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java519
-rw-r--r--gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java131
-rw-r--r--gnu/javax/sound/midi/alsa/AlsaPortDevice.java153
-rw-r--r--gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java173
-rw-r--r--gnu/javax/sound/midi/dssi/DSSISynthesizer.java745
-rw-r--r--gnu/xml/stream/XMLOutputFactoryImpl.java3
-rw-r--r--gnu/xml/transform/TransformerImpl.java8
-rw-r--r--include/Makefile.am14
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkTextLayout.h1
-rw-r--r--include/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.h21
-rw-r--r--include/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.h20
-rw-r--r--include/gnu_javax_sound_midi_alsa_AlsaPortDevice.h19
-rw-r--r--include/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h25
-rw-r--r--include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h29
-rw-r--r--java/awt/BorderLayout.java126
-rw-r--r--java/awt/Canvas.java14
-rw-r--r--java/awt/Choice.java4
-rw-r--r--java/awt/ColorPaintContext.java4
-rw-r--r--java/awt/Component.java65
-rw-r--r--java/awt/DefaultKeyboardFocusManager.java4
-rw-r--r--java/awt/EventQueue.java1
-rw-r--r--java/awt/Font.java2075
-rw-r--r--java/awt/FontMetrics.java21
-rw-r--r--java/awt/Graphics.java1291
-rw-r--r--java/awt/GraphicsConfiguration.java5
-rw-r--r--java/awt/GridBagLayout.java23
-rw-r--r--java/awt/Image.java1
-rw-r--r--java/awt/KeyboardFocusManager.java75
-rw-r--r--java/awt/MenuComponent.java4
-rw-r--r--java/awt/Polygon.java1
-rw-r--r--java/awt/ScrollPaneAdjustable.java8
-rw-r--r--java/awt/Window.java20
-rw-r--r--java/awt/color/ICC_Profile.java18
-rw-r--r--java/awt/event/MouseEvent.java1
-rw-r--r--java/awt/geom/Area.java2
-rw-r--r--java/awt/geom/GeneralPath.java3
-rw-r--r--java/awt/im/InputContext.java3
-rw-r--r--java/awt/im/InputMethodHighlight.java5
-rw-r--r--java/awt/im/InputMethodRequests.java2
-rw-r--r--java/awt/im/spi/InputMethod.java10
-rw-r--r--java/awt/im/spi/InputMethodContext.java4
-rw-r--r--java/awt/im/spi/InputMethodDescriptor.java3
-rw-r--r--java/awt/image/BufferedImage.java2
-rw-r--r--java/awt/image/ColorModel.java2
-rw-r--r--java/awt/image/ComponentSampleModel.java8
-rw-r--r--java/awt/image/ImageConsumer.java2
-rw-r--r--java/awt/image/PackedColorModel.java6
-rw-r--r--java/awt/image/SampleModel.java3
-rw-r--r--java/awt/print/PrinterJob.java7
-rw-r--r--java/beans/IndexedPropertyDescriptor.java610
-rw-r--r--java/beans/PropertyDescriptor.java17
-rw-r--r--java/beans/beancontext/BeanContextServicesSupport.java2
-rw-r--r--java/beans/beancontext/BeanContextSupport.java2
-rw-r--r--java/io/File.java30
-rw-r--r--java/io/FileWriter.java2
-rw-r--r--java/io/ObjectInputStream.java88
-rw-r--r--java/io/ObjectOutputStream.java6
-rw-r--r--java/io/OutputStreamWriter.java152
-rw-r--r--java/lang/Class.java3
-rw-r--r--java/lang/ClassLoader.java20
-rw-r--r--java/lang/StringBuffer.java1
-rw-r--r--java/lang/StringBuilder.java65
-rw-r--r--java/lang/Thread.java7
-rw-r--r--java/lang/reflect/Proxy.java9
-rw-r--r--java/math/BigDecimal.java15
-rw-r--r--java/math/BigInteger.java18
-rw-r--r--java/net/DatagramSocket.java1
-rw-r--r--java/net/Inet4Address.java2
-rw-r--r--java/net/ServerSocket.java4
-rw-r--r--java/net/Socket.java9
-rw-r--r--java/net/URLClassLoader.java35
-rw-r--r--java/net/URLConnection.java8
-rw-r--r--java/net/URLStreamHandler.java20
-rw-r--r--java/nio/channels/spi/AbstractSelectableChannel.java6
-rw-r--r--java/rmi/activation/ActivationGroup_Stub.java110
-rw-r--r--java/rmi/server/LoaderHandler.java6
-rw-r--r--java/rmi/server/RMIClassLoader.java312
-rw-r--r--java/rmi/server/RemoteObject.java4
-rw-r--r--java/rmi/server/RemoteRef.java6
-rw-r--r--java/security/AccessControlContext.java34
-rw-r--r--java/security/AccessController.java16
-rw-r--r--java/text/AttributedString.java48
-rw-r--r--java/text/AttributedStringIterator.java183
-rw-r--r--java/text/CharacterIterator.java2
-rw-r--r--java/util/Calendar.java23
-rw-r--r--java/util/GregorianCalendar.java14
-rw-r--r--java/util/Map.java8
-rw-r--r--java/util/Properties.java314
-rw-r--r--java/util/ResourceBundle.java6
-rw-r--r--java/util/SimpleTimeZone.java1
-rw-r--r--javax/imageio/IIOException.java3
-rw-r--r--javax/imageio/IIOImage.java137
-rw-r--r--javax/imageio/IIOParam.java364
-rw-r--r--javax/imageio/IIOParamController.java13
-rw-r--r--javax/imageio/ImageIO.java609
-rw-r--r--javax/imageio/ImageReadParam.java2
-rw-r--r--javax/imageio/ImageReader.java1724
-rw-r--r--javax/imageio/ImageTranscoder.java48
-rw-r--r--javax/imageio/ImageTypeSpecifier.java467
-rw-r--r--javax/imageio/ImageWriteParam.java3
-rw-r--r--javax/imageio/ImageWriter.java1125
-rw-r--r--javax/imageio/metadata/IIOAttr.java378
-rw-r--r--javax/imageio/metadata/IIOMetadata.java114
-rw-r--r--javax/imageio/metadata/IIOMetadataFormatImpl.java842
-rw-r--r--javax/imageio/metadata/IIOMetadataNode.java157
-rw-r--r--javax/imageio/metadata/IIONamedNodeMap.java138
-rw-r--r--javax/imageio/metadata/IIONodeList.java72
-rw-r--r--javax/imageio/package.html45
-rw-r--r--javax/imageio/spi/ImageReaderWriterSpi.java86
-rw-r--r--javax/print/DocFlavor.java2
-rw-r--r--javax/print/attribute/SetOfIntegerSyntax.java186
-rw-r--r--javax/rmi/BAD_OPERATION.java4
-rw-r--r--javax/rmi/CORBA/ClassDesc.java33
-rw-r--r--javax/rmi/CORBA/ObjectImpl.java9
-rw-r--r--javax/rmi/CORBA/PortableRemoteObjectDelegate.java84
-rw-r--r--javax/rmi/CORBA/Stub.java170
-rw-r--r--javax/rmi/CORBA/StubDelegate.java56
-rw-r--r--javax/rmi/CORBA/SystemException.java4
-rw-r--r--javax/rmi/CORBA/Tie.java101
-rw-r--r--javax/rmi/CORBA/Util.java413
-rw-r--r--javax/rmi/CORBA/UtilDelegate.java285
-rw-r--r--javax/rmi/CORBA/ValueHandler.java101
-rw-r--r--javax/rmi/CORBA/ValueHandlerMultiFormat.java94
-rw-r--r--javax/rmi/CORBA/package.html36
-rw-r--r--javax/rmi/ORB.java4
-rw-r--r--javax/rmi/PortableRemoteObject.java201
-rw-r--r--javax/rmi/package.html36
-rw-r--r--javax/security/auth/login/LoginContext.java4
-rw-r--r--javax/security/auth/x500/X500Principal.java16
-rw-r--r--javax/security/sasl/AuthenticationException.java4
-rw-r--r--javax/security/sasl/AuthorizeCallback.java10
-rw-r--r--javax/security/sasl/RealmCallback.java4
-rw-r--r--javax/security/sasl/RealmChoiceCallback.java4
-rw-r--r--javax/security/sasl/Sasl.java2
-rw-r--r--javax/security/sasl/SaslClient.java6
-rw-r--r--javax/security/sasl/SaslClientFactory.java4
-rw-r--r--javax/security/sasl/SaslException.java6
-rw-r--r--javax/security/sasl/SaslServer.java8
-rw-r--r--javax/security/sasl/SaslServerFactory.java4
-rw-r--r--javax/sound/midi/ControllerEventListener.java58
-rw-r--r--javax/sound/midi/Instrument.java77
-rw-r--r--javax/sound/midi/InvalidMidiDataException.java90
-rw-r--r--javax/sound/midi/MetaEventListener.java (renamed from gnu/java/awt/FocusManager.java)26
-rw-r--r--javax/sound/midi/MetaMessage.java176
-rw-r--r--javax/sound/midi/MidiChannel.java236
-rw-r--r--javax/sound/midi/MidiDevice.java220
-rw-r--r--javax/sound/midi/MidiEvent.java95
-rw-r--r--javax/sound/midi/MidiFileFormat.java158
-rw-r--r--javax/sound/midi/MidiMessage.java126
-rw-r--r--javax/sound/midi/MidiSystem.java566
-rw-r--r--javax/sound/midi/MidiUnavailableException.java90
-rw-r--r--javax/sound/midi/Patch.java86
-rw-r--r--javax/sound/midi/Receiver.java66
-rw-r--r--javax/sound/midi/Sequence.java248
-rw-r--r--javax/sound/midi/Sequencer.java402
-rw-r--r--javax/sound/midi/ShortMessage.java344
-rw-r--r--javax/sound/midi/Soundbank.java101
-rw-r--r--javax/sound/midi/SoundbankResource.java104
-rw-r--r--javax/sound/midi/Synthesizer.java173
-rw-r--r--javax/sound/midi/SysexMessage.java139
-rw-r--r--javax/sound/midi/Track.java160
-rw-r--r--javax/sound/midi/Transmitter.java70
-rw-r--r--javax/sound/midi/VoiceStatus.java79
-rw-r--r--javax/sound/midi/spi/MidiDeviceProvider.java90
-rw-r--r--javax/sound/midi/spi/MidiFileReader.java125
-rw-r--r--javax/sound/midi/spi/MidiFileWriter.java143
-rw-r--r--javax/sound/midi/spi/SoundbankReader.java97
-rw-r--r--javax/swing/AbstractButton.java122
-rw-r--r--javax/swing/AbstractSpinnerModel.java1
-rw-r--r--javax/swing/ActionMap.java1
-rw-r--r--javax/swing/BorderFactory.java2
-rw-r--r--javax/swing/BoundedRangeModel.java4
-rw-r--r--javax/swing/Box.java4
-rw-r--r--javax/swing/BoxLayout.java683
-rw-r--r--javax/swing/ButtonGroup.java5
-rw-r--r--javax/swing/CellEditor.java2
-rw-r--r--javax/swing/CellRendererPane.java38
-rw-r--r--javax/swing/ComboBoxEditor.java2
-rw-r--r--javax/swing/DebugGraphics.java308
-rw-r--r--javax/swing/DefaultButtonModel.java1
-rw-r--r--javax/swing/DefaultCellEditor.java7
-rw-r--r--javax/swing/DefaultComboBoxModel.java172
-rw-r--r--javax/swing/DefaultDesktopManager.java4
-rw-r--r--javax/swing/DefaultListCellRenderer.java14
-rw-r--r--javax/swing/DefaultListSelectionModel.java60
-rw-r--r--javax/swing/DesktopManager.java2
-rw-r--r--javax/swing/FocusManager.java425
-rw-r--r--javax/swing/ImageIcon.java9
-rw-r--r--javax/swing/InputVerifier.java1
-rw-r--r--javax/swing/JApplet.java10
-rw-r--r--javax/swing/JButton.java7
-rw-r--r--javax/swing/JCheckBox.java22
-rw-r--r--javax/swing/JCheckBoxMenuItem.java13
-rw-r--r--javax/swing/JColorChooser.java2
-rw-r--r--javax/swing/JComboBox.java88
-rw-r--r--javax/swing/JComponent.java594
-rw-r--r--javax/swing/JDesktopPane.java3
-rw-r--r--javax/swing/JEditorPane.java441
-rw-r--r--javax/swing/JFileChooser.java765
-rw-r--r--javax/swing/JFrame.java8
-rw-r--r--javax/swing/JLabel.java18
-rw-r--r--javax/swing/JLayeredPane.java61
-rw-r--r--javax/swing/JList.java109
-rw-r--r--javax/swing/JMenu.java27
-rw-r--r--javax/swing/JMenuBar.java143
-rw-r--r--javax/swing/JMenuItem.java32
-rw-r--r--javax/swing/JOptionPane.java114
-rw-r--r--javax/swing/JPanel.java5
-rw-r--r--javax/swing/JPasswordField.java1
-rw-r--r--javax/swing/JPopupMenu.java326
-rw-r--r--javax/swing/JProgressBar.java3
-rw-r--r--javax/swing/JRadioButton.java4
-rw-r--r--javax/swing/JRadioButtonMenuItem.java8
-rw-r--r--javax/swing/JRootPane.java33
-rw-r--r--javax/swing/JScrollPane.java198
-rw-r--r--javax/swing/JSeparator.java2
-rw-r--r--javax/swing/JSlider.java3
-rw-r--r--javax/swing/JSpinner.java42
-rw-r--r--javax/swing/JSplitPane.java3
-rw-r--r--javax/swing/JTabbedPane.java8
-rw-r--r--javax/swing/JTable.java479
-rw-r--r--javax/swing/JTextArea.java43
-rw-r--r--javax/swing/JTextField.java181
-rw-r--r--javax/swing/JTextPane.java11
-rw-r--r--javax/swing/JToggleButton.java24
-rw-r--r--javax/swing/JToolBar.java3
-rw-r--r--javax/swing/JToolTip.java3
-rw-r--r--javax/swing/JTree.java52
-rw-r--r--javax/swing/JViewport.java525
-rw-r--r--javax/swing/KeyStroke.java1
-rw-r--r--javax/swing/LookAndFeel.java115
-rw-r--r--javax/swing/MutableComboBoxModel.java4
-rw-r--r--javax/swing/OverlayLayout.java326
-rw-r--r--javax/swing/Popup.java105
-rw-r--r--javax/swing/PopupFactory.java33
-rw-r--r--javax/swing/RepaintManager.java212
-rw-r--r--javax/swing/ScrollPaneLayout.java370
-rw-r--r--javax/swing/SizeRequirements.java178
-rw-r--r--javax/swing/SortingFocusTraversalPolicy.java2
-rw-r--r--javax/swing/Spring.java1
-rw-r--r--javax/swing/SwingUtilities.java6
-rw-r--r--javax/swing/ToolTipManager.java218
-rw-r--r--javax/swing/TransferHandler.java5
-rw-r--r--javax/swing/UIDefaults.java10
-rw-r--r--javax/swing/UIManager.java20
-rw-r--r--javax/swing/ViewportLayout.java3
-rw-r--r--javax/swing/border/AbstractBorder.java46
-rw-r--r--javax/swing/border/BevelBorder.java13
-rw-r--r--javax/swing/border/Border.java6
-rw-r--r--javax/swing/border/CompoundBorder.java57
-rw-r--r--javax/swing/border/EmptyBorder.java4
-rw-r--r--javax/swing/border/EtchedBorder.java45
-rw-r--r--javax/swing/border/LineBorder.java44
-rw-r--r--javax/swing/border/MatteBorder.java4
-rw-r--r--javax/swing/border/SoftBevelBorder.java12
-rw-r--r--javax/swing/border/TitledBorder.java113
-rw-r--r--javax/swing/colorchooser/AbstractColorChooserPanel.java35
-rw-r--r--javax/swing/colorchooser/ColorChooserComponentFactory.java3
-rw-r--r--javax/swing/colorchooser/DefaultSwatchChooserPanel.java3
-rw-r--r--javax/swing/event/EventListenerList.java1
-rw-r--r--javax/swing/event/InternalFrameAdapter.java147
-rw-r--r--javax/swing/event/ListDataListener.java55
-rw-r--r--javax/swing/event/MouseInputListener.java13
-rw-r--r--javax/swing/event/SwingPropertyChangeSupport.java7
-rw-r--r--javax/swing/filechooser/FileFilter.java77
-rw-r--r--javax/swing/filechooser/FileSystemView.java25
-rw-r--r--javax/swing/filechooser/FileView.java1
-rw-r--r--javax/swing/plaf/ActionMapUIResource.java4
-rw-r--r--javax/swing/plaf/BorderUIResource.java4
-rw-r--r--javax/swing/plaf/ButtonUI.java4
-rw-r--r--javax/swing/plaf/ColorChooserUI.java3
-rw-r--r--javax/swing/plaf/ColorUIResource.java4
-rw-r--r--javax/swing/plaf/ComboBoxUI.java4
-rw-r--r--javax/swing/plaf/ComponentInputMapUIResource.java3
-rw-r--r--javax/swing/plaf/ComponentUI.java8
-rw-r--r--javax/swing/plaf/DesktopIconUI.java4
-rw-r--r--javax/swing/plaf/DesktopPaneUI.java5
-rw-r--r--javax/swing/plaf/DimensionUIResource.java4
-rw-r--r--javax/swing/plaf/FileChooserUI.java4
-rw-r--r--javax/swing/plaf/FontUIResource.java4
-rw-r--r--javax/swing/plaf/IconUIResource.java3
-rw-r--r--javax/swing/plaf/InputMapUIResource.java6
-rw-r--r--javax/swing/plaf/InsetsUIResource.java3
-rw-r--r--javax/swing/plaf/InternalFrameUI.java4
-rw-r--r--javax/swing/plaf/LabelUI.java4
-rw-r--r--javax/swing/plaf/ListUI.java4
-rw-r--r--javax/swing/plaf/MenuBarUI.java4
-rw-r--r--javax/swing/plaf/MenuItemUI.java4
-rw-r--r--javax/swing/plaf/PanelUI.java4
-rw-r--r--javax/swing/plaf/PopupMenuUI.java4
-rw-r--r--javax/swing/plaf/ProgressBarUI.java4
-rw-r--r--javax/swing/plaf/RootPaneUI.java4
-rw-r--r--javax/swing/plaf/ScrollBarUI.java4
-rw-r--r--javax/swing/plaf/ScrollPaneUI.java4
-rw-r--r--javax/swing/plaf/SeparatorUI.java1
-rw-r--r--javax/swing/plaf/SliderUI.java4
-rw-r--r--javax/swing/plaf/SpinnerUI.java4
-rw-r--r--javax/swing/plaf/SplitPaneUI.java4
-rw-r--r--javax/swing/plaf/TabbedPaneUI.java4
-rw-r--r--javax/swing/plaf/TableHeaderUI.java4
-rw-r--r--javax/swing/plaf/TableUI.java4
-rw-r--r--javax/swing/plaf/TextUI.java4
-rw-r--r--javax/swing/plaf/ToolBarUI.java4
-rw-r--r--javax/swing/plaf/ToolTipUI.java4
-rw-r--r--javax/swing/plaf/TreeUI.java4
-rw-r--r--javax/swing/plaf/UIResource.java6
-rw-r--r--javax/swing/plaf/ViewportUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicArrowButton.java393
-rw-r--r--javax/swing/plaf/basic/BasicBorders.java13
-rw-r--r--javax/swing/plaf/basic/BasicButtonListener.java11
-rw-r--r--javax/swing/plaf/basic/BasicButtonUI.java128
-rw-r--r--javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java23
-rw-r--r--javax/swing/plaf/basic/BasicColorChooserUI.java20
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxEditor.java1
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxRenderer.java1
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxUI.java218
-rw-r--r--javax/swing/plaf/basic/BasicComboPopup.java58
-rw-r--r--javax/swing/plaf/basic/BasicDesktopIconUI.java2
-rw-r--r--javax/swing/plaf/basic/BasicDesktopPaneUI.java80
-rw-r--r--javax/swing/plaf/basic/BasicFileChooserUI.java510
-rw-r--r--javax/swing/plaf/basic/BasicFormattedTextFieldUI.java1
-rw-r--r--javax/swing/plaf/basic/BasicGraphicsUtils.java1
-rw-r--r--javax/swing/plaf/basic/BasicIconFactory.java26
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameTitlePane.java55
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameUI.java26
-rw-r--r--javax/swing/plaf/basic/BasicLabelUI.java18
-rw-r--r--javax/swing/plaf/basic/BasicListUI.java525
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java133
-rw-r--r--javax/swing/plaf/basic/BasicMenuBarUI.java29
-rw-r--r--javax/swing/plaf/basic/BasicMenuItemUI.java102
-rw-r--r--javax/swing/plaf/basic/BasicMenuUI.java88
-rw-r--r--javax/swing/plaf/basic/BasicOptionPaneUI.java75
-rw-r--r--javax/swing/plaf/basic/BasicPanelUI.java28
-rw-r--r--javax/swing/plaf/basic/BasicPasswordFieldUI.java1
-rw-r--r--javax/swing/plaf/basic/BasicPopupMenuUI.java12
-rw-r--r--javax/swing/plaf/basic/BasicProgressBarUI.java24
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java35
-rw-r--r--javax/swing/plaf/basic/BasicRootPaneUI.java119
-rw-r--r--javax/swing/plaf/basic/BasicScrollBarUI.java315
-rw-r--r--javax/swing/plaf/basic/BasicScrollPaneUI.java403
-rw-r--r--javax/swing/plaf/basic/BasicSeparatorUI.java73
-rw-r--r--javax/swing/plaf/basic/BasicSliderUI.java51
-rw-r--r--javax/swing/plaf/basic/BasicSpinnerUI.java16
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneDivider.java1
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneUI.java64
-rw-r--r--javax/swing/plaf/basic/BasicTabbedPaneUI.java44
-rw-r--r--javax/swing/plaf/basic/BasicTableHeaderUI.java63
-rw-r--r--javax/swing/plaf/basic/BasicTableUI.java575
-rw-r--r--javax/swing/plaf/basic/BasicTextAreaUI.java41
-rw-r--r--javax/swing/plaf/basic/BasicTextFieldUI.java15
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java94
-rw-r--r--javax/swing/plaf/basic/BasicToggleButtonUI.java65
-rw-r--r--javax/swing/plaf/basic/BasicToolBarSeparatorUI.java5
-rw-r--r--javax/swing/plaf/basic/BasicToolBarUI.java47
-rw-r--r--javax/swing/plaf/basic/BasicToolTipUI.java99
-rw-r--r--javax/swing/plaf/basic/BasicTreeUI.java838
-rw-r--r--javax/swing/plaf/basic/BasicViewportUI.java177
-rw-r--r--javax/swing/plaf/metal/MetalBorders.java374
-rw-r--r--javax/swing/plaf/metal/MetalButtonListener.java86
-rw-r--r--javax/swing/plaf/metal/MetalButtonUI.java158
-rw-r--r--javax/swing/plaf/metal/MetalCheckBoxIcon.java3
-rw-r--r--javax/swing/plaf/metal/MetalCheckBoxUI.java7
-rw-r--r--javax/swing/plaf/metal/MetalComboBoxButton.java29
-rw-r--r--javax/swing/plaf/metal/MetalComboBoxEditor.java8
-rw-r--r--javax/swing/plaf/metal/MetalComboBoxUI.java32
-rw-r--r--javax/swing/plaf/metal/MetalDesktopIconUI.java10
-rw-r--r--javax/swing/plaf/metal/MetalFileChooserUI.java430
-rw-r--r--javax/swing/plaf/metal/MetalIconFactory.java473
-rw-r--r--javax/swing/plaf/metal/MetalInternalFrameTitlePane.java24
-rw-r--r--javax/swing/plaf/metal/MetalInternalFrameUI.java8
-rw-r--r--javax/swing/plaf/metal/MetalLabelUI.java10
-rw-r--r--javax/swing/plaf/metal/MetalLookAndFeel.java35
-rw-r--r--javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java10
-rw-r--r--javax/swing/plaf/metal/MetalProgressBarUI.java33
-rw-r--r--javax/swing/plaf/metal/MetalRadioButtonUI.java15
-rw-r--r--javax/swing/plaf/metal/MetalRootPaneUI.java13
-rw-r--r--javax/swing/plaf/metal/MetalScrollBarUI.java218
-rw-r--r--javax/swing/plaf/metal/MetalScrollButton.java7
-rw-r--r--javax/swing/plaf/metal/MetalScrollPaneUI.java10
-rw-r--r--javax/swing/plaf/metal/MetalSeparatorUI.java63
-rw-r--r--javax/swing/plaf/metal/MetalSliderUI.java10
-rw-r--r--javax/swing/plaf/metal/MetalSplitPaneDivider.java2
-rw-r--r--javax/swing/plaf/metal/MetalSplitPaneUI.java35
-rw-r--r--javax/swing/plaf/metal/MetalTabbedPaneUI.java28
-rw-r--r--javax/swing/plaf/metal/MetalTextFieldUI.java32
-rw-r--r--javax/swing/plaf/metal/MetalToggleButtonUI.java38
-rw-r--r--javax/swing/plaf/metal/MetalToolBarUI.java112
-rw-r--r--javax/swing/plaf/metal/MetalToolTipUI.java272
-rw-r--r--javax/swing/plaf/metal/MetalTreeUI.java54
-rw-r--r--javax/swing/plaf/metal/MetalUtils.java99
-rw-r--r--javax/swing/plaf/metal/OceanTheme.java11
-rw-r--r--javax/swing/plaf/metal/package.html13
-rw-r--r--javax/swing/plaf/multi/MultiLookAndFeel.java1
-rw-r--r--javax/swing/table/DefaultTableCellRenderer.java11
-rw-r--r--javax/swing/table/JTableHeader.java109
-rw-r--r--javax/swing/table/TableColumnModel.java4
-rw-r--r--javax/swing/text/AbstractDocument.java197
-rw-r--r--javax/swing/text/AttributeSet.java6
-rw-r--r--javax/swing/text/BoxView.java248
-rw-r--r--javax/swing/text/ComponentView.java68
-rw-r--r--javax/swing/text/CompositeView.java20
-rw-r--r--javax/swing/text/DefaultCaret.java199
-rw-r--r--javax/swing/text/DefaultEditorKit.java24
-rw-r--r--javax/swing/text/DefaultFormatter.java5
-rw-r--r--javax/swing/text/DefaultHighlighter.java2
-rw-r--r--javax/swing/text/DefaultStyledDocument.java18
-rw-r--r--javax/swing/text/EditorKit.java10
-rw-r--r--javax/swing/text/FieldView.java7
-rw-r--r--javax/swing/text/FlowView.java38
-rw-r--r--javax/swing/text/GapContent.java256
-rw-r--r--javax/swing/text/GlyphView.java20
-rw-r--r--javax/swing/text/JTextComponent.java159
-rw-r--r--javax/swing/text/LabelView.java242
-rw-r--r--javax/swing/text/LayoutQueue.java1
-rw-r--r--javax/swing/text/ParagraphView.java30
-rw-r--r--javax/swing/text/PlainDocument.java28
-rw-r--r--javax/swing/text/PlainView.java324
-rw-r--r--javax/swing/text/Segment.java4
-rw-r--r--javax/swing/text/SimpleAttributeSet.java46
-rw-r--r--javax/swing/text/StyleContext.java11
-rw-r--r--javax/swing/text/StyledDocument.java191
-rw-r--r--javax/swing/text/Utilities.java250
-rw-r--r--javax/swing/text/View.java49
-rw-r--r--javax/swing/text/WrappedPlainView.java547
-rw-r--r--javax/swing/text/html/CSS.java35
-rw-r--r--javax/swing/text/html/HTML.java13
-rw-r--r--javax/swing/text/html/HTMLDocument.java215
-rw-r--r--javax/swing/text/html/HTMLEditorKit.java40
-rw-r--r--javax/swing/text/html/HTMLFrameHyperlinkEvent.java4
-rw-r--r--javax/swing/text/html/parser/ContentModel.java5
-rw-r--r--javax/swing/text/html/parser/DTD.java3
-rw-r--r--javax/swing/text/html/parser/DocumentParser.java7
-rw-r--r--javax/swing/text/html/parser/Element.java2
-rw-r--r--javax/swing/text/html/parser/Parser.java10
-rw-r--r--javax/swing/tree/DefaultMutableTreeNode.java1
-rw-r--r--javax/swing/tree/DefaultTreeCellEditor.java13
-rw-r--r--javax/swing/tree/DefaultTreeModel.java1
-rw-r--r--javax/swing/tree/TreeCellRenderer.java34
-rw-r--r--javax/swing/tree/TreeModel.java122
-rw-r--r--javax/swing/undo/CannotRedoException.java4
-rw-r--r--javax/swing/undo/CannotUndoException.java1
-rw-r--r--javax/xml/namespace/QName.java56
-rw-r--r--lib/Makefile.am6
-rw-r--r--lib/copy-vmresources.sh.in40
-rwxr-xr-xlib/gen-classlist.sh.in2
-rwxr-xr-xlib/split-for-gcj.sh2
-rw-r--r--m4/acattribute.m425
-rw-r--r--native/fdlibm/java-assert.h6
-rw-r--r--native/jawt/Makefile.am2
-rw-r--r--native/jni/Makefile.am13
-rw-r--r--native/jni/classpath/Makefile.am1
-rw-r--r--native/jni/classpath/primlib.c724
-rw-r--r--native/jni/classpath/primlib.h119
-rw-r--r--native/jni/gtk-peer/Makefile.am8
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c42
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c9
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c234
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c14
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c4
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c2
-rw-r--r--native/jni/java-io/Makefile.am2
-rw-r--r--native/jni/java-lang/Makefile.am2
-rw-r--r--native/jni/java-lang/java_lang_VMProcess.c1
-rw-r--r--native/jni/java-lang/java_lang_reflect_Array.c1
-rw-r--r--native/jni/java-net/Makefile.am2
-rw-r--r--native/jni/java-net/javanet.c8
-rw-r--r--native/jni/java-nio/Makefile.am2
-rw-r--r--native/jni/java-util/Makefile.am2
-rw-r--r--native/jni/midi-alsa/.cvsignore7
-rw-r--r--native/jni/midi-alsa/Makefile.am11
-rw-r--r--native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.c148
-rw-r--r--native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.c59
-rw-r--r--native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c150
-rw-r--r--native/jni/midi-dssi/.cvsignore7
-rw-r--r--native/jni/midi-dssi/Makefile.am10
-rw-r--r--native/jni/midi-dssi/README134
-rw-r--r--native/jni/midi-dssi/dssi_data.h121
-rw-r--r--native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c139
-rw-r--r--native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c584
-rw-r--r--native/jni/qt-peer/Makefile.am2
-rw-r--r--native/jni/xmlj/Makefile.am2
-rw-r--r--org/ietf/jgss/GSSCredential.java10
-rw-r--r--org/ietf/jgss/GSSName.java9
-rw-r--r--org/omg/CORBA/ACTIVITY_COMPLETED.java102
-rw-r--r--org/omg/CORBA/ACTIVITY_REQUIRED.java100
-rw-r--r--org/omg/CORBA/AnyHolder.java4
-rw-r--r--org/omg/CORBA/AnySeqHelper.java4
-rw-r--r--org/omg/CORBA/AnySeqHolder.java6
-rwxr-xr-xorg/omg/CORBA/BAD_OPERATION.java92
-rw-r--r--org/omg/CORBA/BAD_QOS.java99
-rw-r--r--org/omg/CORBA/BooleanHolder.java4
-rw-r--r--org/omg/CORBA/BooleanSeqHelper.java4
-rw-r--r--org/omg/CORBA/BooleanSeqHolder.java6
-rw-r--r--org/omg/CORBA/ByteHolder.java4
-rw-r--r--org/omg/CORBA/CODESET_INCOMPATIBLE.java103
-rw-r--r--org/omg/CORBA/CharHolder.java4
-rw-r--r--org/omg/CORBA/CharSeqHelper.java4
-rw-r--r--org/omg/CORBA/CharSeqHolder.java6
-rw-r--r--org/omg/CORBA/CompletionStatus.java10
-rw-r--r--org/omg/CORBA/CompletionStatusHelper.java4
-rw-r--r--org/omg/CORBA/DefinitionKindHelper.java6
-rw-r--r--org/omg/CORBA/DoubleHolder.java4
-rw-r--r--org/omg/CORBA/DoubleSeqHelper.java4
-rw-r--r--org/omg/CORBA/DoubleSeqHolder.java6
-rw-r--r--org/omg/CORBA/DynamicImplementation.java111
-rw-r--r--org/omg/CORBA/FieldNameHelper.java4
-rw-r--r--org/omg/CORBA/FixedHolder.java6
-rw-r--r--org/omg/CORBA/FloatHolder.java4
-rw-r--r--org/omg/CORBA/FloatSeqHelper.java4
-rw-r--r--org/omg/CORBA/FloatSeqHolder.java6
-rw-r--r--org/omg/CORBA/IDLTypeHelper.java4
-rw-r--r--org/omg/CORBA/INVALID_ACTIVITY.java100
-rw-r--r--org/omg/CORBA/IdentifierHelper.java4
-rw-r--r--org/omg/CORBA/IntHolder.java4
-rw-r--r--org/omg/CORBA/LocalObject.java128
-rw-r--r--org/omg/CORBA/LongHolder.java4
-rw-r--r--org/omg/CORBA/LongLongSeqHelper.java4
-rw-r--r--org/omg/CORBA/LongLongSeqHolder.java6
-rw-r--r--org/omg/CORBA/LongSeqHelper.java4
-rw-r--r--org/omg/CORBA/LongSeqHolder.java6
-rw-r--r--org/omg/CORBA/MARSHAL.java260
-rw-r--r--org/omg/CORBA/NO_RESOURCES.java70
-rw-r--r--org/omg/CORBA/NameValuePairHelper.java15
-rw-r--r--org/omg/CORBA/OMGVMCID.java100
-rw-r--r--org/omg/CORBA/ORB.java220
-rw-r--r--org/omg/CORBA/ObjectHelper.java7
-rw-r--r--org/omg/CORBA/ObjectHolder.java8
-rw-r--r--org/omg/CORBA/OctetSeqHelper.java4
-rw-r--r--org/omg/CORBA/OctetSeqHolder.java6
-rw-r--r--org/omg/CORBA/ParameterModeHelper.java4
-rw-r--r--org/omg/CORBA/PolicyError.java2
-rw-r--r--org/omg/CORBA/PolicyErrorCodeHelper.java115
-rw-r--r--org/omg/CORBA/PolicyErrorHelper.java158
-rw-r--r--org/omg/CORBA/PolicyErrorHolder.java103
-rw-r--r--org/omg/CORBA/PolicyHelper.java6
-rw-r--r--org/omg/CORBA/PolicyListHelper.java6
-rw-r--r--org/omg/CORBA/PrincipalHolder.java4
-rw-r--r--org/omg/CORBA/REBIND.java99
-rw-r--r--org/omg/CORBA/RepositoryIdHelper.java4
-rw-r--r--org/omg/CORBA/ServiceDetailHelper.java6
-rw-r--r--org/omg/CORBA/SetOverrideTypeHelper.java4
-rw-r--r--org/omg/CORBA/ShortHolder.java4
-rw-r--r--org/omg/CORBA/ShortSeqHelper.java4
-rw-r--r--org/omg/CORBA/ShortSeqHolder.java6
-rw-r--r--org/omg/CORBA/StringHolder.java6
-rw-r--r--org/omg/CORBA/StringSeqHelper.java4
-rwxr-xr-xorg/omg/CORBA/StringSeqHolder.java6
-rw-r--r--org/omg/CORBA/StringValueHelper.java19
-rw-r--r--org/omg/CORBA/StructMemberHelper.java7
-rw-r--r--org/omg/CORBA/SystemException.java87
-rw-r--r--org/omg/CORBA/TIMEOUT.java98
-rw-r--r--org/omg/CORBA/TRANSACTION_MODE.java99
-rw-r--r--org/omg/CORBA/TRANSACTION_UNAVAILABLE.java99
-rw-r--r--org/omg/CORBA/TypeCodeHolder.java4
-rw-r--r--org/omg/CORBA/TypeCodePackage/BadKind.java2
-rw-r--r--org/omg/CORBA/TypeCodePackage/Bounds.java2
-rw-r--r--org/omg/CORBA/ULongLongSeqHelper.java4
-rw-r--r--org/omg/CORBA/ULongLongSeqHolder.java6
-rw-r--r--org/omg/CORBA/ULongSeqHelper.java4
-rw-r--r--org/omg/CORBA/ULongSeqHolder.java6
-rw-r--r--org/omg/CORBA/UShortSeqHelper.java4
-rw-r--r--org/omg/CORBA/UShortSeqHolder.java6
-rw-r--r--org/omg/CORBA/UnionMemberHelper.java7
-rw-r--r--org/omg/CORBA/UnknownUserExceptionHelper.java157
-rw-r--r--org/omg/CORBA/UnknownUserExceptionHolder.java103
-rw-r--r--org/omg/CORBA/ValueBaseHelper.java4
-rw-r--r--org/omg/CORBA/ValueMemberHelper.java7
-rw-r--r--org/omg/CORBA/VersionSpecHelper.java4
-rw-r--r--org/omg/CORBA/VisibilityHelper.java6
-rw-r--r--org/omg/CORBA/WCharSeqHelper.java4
-rw-r--r--org/omg/CORBA/WCharSeqHolder.java6
-rw-r--r--org/omg/CORBA/WStringSeqHelper.java4
-rwxr-xr-xorg/omg/CORBA/WStringSeqHolder.java6
-rw-r--r--org/omg/CORBA/WStringValueHelper.java19
-rw-r--r--org/omg/CORBA/WrongTransactionHelper.java151
-rw-r--r--org/omg/CORBA/WrongTransactionHolder.java103
-rw-r--r--org/omg/CORBA/_IDLTypeStub.java6
-rw-r--r--org/omg/CORBA/portable/ObjectImpl.java4
-rw-r--r--org/omg/CORBA_2_3/ORB.java8
-rw-r--r--org/omg/CORBA_2_3/portable/InputStream.java18
-rw-r--r--org/omg/CORBA_2_3/portable/OutputStream.java66
-rw-r--r--org/omg/CosNaming/BindingHelper.java7
-rw-r--r--org/omg/CosNaming/BindingIteratorHelper.java32
-rw-r--r--org/omg/CosNaming/BindingIteratorPOA.java5
-rw-r--r--org/omg/CosNaming/BindingTypeHelper.java3
-rw-r--r--org/omg/CosNaming/IstringHelper.java4
-rw-r--r--org/omg/CosNaming/NameComponentHelper.java3
-rw-r--r--org/omg/CosNaming/NameHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextExtHelper.java32
-rw-r--r--org/omg/CosNaming/NamingContextExtPOA.java4
-rw-r--r--org/omg/CosNaming/NamingContextHelper.java32
-rw-r--r--org/omg/CosNaming/NamingContextPOA.java4
-rw-r--r--org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java7
-rw-r--r--org/omg/CosNaming/_BindingIteratorImplBase.java5
-rw-r--r--org/omg/CosNaming/_NamingContextExtStub.java4
-rw-r--r--org/omg/CosNaming/_NamingContextImplBase.java6
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryHelper.java32
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java2
-rw-r--r--org/omg/DynamicAny/DynAnyHelper.java19
-rw-r--r--org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java2
-rw-r--r--org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java2
-rw-r--r--org/omg/DynamicAny/DynAnySeqHelper.java2
-rw-r--r--org/omg/DynamicAny/DynArrayHelper.java19
-rw-r--r--org/omg/DynamicAny/DynEnumHelper.java19
-rw-r--r--org/omg/DynamicAny/DynFixedHelper.java19
-rw-r--r--org/omg/DynamicAny/DynSequenceHelper.java19
-rw-r--r--org/omg/DynamicAny/DynStructHelper.java19
-rw-r--r--org/omg/DynamicAny/DynUnionHelper.java19
-rw-r--r--org/omg/DynamicAny/DynValueHelper.java19
-rw-r--r--org/omg/DynamicAny/FieldNameHelper.java4
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairHelper.java2
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairSeqHelper.java2
-rw-r--r--org/omg/DynamicAny/NameValuePairHelper.java2
-rw-r--r--org/omg/DynamicAny/NameValuePairSeqHelper.java2
-rw-r--r--org/omg/DynamicAny/_DynAnyFactoryStub.java10
-rw-r--r--org/omg/IOP/CodecFactoryHelper.java19
-rw-r--r--org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java2
-rw-r--r--org/omg/IOP/CodecPackage/FormatMismatchHelper.java2
-rw-r--r--org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java2
-rw-r--r--org/omg/IOP/CodecPackage/TypeMismatchHelper.java2
-rw-r--r--org/omg/IOP/ExceptionDetailMessage.java60
-rw-r--r--org/omg/IOP/IORHelper.java3
-rw-r--r--org/omg/IOP/MultipleComponentProfileHelper.java3
-rw-r--r--org/omg/IOP/RMICustomMaxStreamFormat.java56
-rw-r--r--org/omg/IOP/ServiceContextHelper.java3
-rw-r--r--org/omg/IOP/ServiceContextListHelper.java7
-rw-r--r--org/omg/IOP/TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.java61
-rw-r--r--org/omg/IOP/TaggedComponentHelper.java5
-rw-r--r--org/omg/IOP/TaggedProfileHelper.java13
-rw-r--r--org/omg/Messaging/SyncScopeHelper.java8
-rw-r--r--org/omg/PortableInterceptor/ACTIVE.java55
-rw-r--r--org/omg/PortableInterceptor/AdapterManagerIdHelper.java119
-rw-r--r--org/omg/PortableInterceptor/AdapterNameHelper.java144
-rw-r--r--org/omg/PortableInterceptor/AdapterStateHelper.java119
-rw-r--r--org/omg/PortableInterceptor/CurrentHelper.java30
-rw-r--r--org/omg/PortableInterceptor/DISCARDING.java55
-rw-r--r--org/omg/PortableInterceptor/ForwardRequestHelper.java2
-rw-r--r--org/omg/PortableInterceptor/HOLDING.java55
-rw-r--r--org/omg/PortableInterceptor/INACTIVE.java57
-rw-r--r--org/omg/PortableInterceptor/InvalidSlotHelper.java2
-rw-r--r--org/omg/PortableInterceptor/NON_EXISTENT.java57
-rw-r--r--org/omg/PortableInterceptor/ORBIdHelper.java119
-rw-r--r--org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java1
-rw-r--r--org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java2
-rw-r--r--org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java10
-rw-r--r--org/omg/PortableInterceptor/ObjectIdHelper.java121
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceFactory.java57
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java150
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceFactoryHolder.java105
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceFactoryOperations.java64
-rw-r--r--org/omg/PortableInterceptor/ServerIdHelper.java119
-rw-r--r--org/omg/PortableServer/CurrentPackage/NoContextHelper.java2
-rw-r--r--org/omg/PortableServer/ForwardRequestHelper.java2
-rw-r--r--org/omg/PortableServer/IdAssignmentPolicyValue.java6
-rw-r--r--org/omg/PortableServer/IdUniquenessPolicyValue.java6
-rw-r--r--org/omg/PortableServer/ImplicitActivationPolicyValue.java6
-rw-r--r--org/omg/PortableServer/LifespanPolicyValue.java6
-rw-r--r--org/omg/PortableServer/POAHelper.java10
-rw-r--r--org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java2
-rw-r--r--org/omg/PortableServer/POAManagerPackage/State.java11
-rw-r--r--org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/NoServantHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/WrongAdapterHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/WrongPolicyHelper.java2
-rw-r--r--org/omg/PortableServer/POAPackage/package.html49
-rw-r--r--org/omg/PortableServer/RequestProcessingPolicyValue.java6
-rw-r--r--org/omg/PortableServer/Servant.java4
-rw-r--r--org/omg/PortableServer/ServantActivatorHelper.java31
-rw-r--r--org/omg/PortableServer/ServantLocatorHelper.java30
-rw-r--r--org/omg/PortableServer/ServantRetentionPolicyValue.java6
-rw-r--r--org/omg/PortableServer/ThreadPolicyValue.java6
-rw-r--r--org/omg/SendingContext/RunTime.java60
-rw-r--r--org/omg/SendingContext/RunTimeOperations.java57
-rw-r--r--resource/META-INF/services/javax.sound.midi.spi.MidiDeviceProvider3
-rw-r--r--test/native/lib/PrimlibInterface.c162
-rw-r--r--test/native/lib/PrimlibInterface.h141
-rw-r--r--test/native/lib/PrimlibTest.java88
-rw-r--r--vm/reference/java/lang/VMClassLoader.java123
-rw-r--r--vm/reference/java/lang/VMThread.java9
-rw-r--r--vm/reference/java/security/VMAccessController.java42
919 files changed, 58992 insertions, 15625 deletions
diff --git a/BUGS b/BUGS
index abdb4e4d5..aa7543958 100644
--- a/BUGS
+++ b/BUGS
@@ -2,4 +2,4 @@ This package is still in the early development phase. That means too
early to start listing bugs in a file like this one!
Report bugs to classpath@gnu.org or much better via Savannah at this
-URL: http://savannah.gnu.org/bugs/?group=classpath
+URL: http://www.gnu.org/software/classpath/bugs.html
diff --git a/ChangeLog b/ChangeLog
index e405c2a92..297b1c12a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,918 @@
+2005-11-01 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JPopupMenu.java
+ (setVisible): Pack the JPopupMenu before fetching the Popup
+ instance. Otherwise the PopupFactory has the wrong size for
+ its size check.
+
+2005-11-01 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JTable.java:
+ (JTable(TableModel, TableColumnModel, ListSelectionModel)): Call
+ updateUI after initializeLocalVars. Manually set the lead selection
+ indices.
+
+2005-11-01 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/plaf/basic/BasicFileChooserUI.java:
+ (getApproveButtonText): First use the JFileChooser's approve button
+ text, but if it is null, then try otherwise.
+
+2005-11-01 Christian Thalinger <twisti@complang.tuwien.ac.at>
+
+ * vm/reference/java/lang/VMThread.java (sleep): Don't round
+ ms and pass ns to Object.wait, fixes mauve test.
+
+2005-11-01 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JFileChooser.java:
+ (getDialogTitle): Allow return of null.
+ (getApproveButtonText): Likewise.
+ (getFileView): Likewise.
+ (getName): First try using the JFileChooser's FileView, if null, then
+ pass call to UI.
+ (getDescription): Likewise.
+ (getTypeDescription): Likewise.
+ (getIcon): Likewise.
+
+2005-11-01 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JTable.java:
+ (JTable(TableModel, TableColumnModel, ListSelectionModel)): Set the
+ model before calling initializeLocalVars.
+
+2005-11-01 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+ (BasicCheckBoxMenuItem): Moved code to BasicMenuItemUI.installDefaults
+ (processMouseEvent): Added TODO comment. Not sure about the
+ correct implementation yet.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Removed MenuItem.checkIcon default. Only
+ RadioButtonMenuItem's and CheckBoxMenuItem's have checkIcons.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (installDefaults): Fixed to initialized checkIcon. If the menuItem is
+ not a RadioButtonMenuItem or CheckBoxMenuItem, then checkIcon is null.
+ Also, fixed defaults to use prefix.
+
+2005-11-01 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/io/ObjectOutputStream.java
+ (writeObject): Fixed NPE.
+
+2005-10-31 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTextAreaUI.java:
+ (create): Added docs. Create WrappedPlainView instead of PlainView if
+ the text area has line wrapping turned on.
+ (propertyChange): New API method. If line wrapping is turned on or off
+ or if the style of wrapping (character or word) is changed, call
+ modelChanged().
+ * javax/swing/plaf/basic/BasicTextUI.java:
+ (setView): Call revalidate and repaint after setting the View.
+ * javax/swing/text/WrappedPlainView.java:
+ (insertUpdate): Repaint the container.
+ (removeUpdate): Likewise.
+ (changedUpdate): Likewise.
+
+2005-10-31 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/WrappedPlainView.java:
+ (viewFactory): New field.
+ (drawLine): New API method.
+ (calculateBreakPosition): Update the metrics before calling Utilities
+ methods. Fixed error in offset argument passed to the Utilities
+ methods.
+ (updateMetrics): New implementation method.
+ (getPreferredSpan): New API method.
+ (insertUpdate): Likewise.
+ (removeUpdate): Likewise.
+ (changedUpdate): Likewise.
+ (WrappedLineCreator): New class.
+ (paint): New API method.
+ (setSize): New API method.
+ (WrappedLine.paint): Implemented.
+ (WrappedLine.getPreferredSpan): Don't update the metrics, this is now
+ done in WrappedPlainView.paint.
+ (WrappedLine.modelToView): Likewise.
+ (WrappedLine.viewToModel): Likewise.
+
+2005-10-31 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/Utilities.java:
+ (getTabbedTextOffset): Adjusted for loop bound down by s.offset and
+ adjusted array index up by s.offset. This fixes the second part of
+ PR 24316. Expand tabs, not newlines. Allow the x-position to reach
+ the end specified position (use < instead of <=).
+
+2005-10-31 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTextField.java
+ (horizontalVisibility): New field.
+ (JTextField): Initialize horizontalVisibility field.
+ (getHorizontalVisibility): New method.
+
+2005-10-31 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/SocketRepository.java (not_reusable, gc): New methods.
+ (sockets): Use hashtable. (get_socket): Rewritten.
+
+2005-10-31 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (AccessibleJTable.tableChanged): Implemented.
+ (AccessibleJTable.tableRowsInserted): Implemented.
+ (AccessibleJTable.tableRowsDeleted): Implemented.
+
+2005-10-30 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (updateCurrentVisiblePath): Check whether treeModel is null.
+
+2005-10-30 Mark Wielaard <mark@klomp.org>
+
+ * examples/gnu/classpath/examples/swing/Demo.java (static): Set look
+ and feel before showing dialog. Clean up message text.
+
+2005-10-30 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/text/PlainView.java (determineMaxLineLength): Get
+ correct lenght of text.
+ (drawLine): Throw AssertionError on unexpected bad location.
+ (viewToModel): Likewise.
+
+2005-10-30 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/text/AbstractDocument.java (dump): Actually throw
+ AssertionError when constructed.
+ * javax/swing/text/DefaultFormatter.java (checkValidInput): Add cause
+ to AssertionError.
+ * javax/swing/text/DefaultStyledDocument.java (insertUpdate):
+ Likewise.
+ * javax/swing/text/GlyphView.java (getPartialSpan): Likewise.
+ (getText): Likewise.
+ * javax/swing/text/PlainView.java (determineMaxLineLength): Likewise.
+ (updateDamage): Likewise.
+
+2005-10-30 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/rmi/server/UnicastServer.java (refcache): Make it a
+ synchronized IdentityHashMap.
+
+2005-10-30 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java
+ (GdkGraphics2D(GdkGraphics2D,int, int, int,int)): New constructor.
+ (create(int,int,int,int)): Use new constructor.
+ (copyArea): Implement through create() and gdkDrawDrawable().
+
+2005-10-29 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/nio/channels/spi/AbstractSelectableChannel.java
+ (register): Throw IllegalBlockingModeException if the channel is
+ not in blocking mode.
+
+2005-10-29 David Gilbert <david.gilbert@object-refinery.com>
+
+ * examples/gnu/classpath/examples/swing/ButtonDemo.java
+ (ButtonDemo): add closePanel after content is created,
+ (createContent): don't add closePanel here,
+ * examples/gnu/classpath/examples/swing/ComboBoxDemo.java
+ (ButtonDemo): add closePanel after content is created,
+ (createContent): don't add closePanel here,
+ * examples/gnu/classpath/examples/swing/ScrollBarDemo.java
+ (ButtonDemo): add closePanel after content is created,
+ (createContent): don't add closePanel here,
+ * examples/gnu/classpath/examples/swing/SliderDemo.java
+ (ButtonDemo): add closePanel after content is created,
+ (createContent): add separate checkBoxPanel but don't add closePanel
+ here.
+
+2005-10-28 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/KeyboardFocusManager.java
+ (setCurrentKeyboardFocusManager): Create a DefaultKeyboardFocusManager
+ directly.
+ (createFocusManager): Removed.
+ * gnu/java/awt/FocusManager.java: Removed.
+ * javax/swing/FocusManager.java
+ (DisabledFocusManager): Removed inner class.
+ (WrappingFocusManager): New inner class.
+ (getCurrentManager): Return WrappingKeyboardFocusManager instance.
+
+2005-10-28 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/awt/Component.java:
+ (requestFocus): If this component is a Container, start here, not at
+ its parent when looking for the top-level ancestor. If no top-level
+ ancestor is found (parent == null), return.
+
+2005-10-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/table/DefaulTableCellRenderer.java
+ (getTableCellRenderer): Correctly configure the cell renderer for
+ selected and / or focused cells.
+ * javax/swing/table/JTableHeader.java
+ (getHeaderRect): Don't include the intercellSpacing in the
+ header rectangle.
+
+2005-10-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (MouseInputHandler.mouseDragged): Only react if table is enabled.
+ (MouseInputHandler.mousePressed): Only react if table is enabled.
+ (MouseInputHandler.mouseReleased): Only react if table is enabled.
+ (PropertyChangeHandler): New inner class. Updates the state of
+ the table if the model property changes.
+ (installDefaults): Don't load the highlightCellBorder here. This
+ is done in the cell renderer now.
+ (installListeners): Install the new PropertyChangeListener.
+ (uninstallListeners): Uninstall the new PropertyChangeListener.
+ (paintCell): Fixed determination of the selected and focused state
+ of the cell. Removed handling of the border (this is moved into
+ the cell renderer).
+ (paint): Fixed the rectangle calculation of the cell. Fixed painting
+ of the grid.
+
+2005-10-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/DefaultListSelectionModel.java
+ (setLeadSelectionIndex): Forbit some changes to leadSelectionIndex
+ when the anchorSelectionIndex is not set properly.
+
+2005-10-28 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Poa/AOM.java,
+ gnu/CORBA/Poa/AccessiblePolicy.java,
+ gnu/CORBA/Poa/DynamicImpHandler.java,
+ gnu/CORBA/Poa/StandardPolicies.java,
+ gnu/CORBA/Poa/ServantDelegateImpl.java,
+ gnu/CORBA/Poa/NamingService/NameComponentComparator.java
+ gnu/CORBA/Poa/NamingService/NameTransformer.java
+ gnu/CORBA/GIOP/ContextHandler.java,
+ gnu/CORBA/GIOP/CodeSetServiceContext.java: New files.
+ * gnu/CORBA/GIOP/contextSupportingHeader.java,
+ gnu/CORBA/GIOP/cxCodeSet.java,
+ gnu/CORBA/NamingService/cmpNameComponent.java,
+ gnu/CORBA/NamingService/snConverter.java,
+ gnu/CORBA/Poa/activeObjectMap.java,
+ gnu/CORBA/Poa/dynImpHandler.java,
+ gnu/CORBA/Poa/policySets.java,
+ gnu/CORBA/Poa/servantDelegate.java,
+ gnu/CORBA/Poa/vPolicy.java: Removed.
+ * gnu/CORBA/GIOP/CharSets_OSF:
+ Explaining the reason of setting "_OSF" apart.
+ * gnu/CORBA/CDR/AbstractCdrInput.java,
+ gnu/CORBA/CDR/AbstractCdrOutput.java,
+ gnu/CORBA/GIOP/CharSets_OSF.java,
+ gnu/CORBA/GIOP/ReplyHeader.java,
+ gnu/CORBA/GIOP/RequestHeader.java,
+ gnu/CORBA/GIOP/ServiceContext.java,
+ gnu/CORBA/GIOP/v1_0/ReplyHeader.java,
+ gnu/CORBA/GIOP/v1_0/RequestHeader.java,
+ gnu/CORBA/GIOP/v1_2/ReplyHeader.java,
+ gnu/CORBA/GIOP/v1_2/RequestHeader.java,
+ gnu/CORBA/IOR.java,
+ gnu/CORBA/NamingService/Ext.java,
+ gnu/CORBA/NamingService/NameParser.java,
+ gnu/CORBA/NamingService/NamingMap.java,
+ gnu/CORBA/Poa/ForwardedServant.java,
+ gnu/CORBA/Poa/LocalDelegate.java,
+ gnu/CORBA/Poa/LocalRequest.java,
+ gnu/CORBA/Poa/ORB_1_4.java,
+ gnu/CORBA/Poa/gnuAdapterActivator.java,
+ gnu/CORBA/Poa/gnuIdAssignmentPolicy.java,
+ gnu/CORBA/Poa/gnuIdUniquenessPolicy.java,
+ gnu/CORBA/Poa/gnuImplicitActivationPolicy.java,
+ gnu/CORBA/Poa/gnuLifespanPolicy.java,
+ gnu/CORBA/Poa/gnuPOA.java,
+ gnu/CORBA/Poa/gnuRequestProcessingPolicy.java,
+ gnu/CORBA/Poa/gnuServantObject.java,
+ gnu/CORBA/Poa/gnuServantRetentionPolicy.java,
+ gnu/CORBA/Poa/gnuThreadPolicy.java,
+ gnu/CORBA/ResponseHandlerImpl.java,
+ gnu/CORBA/gnuRequest.java,
+ gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java,
+ gnu/javax/rmi/CORBA/UtilDelegateImpl.java,
+ org/omg/CosNaming/_NamingContextExtStub.java:
+ References updated.
+
+2005-10-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (JTable): Changed order of initialization (UI first, then the model
+ etc), so that the UI gets notified of the initial model change.
+ (rowAtPoint): Don't add the intercellSpacing in the calculation
+ of the row-at-Point.
+ (setModel): Throw a PropertyChangeEvent here if the model changes.
+
+2005-10-28 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/DynAn/ValueChangeListener.java
+ gnu/CORBA/DynAn/AbstractAny.java
+ gnu/CORBA/DynAn/RecordAny.java
+ gnu/CORBA/DynAn/DivideableAny.java
+ gnu/CORBA/DynAn/UndivideableAny.java: New files.
+ * gnu/CORBA/DynAn/abstractDynAny.java,
+ gnu/CORBA/DynAn/recordAny.java,
+ gnu/CORBA/DynAn/anyDivideable.java,
+ gnu/CORBA/DynAn/anyUndivideable.java,
+ gnu/CORBA/DynAn/valueChangedListener.java: Removed.
+ * gnu/CORBA/DynAn/gnuDynAny.java,
+ gnu/CORBA/DynAn/gnuDynArray.java,
+ gnu/CORBA/DynAn/gnuDynEnum.java,
+ gnu/CORBA/DynAn/gnuDynFixed.java,
+ gnu/CORBA/DynAn/gnuDynStruct.java,
+ gnu/CORBA/DynAn/gnuDynUnion.java,
+ gnu/CORBA/DynAn/gnuDynValue.java,
+ gnu/CORBA/DynAn/gnuDynValueBox.java:
+ References updated.
+
+2005-10-28 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CDR/abstractDataInputStream.java,
+ gnu/CORBA/CDR/abstractDataOutputStream.java,
+ gnu/CORBA/CDR/aligningInputStream.java,
+ gnu/CORBA/CDR/aligningOutputStream.java,
+ gnu/CORBA/CDR/cdrBufInput.java.java,
+ gnu/CORBA/CDR/cdrBufOutput.java
+ gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/CDR/encapsulatedOutput.java,
+ gnu/CORBA/CDR/noHeaderInput.java: Removed.
+ * gnu/CORBA/CDR/HeadlessInput.java
+ gnu/CORBA/CDR/AbstractCdrInput.java
+ gnu/CORBA/CDR/AbstractCdrOutput.java
+ gnu/CORBA/CDR/AbstractDataInput.java
+ gnu/CORBA/CDR/AbstractDataOutput.java
+ gnu/CORBA/CDR/AligningInput.java
+ gnu/CORBA/CDR/AligningOutput.java
+ gnu/CORBA/CDR/BufferedCdrOutput.java
+ gnu/CORBA/CDR/BufferredCdrInput.java
+ gnu/CORBA/CDR/EncapsulationStream.java: New files.
+ * gnu/CORBA/CDR/ArrayValueHelper.java,
+ gnu/CORBA/CDR/BigEndianInputStream.java,
+ gnu/CORBA/CDR/BigEndianOutputStream.java,
+ gnu/CORBA/CDR/LittleEndianInputStream.java,
+ gnu/CORBA/CDR/LittleEndianOutputStream.java,
+ gnu/CORBA/CDR/UnknownExceptionCtxHandler.java,
+ gnu/CORBA/CDR/Vio.java,
+ gnu/CORBA/CdrEncapsCodecImpl.java,
+ gnu/CORBA/DynAn/gnuDynAny.java,
+ gnu/CORBA/GIOP/MessageHeader.java,
+ gnu/CORBA/GIOP/ReplyHeader.java,
+ gnu/CORBA/GIOP/RequestHeader.java,
+ gnu/CORBA/GIOP/ServiceContext.java,
+ gnu/CORBA/GIOP/cxCodeSet.java,
+ gnu/CORBA/GIOP/v1_0/ReplyHeader.java,
+ gnu/CORBA/GIOP/v1_0/RequestHeader.java,
+ gnu/CORBA/GIOP/v1_2/ReplyHeader.java,
+ gnu/CORBA/GIOP/v1_2/RequestHeader.java,
+ gnu/CORBA/GeneralHolder.java,
+ gnu/CORBA/IOR.java,
+ gnu/CORBA/Interceptor/gnuIcCurrent.java,
+ gnu/CORBA/IorDelegate.java,
+ gnu/CORBA/ObjectCreator.java,
+ gnu/CORBA/OrbFunctional.java,
+ gnu/CORBA/OrbRestricted.java,
+ gnu/CORBA/Poa/LocalDelegate.java,
+ gnu/CORBA/Poa/LocalRequest.java,
+ gnu/CORBA/Poa/gnuPOA.java,
+ gnu/CORBA/RawReply.java,
+ gnu/CORBA/ResponseHandlerImpl.java,
+ gnu/CORBA/ServiceRequestAdapter.java,
+ gnu/CORBA/StreamBasedRequest.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/gnuRequest.java,
+ gnu/CORBA/typecodes/GeneralTypeCode.java,
+ gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java,
+ gnu/javax/rmi/CORBA/RmiUtilities.java,
+ gnu/javax/rmi/CORBA/StubDelegateImpl.java,
+ org/omg/IOP/TaggedProfileHelper.java:
+ References updated.
+
+2005-10-28 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/rmi/CORBA/corbaObjectInput.java,
+ gnu/javax/rmi/CORBA/corbaObjectOutput.java,
+ gnu/javax/rmi/CORBA/dwoTester.java,
+ gnu/javax/rmi/CORBA/gnuRmiUtil: Deleted.
+ * gnu/javax/rmi/CORBA/CorbaInput.java,
+ gnu/javax/rmi/CORBA/CorbaOutput.java,
+ gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java,
+ gnu/javax/rmi/CORBA/RmiUtilities.java: New files.
+ * gnu/javax/rmi/CORBA/UtilDelegateImpl.java,
+ gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java:
+ References updated.
+
+2005-10-28 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/holderFactory.java,
+ gnu/CORBA/IOR_contructed_object.java,
+ gnu/CORBA/IOR_Delegate.java,
+ gnu/CORBA/Simple_delegate.java,
+ gnu/CORBA/Restricted_ORB.java,
+ gnu/CORBA/Functional_ORB.java,
+ gnu/CORBA/Focused_ORB.java: Removed.
+ * gnu/CORBA/HolderLocator.java
+ gnu/CORBA/IorDelegate.java
+ gnu/CORBA/IorObject.java
+ gnu/CORBA/OrbFocused.java
+ gnu/CORBA/OrbFunctional.java
+ gnu/CORBA/OrbRestricted.java
+ gnu/CORBA/SimpleDelegate.java: New files.
+ * gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/DynAn/abstractRecord.java,
+ gnu/CORBA/DynAn/gnuDynAny.java,
+ gnu/CORBA/DynAn/gnuDynAnyFactory.java,
+ gnu/CORBA/DynAn/gnuDynArray.java,
+ gnu/CORBA/DynAn/gnuDynValueBox.java,
+ gnu/CORBA/GIOP/ErrorMessage.java,
+ gnu/CORBA/NamingService/NameParser.java,
+ gnu/CORBA/NamingService/NamingServiceTransient.java,
+ gnu/CORBA/Poa/ForwardedServant.java,
+ gnu/CORBA/Poa/ORB_1_4.java,
+ gnu/CORBA/Poa/gnuServantObject.java,
+ gnu/CORBA/StubLocator.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/gnuRequest.java,
+ gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java,
+ gnu/javax/rmi/CORBA/gnuRmiUtil.java,
+ org/omg/CORBA/CompletionStatusHelper.java,
+ org/omg/CORBA/DefinitionKindHelper.java,
+ org/omg/CORBA/FieldNameHelper.java,
+ org/omg/CORBA/IDLTypeHelper.java,
+ org/omg/CORBA/IdentifierHelper.java,
+ org/omg/CORBA/ORB.java,
+ org/omg/CORBA/ParameterModeHelper.java,
+ org/omg/CORBA/RepositoryIdHelper.java,
+ org/omg/CORBA/SetOverrideTypeHelper.java,
+ org/omg/CORBA/StringValueHelper.java,
+ org/omg/CORBA/StructMemberHelper.java,
+ org/omg/CORBA/UnionMemberHelper.java,
+ org/omg/CORBA/ValueMemberHelper.java,
+ org/omg/CORBA/VersionSpecHelper.java,
+ org/omg/CORBA/VisibilityHelper.java,
+ org/omg/CORBA/WStringValueHelper.java,
+ org/omg/CORBA/_IDLTypeStub.java,
+ org/omg/CosNaming/IstringHelper.java,
+ org/omg/DynamicAny/FieldNameHelper.java,
+ org/omg/PortableInterceptor/AdapterNameHelper.java,
+ org/omg/PortableInterceptor/ORBIdHelper.java,
+ org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java,
+ org/omg/PortableInterceptor/ObjectIdHelper.java,
+ org/omg/PortableInterceptor/ServerIdHelper.java:
+ References updated.
+
+2005-10-28 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/universalHolder.java
+ gnu/CORBA/stubFinder.java
+ gnu/CORBA/typeNamer.java
+ gnu/CORBA/streamRequest.java
+ gnu/CORBA/streamReadyHolder.java
+ gnu/CORBA/binaryReply.java
+ gnu/CORBA/bufferedResponseHandler.java
+ gnu/CORBA/cdrEncapsCodec.java
+ gnu/CORBA/corbaArrayList.java: Removed.
+ * gnu/CORBA/CdrEncapsCodecImpl.java,
+ gnu/CORBA/CorbaList.java,
+ gnu/CORBA/GeneralHolder.java,
+ gnu/CORBA/RawReply.java,
+ gnu/CORBA/ResponseHandlerImpl.java,
+ gnu/CORBA/StreamBasedRequest.java,
+ gnu/CORBA/StreamHolder.java,
+ gnu/CORBA/StubLocator.java,
+ gnu/CORBA/TypeKindNamer.java: New files.
+ * gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/DynAn/abstractDynAny.java,
+ gnu/CORBA/DynAn/anyDivideable.java,
+ gnu/CORBA/DynAn/gnuDynAny.java,
+ gnu/CORBA/DynAn/gnuDynAnyFactory.java,
+ gnu/CORBA/Functional_ORB.java,
+ gnu/CORBA/IOR_Delegate.java,
+ gnu/CORBA/ObjectCreator.java,
+ gnu/CORBA/Poa/LocalDelegate.java,
+ gnu/CORBA/Poa/LocalRequest.java,
+ gnu/CORBA/Poa/gnuServantObject.java,
+ gnu/CORBA/Restricted_ORB.java,
+ gnu/CORBA/ServiceRequestAdapter.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/gnuCodecFactory.java,
+ gnu/CORBA/gnuContextList.java,
+ gnu/CORBA/gnuExceptionList.java,
+ gnu/CORBA/gnuNVList.java,
+ gnu/CORBA/gnuRequest.java,
+ gnu/CORBA/typecodes/RecordTypeCode.java:
+ References updated.
+
+2005-10-28 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/typecodes/AliasTypeCode.java,
+ gnu/CORBA/typecodes/ArrayTypeCode.java,
+ gnu/CORBA/typecodes/FixedTypeCode.java,
+ gnu/CORBA/typecodes/GeneralTypeCode.java,
+ gnu/CORBA/typecodes/PrimitiveTypeCode.java,
+ gnu/CORBA/typecodes/RecordTypeCode.java,
+ gnu/CORBA/typecodes/RecursiveTypeCode.java,
+ gnu/CORBA/typecodes/StringTypeCode.java,
+ gnu/CORBA/typecodes/package.html: New files.
+ * gnu/CORBA/aliasTypeCode.java,
+ gnu/CORBA/primitiveArrayTypeCode.java,
+ gnu/CORBA/fixedTypeCode.java,
+ gnu/CORBA/generalTypeCode.java,
+ gnu/CORBA/primitiveTypeCode.java,
+ gnu/CORBA/recordTypeCode.java,
+ gnu/CORBA/recursiveTypeCode.java,
+ gnu/CORBA/stringTypeCode.java: Deleted.
+ * gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/ObjectCreator.java,
+ gnu/CORBA/OctetHolder.java,
+ gnu/CORBA/Poa/LocalRequest.java,
+ gnu/CORBA/Poa/gnuServantObject.java,
+ gnu/CORBA/Restricted_ORB.java,
+ gnu/CORBA/TypeCodeHelper.java,
+ gnu/CORBA/WCharHolder.java,
+ gnu/CORBA/WStringHolder.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/typeNamer.java,
+ gnu/javax/rmi/CORBA/UtilDelegateImpl.java,
+ org/omg/CORBA/AnyHolder.java,
+ org/omg/CORBA/AnySeqHelper.java,
+ org/omg/CORBA/AnySeqHolder.java,
+ org/omg/CORBA/BooleanHolder.java,
+ org/omg/CORBA/BooleanSeqHelper.java,
+ org/omg/CORBA/BooleanSeqHolder.java,
+ org/omg/CORBA/ByteHolder.java,
+ org/omg/CORBA/CharHolder.java,
+ org/omg/CORBA/CharSeqHelper.java,
+ org/omg/CORBA/CharSeqHolder.java,
+ org/omg/CORBA/DefinitionKindHelper.java,
+ org/omg/CORBA/DoubleHolder.java,
+ org/omg/CORBA/DoubleSeqHelper.java,
+ org/omg/CORBA/DoubleSeqHolder.java,
+ org/omg/CORBA/FixedHolder.java,
+ org/omg/CORBA/FloatHolder.java,
+ org/omg/CORBA/FloatSeqHelper.java,
+ org/omg/CORBA/FloatSeqHolder.java,
+ org/omg/CORBA/IntHolder.java,
+ org/omg/CORBA/LongHolder.java,
+ org/omg/CORBA/LongLongSeqHelper.java,
+ org/omg/CORBA/LongLongSeqHolder.java,
+ org/omg/CORBA/LongSeqHelper.java,
+ org/omg/CORBA/LongSeqHolder.java,
+ org/omg/CORBA/NameValuePairHelper.java,
+ org/omg/CORBA/ORB.java,
+ org/omg/CORBA/ObjectHelper.java,
+ org/omg/CORBA/ObjectHolder.java,
+ org/omg/CORBA/OctetSeqHelper.java,
+ org/omg/CORBA/OctetSeqHolder.java,
+ org/omg/CORBA/PolicyErrorCodeHelper.java,
+ org/omg/CORBA/PrincipalHolder.java,
+ org/omg/CORBA/ShortHolder.java,
+ org/omg/CORBA/ShortSeqHelper.java,
+ org/omg/CORBA/ShortSeqHolder.java,
+ org/omg/CORBA/StringHolder.java,
+ org/omg/CORBA/StringSeqHelper.java,
+ org/omg/CORBA/StringSeqHolder.java,
+ org/omg/CORBA/TypeCodeHolder.java,
+ org/omg/CORBA/ULongLongSeqHelper.java,
+ org/omg/CORBA/ULongLongSeqHolder.java,
+ org/omg/CORBA/ULongSeqHelper.java,
+ org/omg/CORBA/ULongSeqHolder.java,
+ org/omg/CORBA/UShortSeqHelper.java,
+ org/omg/CORBA/UShortSeqHolder.java,
+ org/omg/CORBA/ValueBaseHelper.java,
+ org/omg/CORBA/WCharSeqHelper.java,
+ org/omg/CORBA/WCharSeqHolder.java,
+ org/omg/CORBA/WStringSeqHelper.java,
+ org/omg/CORBA/WStringSeqHolder.java,
+ org/omg/Messaging/SyncScopeHelper.java: References modified.
+
+2005-10-28 Nicolas Geoffray <nicolas.geoffray@menlina.com>
+
+ Reported by: Gael Thomas <gael.thomas@imag.fr>
+ * NEWS : added entry about new implementation of
+ VMClassLoader.getPackage(s), and new method
+ VMClassLoader.getBootPackages
+ * vm/reference/java/lang/VMClassLoader.java:
+ Added new definedPackages field to store packages
+ loaded by the bootstrap classloader.
+ Added new static initializer to create all packages
+ which names are returned by getBootPackages
+ (getBootPackages): new private method. Helper
+ to get as a String[] the native package names
+ (getPackage): uses the new definedPackages field
+ (getPackages): uses the new definedPackages field
+ * java/lang/Class.java:
+ (getPackage): if the classloader of the class is null
+ then call VMClassLoader.getPackage
+
+2005-10-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JEditorPane.java:
+ (getScrollableTracksViewportWidth): Return true if the component is
+ valid.
+ (getScrollableTracksViewportHeight): Likewise.
+
+2005-10-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/ScrollPaneLayout.java:
+ (preferredLayoutSize): Fixed the conditions for allocating space for
+ the scrollbars. Should allocate space if the View's dimension is
+ larger than the Viewport's dimension. This fixes the problem in
+ comment 1) for PR 23530.
+
+2005-10-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JViewport.java:
+ (scrollRectToVisible): Use the viewport bounds instead of the view
+ bounds when scrolling up and scrolling left.
+
+2005-10-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/FieldView.java
+ (getPreferredSpan): For the Y_AXIS call the superclass behaviour as
+ described in the Swing book by OReilly.
+
+2005-10-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/PortableInterceptor/ObjectIdHelper.java:
+ Assuming ObjectId as alias of byte[], not alias of String.
+
+2005-10-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTextField.java
+ (createDefaultModel): Return a normal PlainDocument here.
+ * javax/swing/text/AbstractDocument.java
+ (insertString): Correctly placed locking so that insertUpdate() is
+ called within a lock as specified. Do not setup any ElementChanges
+ here, this must be done in subclasses in insertUpdate() method.
+ Fire an UndoableEditEvent.
+ * javax/swing/text/PlainDocument.java
+ (insertString): New method. Replaces newlines with whitespace
+ when document property 'filterNewlines' is set.
+
+2005-10-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (PropertyChangeHandler.propertyChange): If orientation property
+ changes, re-setup the UI.
+ (TrackListener.mouseReleased): Removed unused code.
+ (createIncreaseButton): Simply return a new instance without any
+ hacks.
+ (createDecreaseButton): Likewise.
+ (installComponents): Do not create the incrButton and decrButton
+ here, only install them on the ScrollBar.
+ (installDefaults): Also initialize the incrButton and decrButton
+ fields here.
+ (uninstallComponents): Added some null checks.
+ (uninstallDefaults): Uninstall border using the LookAndFeel utility
+ method. Set incrButton and decrButton to null here.
+ (uninstallListeners): Added null checks.
+ (uninstallUI): Changed order of method calls. First uninstall
+ listeners then uninstallDefaults, because uninstallDefaults sets
+ the incrButton and decrButton fields to null, and uninstallListeners
+ removes a listener from them. Avoids NPE.
+
+2005-10-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java: API doc updates,
+ * javax/swing/plaf/metal/MetalButtonUI.java: likewise,
+ * javax/swing/plaf/metal/MetalCheckBoxIcon.java: likewise,
+ * javax/swing/plaf/metal/MetalCheckBoxUI.java: likewise,
+ * javax/swing/plaf/metal/MetalDesktopIconUI.java: likewise,
+ * javax/swing/plaf/metal/MetalIconFactory.java: likewise,
+ * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java: likewise,
+ * javax/swing/plaf/metal/MetalInternalFrameUI.java: likewise,
+ * javax/swing/plaf/metal/MetalLabelUI.java: likewise,
+ * javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java: likewise,
+ * javax/swing/plaf/metal/MetalProgressBarUI.java: likewise,
+ * javax/swing/plaf/metal/MetalRadioButtonUI.java: likewise,
+ * javax/swing/plaf/metal/MetalRootPaneUI.java: likewise,
+ * javax/swing/plaf/metal/MetalScrollBarUI.java: likewise,
+ * javax/swing/plaf/metal/MetalScrollPaneUI.java: likewise,
+ * javax/swing/plaf/metal/MetalSeparatorUI.java: likewise,
+ * javax/swing/plaf/metal/MetalSliderUI.java: likewise,
+ * javax/swing/plaf/metal/MetalSplitPaneUI.java: likewise,
+ * javax/swing/plaf/metal/MetalTabbedPaneUI.java: likewise,
+ * javax/swing/plaf/metal/MetalTextFieldUI.java: likewise,
+ * javax/swing/plaf/metal/MetalToolBarUI.java: likewise,
+ * javax/swing/plaf/metal/MetalToolTipUI.java: likewise,
+ * javax/swing/plaf/metal/MetalTreeUI.java: likewise,
+ * javax/swing/plaf/metal/package.html: likewise.
+
+2005-10-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalToggleButtonUI.java:
+ (MetalToggleButtonUI): removed color field initialisation,
+ (installDefaults): added color field initialisation formerly in
+ the constructor.
+
+2005-10-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/RepaintManager.java
+ (paintDirtyRegions): replaced characters in comment that caused
+ warnings in gjdoc and Eclipse.
+
+2005-10-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * BUGS: URL refreshed.
+
+2005-10-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/ExceptionCreator.java: Deleted.
+
+2005-10-26 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/PortableInterceptor/ObjectReferenceFactory.java,
+ org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java,
+ org/omg/PortableInterceptor/ObjectReferenceFactoryHolder.java,
+ org/omg/PortableInterceptor/ObjectReferenceFactoryOperations.java:
+ New files.
+
+2005-10-26 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/ViewportLayout.java:
+ (layoutContainer): Fixed incorrect boundary checks, should have been
+ checking for viewport being smaller than minimum size, not smaller
+ than preferred size.
+
+2005-10-26 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * configure.ac: Rename --with-qtdir to --with-qt4dir to make clear
+ which Qt version is meant.
+
+2005-10-26 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JList.java:
+ (getPreferredScrollableViewportSize): Use the preferred width instead
+ of the width of the widest element. This allows us to use the
+ user-specified preferred width if setPreferredSize was called. Use
+ the height of the first row, not the first visible row, when
+ calculating the preferred height. Added comments and made code cleaner
+ and more readable.
+
+2005-10-26 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/spi/ImageReaderWriterSpi.java
+ (getStreamMetadataFormat): Implement.
+ (getImageMetadataFormat): Likewise.
+
+2005-10-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/colorchooser/AbstractColorChooserPanel.java
+ (getMnemonic): implemented,
+ (getDisplayedMnemonicIndex): implemented.
+
+2005-10-26 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/PortableInterceptor/AdapterManagerIdHelper.java,
+ org/omg/PortableInterceptor/AdapterNameHelper.java,
+ org/omg/PortableInterceptor/AdapterStateHelper.java,
+ org/omg/PortableInterceptor/ORBIdHelper.java,
+ org/omg/PortableInterceptor/ObjectIdHelper.java,
+ org/omg/PortableInterceptor/ServerIdHelper.java: New files.
+ * org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java
+ (type): Fixed typo in typecode name.
+
+2005-10-25 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/WrappedPlainView: New class.
+
+2005-10-25 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonUI.java
+ (installDefaults): Removed initialization of unnecessary focusColor
+ field.
+ (paintButtonPressed): Only paint if button is opaque.
+ * javax/swing/plaf/metal/MetalButtonUI.java
+ (paintButtonPressed): Only paint if button is opaque and
+ contentAreaFilled.
+
+2005-10-25 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/CompositeView.java:
+ (getViewIndexAtPosition): Fixed boundary conditions (less than and
+ greater than signs were backward).
+
+2005-10-25 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/Utilities.java:
+ (getBreakLocation): New API method.
+
+2005-10-25 Tom Tromey <tromey@redhat.com>
+
+ * java/io/ObjectOutputStream.java (useProtocolVersion): Typo fix.
+
+2005-10-25 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/GtkDialogPeer.java
+ (create): Changed classname for the heavyweight testclass to match
+ the new classes introduced by my popup patch earlier this day.
+
+2005-10-25 Roman Kennke <kennke@aicas.com>
+
+ * examples/gnu/classpath/examples/swing/Demo.java
+ (mkMenuBar): Replaced some demos with new external demo programs,
+ namely the button demo, the scrollbar demo, the combobox demo and
+ the slider demo.
+ (mkButtonBar): Likewise.
+ * examples/gnu/classpath/examples/swing/ButtonDemo.java
+ (createContent): Made package private so that the Demo.java can
+ access it.
+ * examples/gnu/classpath/examples/swing/ComboBoxDemo.java
+ (createContent): Made package private so that the Demo.java can
+ access it.
+ * examples/gnu/classpath/examples/swing/ScrollBarDemo.java
+ (createContent): Made package private so that the Demo.java can
+ access it.
+ * examples/gnu/classpath/examples/swing/SliderDemo.java
+ (createContent): Made package private so that the Demo.java can
+ access it.
+
+2005-10-25 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JLayeredPane.java
+ (addImpl): Removed unnecessary repaint() and revalidate() calls.
+ * javax/swing/JPopupMenu.java
+ (remove): Removed unnecessary revalidate() call.
+ (insert): Removed code that installs GridBagConstraints. JPopupMenu
+ uses a BoxLayout and this is not needed anymore.
+ (pack): Send this method call to the event queue to avoid
+ synchronization problems. Set size to preferredSize of this menu.
+ (setVisible): Send this method call to the event queue to avoid
+ synchronization problems. Use PopupFactory for creating a popup.
+ (setLocation): Use int fields instead of a Point field.
+ (Popup): Removed inner interface. We use javax.swing.Popup now.
+ (LightweightPopup): Likewise.
+ (MediumWeightPopup): Likewise.
+ (HeavyWeightPopup): Likewise.
+ * javax/swing/Popup.java
+ (JWindowPopup.JWindowPopup): Add contents to contentPane of window.
+ Set focusableWindowState to false.
+ (JWindowPopup.show): Set size of window here.
+ (LightweightPopup): New inner class.
+ * javax/swing/PopupFactory.java
+ (getPopup): Return heavyweight or lightweight popup depending on
+ the parameters.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (PropertyChangeHandler): Removed unneeded inner class.
+ (BasicMenuItemUI): Removed instantiation of PropertyChangeHandler.
+ (installListeners): Removed handling of the PropertyChangeHandler.
+ (uninstallListeners): Removed handling of the PropertyChangeHandler.
+ * javax/swing/plaf/basic/BasicMenuUI.java
+ (getMaximumSize): Don't treat popup menus different.
+
+2005-10-25 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/classpath/examples/CORBA/NamingService/Demo.java (main):
+ Make arguments not final.
+
+2005-10-25 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/IDLEntity.java: Deleted.
+ * gnu/CORBA/primitiveTypeCode.java,
+ org/omg/CORBA/PolicyError.java,
+ org/omg/CORBA/TypeCodePackage/BadKind.java,
+ org/omg/CORBA/TypeCodePackage/Bounds.java:
+ Use org.omg.CORBA.portable.IDLEntity.
+
+2005-10-25 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/interfaces/SocketFactory.java: New file.
+ * gnu/CORBA/interfaces/gnuSocketFactory.java: Deleted.
+ * gnu/CORBA/DefaultSocketFactory.java,
+ gnu/CORBA/Functional_ORB.java,
+ org/omg/CORBA/ORB.java: Replacing gnuSocketFactory into SocketFactory.
+
+2005-10-25 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CosNaming/BindingIteratorHelper.java,
+ org/omg/CosNaming/NamingContextExtHelper.java,
+ org/omg/CosNaming/NamingContextHelper.java,
+ org/omg/DynamicAny/DynAnyFactoryHelper.java,
+ org/omg/DynamicAny/DynAnyHelper.java,
+ org/omg/DynamicAny/DynArrayHelper.java,
+ org/omg/DynamicAny/DynEnumHelper.java,
+ org/omg/DynamicAny/DynFixedHelper.java,
+ org/omg/DynamicAny/DynSequenceHelper.java,
+ org/omg/DynamicAny/DynStructHelper.java,
+ org/omg/DynamicAny/DynUnionHelper.java,
+ org/omg/DynamicAny/DynValueHelper.java,
+ org/omg/IOP/CodecFactoryHelper.java,
+ org/omg/PortableInterceptor/CurrentHelper.java,
+ org/omg/PortableServer/ServantActivatorHelper.java,
+ org/omg/PortableServer/ServantLocatorHelper.java: Added
+ unchecked_narrow method.
+
+2005-10-25 Roman Kennke <kennke@aicas.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen):
+ Call gdk_window_get_root_origin instead of gdk_window_get_origin
+ so that the window decorations are correctly respected.
+
2005-10-24 Tom Tromey <tromey@redhat.com>
* javax/accessibility/AccessibleStateSet.java (states):
@@ -36,6 +951,1128 @@
* java/awt/image/CropImageFilter.java (setProperties): Changed
argument type.
+2005-10-24 Tom Tromey <tromey@redhat.com>
+
+ * java/io/ObjectOutputStream.java (useProtocolVersion): Fixed typo
+ in javadoc.
+
+2005-10-24 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/StringBuffer.java (appendCodePoint): Added @since.
+ * java/lang/StringBuilder.java (insert): New overloads.
+ (appendCodePoint): New method.
+
+2005-10-24 Dalibor Topic <robilad@kaffe.org>
+
+ * test/native/lib/PrimlibInterface.c,
+ * test/native/lib/PrimlibInterface.h,
+ * test/native/lib/PrimlibTest.java:
+ Removed unused test.
+
+2005-10-24 Dalibor Topic <robilad@kaffe.org>
+
+ * native/jni/classpath/primlib.c,
+ native/jni/classpath/primlib.h: Removed since unused.
+
+ * native/jni/classpath/Makefile.am: (libclasspath_la_SOURCES)
+ Removed primlib.c and primlib.h.
+
+2005-10-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * examples/gnu/classpath/examples/swing/ScrollBarDemo.java: New file.
+
+2005-10-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (ModelListener.stateChanged): changed call to getThumbBounds() to
+ updateThumbRect(),
+ (PropertyChangeHandler.propertyChange): likewise, plus added handling
+ for 'enabled' property,
+ (getMaximumSize): return maximum dimension,
+ (getThumbBounds): just return field value,
+ (getTrackBounds): just return field value,
+ (installUI): switch order of calls to installDefaults() and
+ installComponents(),
+ (layoutHScrollBar): reimplemented using new updateThumbRect() method,
+ (layoutVScrollBar): likewise,
+ (updateThumbRect): new method,
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): added 'ScrollBar.width' default,
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ (MIN_THUMB_SIZE): changed value,
+ (MIN_THUMB_SIZE_FREE_STANDING): new field,
+ (isFreeStanding): set default to true,
+ (scrollBarShadowColor): new field,
+ (installDefaults): initialise scrollBarShadowColor,
+ (createDecreaseButton): retain reference in decreaseButton field,
+ (createIncreaseButton): retain reference in increaseButton field,
+ (paintTrackHorizontal): use scrollBarShadowColor, add special handling
+ for free standing scroll bar in disabled state,
+ (paintTrackVertical): likewise,
+ (paintThumb): separate horizontal and vertical cases,
+ (paintThumbHorizontal): new method,
+ (paintThumbVertical): new method,
+ (getMinimumThumbSize): return different size depending on whether or
+ not the scroll bar is free standing,
+ * javax/swing/plaf/metal/MetalScrollButton.java
+ (paintNorthBorderFreeStanding): modified drawing.
+
+2005-10-24 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/metadata/IIOMetadataFormatImpl.java: Complete.
+ * javax/imageio/metadata/IIOMetadataNode.java: Complete stubs.
+ * javax/imageio/metadata/IIOAttr.java: Replace with
+ IIOMetadataFormatImpl.IIOMetadataNodeAttr. Remove file.
+ * javax/imageio/metadata/IIONamedNodeMap.java: Replace with
+ IIOMetadataNode.IIONamedNodeMap. Remove file.
+ * javax/imageio/metadata/IIONodeList.java: Replace with
+ IIOMetadataNode.IIONodeList. Remove file.
+
+2005-10-24 Tom Tromey <tromey@redhat.com>
+
+ * java/text/AttributedStringIterator.java (getRunLimit): Add
+ explicit qualification.
+ (getRunStart): Likewise.
+
+2005-10-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/text/AttributedString.java
+ (AttributedString(AttributedCharacterIterator, int, int,
+ AttributedCharacterIterator.Attribute[])): renamed arguments, and
+ updated IllegalArgumentException check,
+ (addAttribute(AttributedCharacterIterator.Attribute, Object, int,
+ int)): likewise,
+ (addAttributes(Map, int, int)): changed IllegalArgumentException to
+ NullPointerException, and modified check for illegal range,
+ * java/text/AttributedStringIterator.java
+ (getRunLimit(Set)): reimplemented,
+ (getRunStart): added API docs,
+ (getRunStart(AttributedCharacterIterator.Attribute)): handle null
+ argument as a special case,
+ (getRunStart(Set)): reimplemented,
+ (getAttribute(AttributedCharacterIterator.Attribute, int)): new
+ private method,
+ (getAttribute(AttributedCharacterIterator.Attribute)): reimplemented
+ using new private method.
+ * java/text/CharacterIterator.java: minor API doc fix.
+
+2005-10-24 Roman Kennke <kennke@aicas.com>
+
+ Fixes Bug #24359
+ * javax/swing/BoxLayout.java:
+ Made class thread safe.
+
+2005-10-23 Tom Tromey <tromey@redhat.com>
+
+ * java/util/InvalidPropertiesFormatException.java: New file.
+
+2005-10-23 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/util/Properties.java
+ (storeToXML(OutputStream,String,String)): Added null pointer checks.
+ (loadFromXML(InputStream)): Implemented.
+ (PropertiesHandler): New class to handle parsing events.
+ (PropertiesHandler()): New constructor.
+ (startDTD(String,String,String)): Implemented.
+ (startElement(String,String,String,Attributes)): Implemented.
+ (characters(char[],int,int)): Implemented.
+ (endElement(String,String,String)): Implemented.
+ (endDocument()): Implemented.
+
+2005-10-23 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/lang/Thread.java
+ (sleep): Better exception message.
+
+ * java/security/AccessControlContext.java
+ (checkPermission): Likewise.
+
+ * java/util/ResourceBundle.java
+ (getBundle): Likewise.
+
+ * java/util/SimpleTimeZone.java
+ (setStartRule): Added some documentation.
+
+2005-10-23 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * configure.ac: Added support for "--with-native-libdir" and
+ "--with-glibj-dir". Generate copy-vmresources.sh
+
+ * lib/Makefile.am: Call copy-vmresources.sh to fetch possible vm
+ resources from the vmdirs.
+
+ * lib/copy-vmresources.sh.in: New script file.
+
+ * lib/gen-classlist.sh.in: Include com/ as base package for the
+ vm directories.
+
+ * native/jawt/Makefile.am,
+ native/jni/gtk-peer/Makefile.am,
+ native/jni/java-io/Makefile.am,
+ native/jni/java-lang/Makefile.am,
+ native/jni/java-net/Makefile.am,
+ native/jni/java-nio/Makefile.am,
+ native/jni/java-util/Makefile.am,
+ native/jni/midi-alsa/Makefile.am,
+ native/jni/midi-dssi/Makefile.am,
+ native/jni/qt-peer/Makefile.am,
+ native/jni/xmlj/Makefile.am: Install libraries in nativelibdir
+ and not pkglib.
+
+2005-10-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR classpath/22972
+ * java/io/File (createTempFile): Rewritten.
+
+2005-10-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/IOP/RMICustomMaxStreamFormat.java,
+ * org/omg/IOP/ExceptionDetailMessage.java: New files.
+
+2005-10-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Interceptor/Registrator.java (m_prefix): Made static.
+
+2005-10-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/rmi/CORBA/gnuRmiUtil.java (readValue):
+ Do not read fields of the ObjectImpl.
+
+2005-10-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/IOP/TAG_RMI_CUSTOM_MAX_STREAM_FORMAT,
+ * org/omg/PortableInterceptor/ACTIVE.java,
+ * org/omg/PortableInterceptor/DISCARDING.java,
+ * org/omg/PortableInterceptor/HOLDING.java,
+ * org/omg/PortableInterceptor/INACTIVE.java,
+ * org/omg/PortableInterceptor/NON_EXISTENT.java: New files.
+
+2005-10-22 Julian Scheid <julian@sektor37.de>
+
+ * java/util/Map.java (Entry.equals): Fixed invalid example code
+ in documentation.
+
+2005-10-22 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/ACTIVITY_COMPLETED.java,
+ * org/omg/CORBA/ACTIVITY_REQUIRED.java,
+ * org/omg/CORBA/BAD_QOS.java,
+ * org/omg/CORBA/CODESET_INCOMPATIBLE.java,
+ * org/omg/CORBA/INVALID_ACTIVITY.java,
+ * org/omg/CORBA/REBIND.java,
+ * org/omg/CORBA/TIMEOUT.java,
+ * org/omg/CORBA/TRANSACTION_MODE.java,
+ * org/omg/CORBA/TRANSACTION_UNAVAILABLE.java: New exceptions.
+
+2005-10-22 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/rmi/CORBA/ValueHandlerMultiFormat.java: New interface.
+ * gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java
+ (getMaximumStreamFormatVersion, writeValue): New methods.
+
+2005-10-22 Mark Wielaard <mark@klomp.org>
+
+ * java/net/URLClassloader.java (addURLs): Add comment about jboss.
+
+2005-10-21 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+ (BasicCheckBoxMenuItem): Implemented.
+ (installDefaults): Removed method, not in API.
+ (processMouseEvent): Implemented.
+ * javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
+ (processMouseEvent): Implemented.
+
+2005-10-21 Christian Thalinger <twisti@complang.tuwien.ac.at>
+
+ * configure.ac: Also check for pangoft2 without cairo and
+ additionally check for freetype2.
+ * native/jni/gtk-peer/Makefile.am: Added X, pangoft2 and
+ freetype2 CFLAGS and LDFLAGS.
+
+2005-10-21 Nicolas Geoffray <nicolas.geoffray@menlina.com>
+
+ * vm/reference/java/lang/VMClassLoader.java
+ (getResources): uses a new static field HashMap to
+ store opened zip files from property java.boot.class.path.
+
+2005-10-21 Nicolas Geoffray <nicolas.geoffray@menlina.com>
+
+ * vm/reference/java/lang/VMClassLoader.java
+ (getRessources): In case the property java.boot.class.path
+ contains directories, tests if the ressource exists before adding
+ it to the vector result.
+
+2005-10-21 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (paint): Only paint focus if enabled.
+
+2005-10-21 David Daney <ddaney@avtrex.com>
+
+ * NEWS: Added entry about HttpURLConnection improvements.
+
+2005-10-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/DefaultSocketFactory.java,
+ * gnu/CORBA/interfaces/gnuSocketFactory.java,
+ * gnu/CORBA/interfaces/package.html: New files.
+ * gnu/CORBA/Functional_ORB.java,
+ * gnu/CORBA/Focused_ORB.java (getPortServer),
+ * gnu/CORBA/GIOP/ErrorMessage.java (send),
+ * gnu/CORBA/gnuRequest.java (submit): Rewritten to support
+ gnu.Corba.SocketFactory property.
+ * org/omg/CORBA/ORB.java: Documentation update.
+
+2005-10-21 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JPopupMenu.java
+ (show): Fixed to set the size if it was never set.
+ * javax/swing/plaf/basic/BasicMenuUI.java
+ (menuDeselected): Added check to prevent NPE.
+ * javax/swing/plaf/basic/BasicSeparatorUI.java:
+ Removed minSize, horizontalPrefSize, verticalPrefSize and
+ maxSize fields. They were causing problems when other classes
+ were setting this variables to something else. More reliable if
+ actual value is returned.
+ (getPreferredSize): Returned appropriate values.
+ (getMinimumSize): Likewise.
+ (getMaximumSize): Likewise.
+
+2005-10-21 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/lang/reflect/Proxy.java
+ (ProxyType.ProxyType): Don't replace null with system class loader.
+ (ProxyType.hashCode): Handle null loader.
+
+2005-10-20 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/DefaultListSelectionModel.java:
+ (setLeadSelectionIndex): If the selection mode is SINGLE_SELECTION then
+ pass this call to setSelectionInterval.
+ (addSelectionInterval): If the selection mode is SINGLE_SELECTION then
+ pass the call to setSelectionInterval and avoid the lengthy checks
+ that don't apply to this mode.
+ * javax/swing/JList.java:
+ (getSelectedIndices): Changed bounds of for loop to include the
+ maxSelectionIndex.
+
+2005-10-20 Lillian Angel <langel@redhat.com>
+
+ * examples/gnu/classpath/examples/swing/Demo.java
+ (mkRadio): Changed to create a panel that contains
+ 2 buttons in a ButtonGroup.
+ * javax/swing/ButtonGroup.java
+ (add): Fixed to initialize sel if the newly added
+ button is already selected.
+ * javax/swing/JToggleButton.java
+ (isSelected): Implemented.
+ (setSelected): Implemented.
+ * javax/swing/plaf/metal/MetalRadioButtonUI.java
+ (paintFocus): Fixed size of border drawn around the
+ radio button.
+
+2005-10-20 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * java/awt/ScrollPaneAdjustable.java:
+ (addAdjustmentListener): If parameter is null take no action and throw
+ no exception. Store the resulting listener chain from call to
+ AWTEventMulticaster.add.
+ (removeAdjustmentListener): If parameter is null take no action and
+ throw no exception. Store the resulting listener chain from call to
+ AWTEventMulticaster.remove.
+
+2005-10-20 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/LookAndFeel.java:
+ (loadKeyBindings): Implemented and added docs.
+ (makeComponentInputMap): Likewise.
+ (makeInputMap): Likewise.
+ (makeKeyBindings): Likewise.
+ * javax/swing/plaf/basic/BasicListUI.java:
+ (convertModifiers): Removed this no longer needed private method.
+ (installKeyboardActions): Removed the code relating to modifier
+ conversion and made code more readable by using local variables.
+ * javax/swing/plaf/basic/BasicTableUI.java:
+ (convertModifiers): Removed this no longer needed private method.
+ (installKeyboardActions): Removed the code relating to modifier
+ conversion and made code more readbale by using local variables.
+
+2005-10-20 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicMenuItemUI.java:
+ Added new ItemListener field.
+ (BasicMenuItemUI): Initialized new field.
+ (installListeners): Installed new listener.
+ (removeListeners): Removed new listener.
+ (MenuDragMouseHandler): Class should be private, not
+ in API.
+ (MenuKeyHandler): Likewise.
+ (PropertyChangeHandler): Likewise.
+ (ItemHandler): New class implemented to change the
+ state of the menu item if it is a checkbox menu item.
+
+2005-10-20 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/BoxView.java
+ (layoutMinorAxis): Calculate total requirements before calling
+ the SizeRequirements utility method. Avoids an NPE.
+
+2005-10-20 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicArrowButton.java: Updated API docs all
+ over, plus:
+ (defaultSize): removed field,
+ (upIcon): removed field,
+ (downIcon): removed field,
+ (leftIcon): removed field,
+ (rightIcon): removed field,
+ (darkShadow): changed color value,
+ (paint): ignore insets for triangle positioning, but check 'armed'
+ state,
+ (paintTriangle): delegate to new private methods depending on
+ direction,
+ (paintTriangleNorth): new private method,
+ (paintTriangleSouth): new private method,
+ (paintTriangleEast): new private method,
+ (paintTriangleWest): new private method.
+
+2005-10-20 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/ietf/jgss/GSSCredential.java (hashCode),
+ * org/ietf/jgss/GSSName.java (hashCode): New declarations.
+
+2005-10-19 Mark Wielaard <mark@klomp.org>
+
+ * java/net/URLClassLoader.java (addURLs): Don't call addURL(), but
+ call urls.add() and addURLImpl() directly on each URL.
+
+2005-10-19 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * javax/swing/text/html/HTMLEditorKit.java: Add missing import.
+
+2005-10-19 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/HTMLEditorKit.java (getParser): New method.
+
+2005-10-19 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/parser/ContentModel.java: Fixed comments for
+ parameterless constructor.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (getDebugGraphicsOptions): Removed debug output.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (isShowing): Fixed condition.
+ (show): Only repaint if component is showing.
+ (hide): Only repaint if component was showing.
+
+2005-10-19 Mark Wielaard <mark@klomp.org>
+
+ * javax/security/auth/login/LoginContext.java (lookupModule):
+ Load LoginModule through Thread context class loader.
+
+2005-10-19 Mark Wielaard <mark@klomp.org>
+
+ * java/net/Socket.java (getImpl): Chain exception before throwing.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/AbstractSpinnerModel.java
+ * javax/swing/ActionMap.java
+ * javax/swing/BoundedRangeModel.java
+ * javax/swing/Box.java
+ * javax/swing/BoxLayout.java
+ * javax/swing/ButtonGroup.java
+ * javax/swing/CellEditor.java
+ * javax/swing/CellRendererPane.java
+ * javax/swing/ComboBoxEditor.java
+ * javax/swing/DefaultButtonModel.java
+ * javax/swing/DefaultCellEditor.java
+ * javax/swing/DefaultDesktopManager.java
+ * javax/swing/DefaultListCellRenderer.java
+ * javax/swing/DesktopManager.java
+ * javax/swing/ImageIcon.java
+ * javax/swing/InputVerifier.java
+ * javax/swing/JCheckBoxMenuItem.java
+ * javax/swing/JColorChooser.java
+ * javax/swing/JDesktopPane.java
+ * javax/swing/JFileChooser.java
+ * javax/swing/JLayeredPane.java
+ * javax/swing/JList.java
+ * javax/swing/JMenu.java
+ * javax/swing/JMenuBar.java
+ * javax/swing/JMenuItem.java
+ * javax/swing/JOptionPane.java
+ * javax/swing/JPasswordField.java
+ * javax/swing/JPopupMenu.java
+ * javax/swing/JProgressBar.java
+ * javax/swing/JRadioButtonMenuItem.java
+ * javax/swing/JRootPane.java
+ * javax/swing/JSeparator.java
+ * javax/swing/JSlider.java
+ * javax/swing/JSpinner.java
+ * javax/swing/JSplitPane.java
+ * javax/swing/JTabbedPane.java
+ * javax/swing/JTable.java
+ * javax/swing/JTextPane.java
+ * javax/swing/JToolBar.java
+ * javax/swing/JToolTip.java
+ * javax/swing/JTree.java
+ * javax/swing/KeyStroke.java
+ * javax/swing/LookAndFeel.java
+ * javax/swing/MutableComboBoxModel.java
+ * javax/swing/Popup.java
+ * javax/swing/PopupFactory.java
+ * javax/swing/RepaintManager.java
+ * javax/swing/SortingFocusTraversalPolicy.java
+ * javax/swing/Spring.java
+ * javax/swing/SwingUtilities.java
+ * javax/swing/ToolTipManager.java
+ * javax/swing/TransferHandler.java
+ * javax/swing/ViewportLayout.java
+ Reformatted slightly. Filled emtpy blocks with comments. Fixed some
+ slight API doc errors. Removed some unneeded imports. Removed
+ unneeded serialization methods.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/OverlayLayout.java
+ (checkLayout): Respect the container's insets correctly.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JLabel.java
+ (setText): Call revalidate() and repaint().
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JEditorPane.java
+ Added comments to empty blocks.
+ (read): Implemented this previously stubbed method.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComboBox.java
+ Added comments to empty blocks.
+ (writeObject): Removed unnecessary serialization method.
+ (processKeyEvent): Implemented this previously stubbed method.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JButton.java
+ (removeNotify): Implemented this previously stubbed method.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/undo/CannotRedoException.java
+ * javax/swing/undo/CannotUndoException.java
+ Put super() call in empty constructors.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/tree/DefaultMutableTreeNode.java
+ * javax/swing/tree/DefaultTreeCellEditor.java
+ * javax/swing/tree/TreeCellRenderer.java
+ * javax/swing/tree/TreeModel.java
+ Reformatted slightly. Filled emtpy blocks with comments. Fixed some
+ slight API doc errors. Removed some unneeded imports.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/AbstractDocument.java
+ * javax/swing/text/AttributeSet.java
+ * javax/swing/text/ComponentView.java
+ * javax/swing/text/DefaultCaret.java
+ * javax/swing/text/DefaultEditorKit.java
+ * javax/swing/text/DefaultHighlighter.java
+ * javax/swing/text/EditorKit.java
+ * javax/swing/text/FieldView.java
+ * javax/swing/text/FlowView.java
+ * javax/swing/text/GlyphView.java
+ * javax/swing/text/JTextComponent.java
+ * javax/swing/text/LayoutQueue.java
+ * javax/swing/text/PlainView.java
+ * javax/swing/text/Segment.java
+ * javax/swing/text/StyledDocument.java
+ * javax/swing/text/html/HTMLEditorKit.java
+ * javax/swing/text/html/HTMLFrameHyperlinkEvent.java
+ * javax/swing/text/html/parser/DocumentParser.java
+ Reformatted slightly. Filled emtpy blocks with comments. Fixed some
+ slight API doc errors. Removed some unneeded imports.
+
+2005-10-19 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicArrowButton.java
+ (buttonBorder): removed,
+ (BasicArrowButton): don't set border, use default border,
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (configureArrowButton): don't set margin here,
+ (getPreferredSize): added comment,
+ (getMinimumSize): icon width is the same as the display area height,
+ (getDefaultSize): return size of space char plus 1 pixel margin,
+ (getDisplaySize): take into account the prototype display value, if
+ there is one,
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): updated 'Button.margin' default,
+ * javax/swing/plaf/metal/MetalComboBoxButton.java
+ (MetalComboBoxButton(JComboBox, Icon, boolean, CellRendererPane,
+ JList)): check for null JComboBox, don't set margin here,
+ * javax/swing/plaf/metal/MetalComboBoxUI.java
+ (createArrowButton): set margin,
+ (getMinimumSize): reimplemented,
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): changed 'Button.margin' default to from Insets
+ to InsetsUIResource.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/html/HTML.java
+ * javax/swing/text/html/HTMLDocument.java
+ Filled emtpy blocks with comments.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/html/parser/ContentModel.java
+ * javax/swing/text/html/parser/DTD.java
+ * javax/swing/text/html/parser/DocumentParser.java
+ * javax/swing/text/html/parser/Element.java
+ * javax/swing/text/html/parser/Parser.java
+ Filled emtpy blocks with comments.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/table/TableColumnModel.java:
+ Fixed some minor API doc errors.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/ActionMapUIResource.java
+ * javax/swing/plaf/BorderUIResource.java
+ * javax/swing/plaf/ButtonUI.java
+ * javax/swing/plaf/ColorChooserUI.java
+ * javax/swing/plaf/ColorUIResource.java
+ * javax/swing/plaf/ComboBoxUI.java
+ * javax/swing/plaf/ComponentInputMapUIResource.java
+ * javax/swing/plaf/DesktopIconUI.java
+ * javax/swing/plaf/DesktopPaneUI.java
+ * javax/swing/plaf/DimensionUIResource.java
+ * javax/swing/plaf/FileChooserUI.java
+ * javax/swing/plaf/FontUIResource.java
+ * javax/swing/plaf/IconUIResource.java
+ * javax/swing/plaf/InputMapUIResource.java
+ * javax/swing/plaf/InsetsUIResource.java
+ * javax/swing/plaf/InternalFrameUI.java
+ * javax/swing/plaf/LabelUI.java
+ * javax/swing/plaf/ListUI.java
+ * javax/swing/plaf/MenuBarUI.java
+ * javax/swing/plaf/MenuItemUI.java
+ * javax/swing/plaf/PanelUI.java
+ * javax/swing/plaf/PopupMenuUI.java
+ * javax/swing/plaf/ProgressBarUI.java
+ * javax/swing/plaf/RootPaneUI.java
+ * javax/swing/plaf/ScrollBarUI.java
+ * javax/swing/plaf/ScrollPaneUI.java
+ * javax/swing/plaf/SeparatorUI.java
+ * javax/swing/plaf/SliderUI.java
+ * javax/swing/plaf/SpinnerUI.java
+ * javax/swing/plaf/SplitPaneUI.java
+ * javax/swing/plaf/TabbedPaneUI.java
+ * javax/swing/plaf/TableHeaderUI.java
+ * javax/swing/plaf/TableUI.java
+ * javax/swing/plaf/TextUI.java
+ * javax/swing/plaf/ToolBarUI.java
+ * javax/swing/plaf/ToolTipUI.java
+ * javax/swing/plaf/TreeUI.java
+ * javax/swing/plaf/UIResource.java
+ * javax/swing/plaf/ViewportUI.java
+ Reformatted slightly. Filled emtpy blocks with comments.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/ComponentUI.java
+ Filled empty blocks with comments.
+ (update): Reverted my patch from 2005-10-12. This is wrong. If there
+ are still clipping problems, then certainly in another area.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/multi/MultiLookAndFeel.java
+ Filled empty block with comment.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java
+ * javax/swing/plaf/metal/MetalButtonListener.java
+ * javax/swing/plaf/metal/MetalComboBoxEditor.java
+ * javax/swing/plaf/metal/MetalComboBoxUI.java
+ * javax/swing/plaf/metal/MetalFileChooserUI.java
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
+ * javax/swing/plaf/metal/MetalProgressBarUI.java
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ * javax/swing/plaf/metal/MetalSliderUI.java
+ * javax/swing/plaf/metal/MetalSplitPaneUI.java
+ * javax/swing/plaf/metal/MetalTabbedPaneUI.java
+ * javax/swing/plaf/metal/MetalTextFieldUI.java
+ * javax/swing/plaf/metal/MetalToolBarUI.java
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ * javax/swing/plaf/metal/MetalUtils.java:
+ Reformatted slightly. Filled emtpy blocks with comments. Fixed some
+ slight API doc errors. Removed some unneeded imports.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (getDebugGraphicsOptions): Fixed to load system property if present.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/DebugGraphics.java
+ (counter): New field.
+ (color): Removed unneeded field.
+ (DebugGraphics()): Count up.
+ (DebugGraphics(Graphics,JComponent)): Call this(Graphics).
+ (DebugGraphics(Graphics)): Call this().
+ (setColor): Implemented logging facility.
+ (create): Copy debugOptions over to new DebugGraphics instance.
+ (create(int,int,int,int)): Likewise.
+ (setFont): Implemented logging facility.
+ (getColor): Return graphics.getColor().
+ (translate): Implemented logging facility.
+ (setPaintMode): Likewise.
+ (setXORMode): Likewise.
+ (clipRect): Likewise.
+ (setClip(int,int,int,int)): Likewise.
+ (setClip(Shape)): Likewise.
+ (drawRect): Likewise. Only flash when FLASH_OPTION is set.
+ (fillRect): Likewise.
+ (clearRect): Implemented logging facility.
+ (drawRoundRect): Likewise.
+ (fillRoundRect): Likewise.
+ (drawLine): Likewise.
+ (draw3DRect): Likewise.
+ (fill3DRect): Likewise.
+ (drawOval): Likewise.
+ (fillOval): Likewise.
+ (drawArc): Likewise.
+ (fillArc): Likewise.
+ (drawPolyline): Likewise.
+ (drawPolygon): Likewise.
+ (fillPolygon): Likewise.
+ (drawString(String,int,int)): Likewise.
+ (drawString(AttributedCharacterIterator,int,int)): Likewise.
+ (drawByted): Likewise.
+ (drawChars): Likewise. Only flash if FLASH_OPTION is set.
+ (drawImage): Implemented logging facility. (Also applies to all
+ overloaded versions of this method).
+ (copyArea): Likewise.
+ (setDebugOptions): Likewise.
+ (prefix): New helper method.
+ * javax/swing/JComponent.java
+ (getComponentGraphics): Implemented to return DebugGraphics when
+ needed.
+ (getDebugGraphicsOptions): Implemented to return the correct options.
+ Also, this loads a system property gnu.javax.swing.DebugGraphics
+ if present and evaluates it.
+
+2005-10-19 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JList.java
+ (getAccessibleContext): Returned an instance of
+ AccessibleJList. Should never return null.
+
+2005-10-19 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java:
+ Added MouseListener and removed MouseInputListener.
+ (BasicTreeUI): Initialized mouseListener and removed
+ mouseInputListener.
+ (removeListeners): Removed mouseListener and removed
+ mouseInputListener code.
+ (installListeners): Likewise.
+ (MouseInputHandler.mousePressed): Moved code to MouseHandler.
+ (MouseHandler.mousePressed): Likewise.
+ * javax/swing/plaf/metal/MetalTreeUI.java:
+ Added MouseListener and removed MouseInputListener.
+ (installUI): Initialized mouseListener and removed
+ mouseInputListener.
+ (uninstallUI): Removed mouseListener and removed
+ mouseInputListener code.
+
+2005-10-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicBorders.java
+ * javax/swing/plaf/basic/BasicButtonListener.java
+ * javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+ * javax/swing/plaf/basic/BasicComboBoxEditor.java
+ * javax/swing/plaf/basic/BasicComboBoxRenderer.java
+ * javax/swing/plaf/basic/BasicDesktopIconUI.java
+ * javax/swing/plaf/basic/BasicDesktopPaneUI.java
+ * javax/swing/plaf/basic/BasicFileChooserUI.java
+ * javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
+ * javax/swing/plaf/basic/BasicGraphicsUtils.java
+ * javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ * javax/swing/plaf/basic/BasicLabelUI.java
+ * javax/swing/plaf/basic/BasicListUI.java
+ * javax/swing/plaf/basic/BasicMenuBarUI.java
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ * javax/swing/plaf/basic/BasicMenuUI.java
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ * javax/swing/plaf/basic/BasicPasswordFieldUI.java
+ * javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
+ * javax/swing/plaf/basic/BasicRootPaneUI.java
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ * javax/swing/plaf/basic/BasicSplitPaneDivider.java
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ * javax/swing/plaf/basic/BasicTableHeaderUI.java
+ * javax/swing/plaf/basic/BasicTableUI.java
+ * javax/swing/plaf/basic/BasicTextAreaUI.java
+ * javax/swing/plaf/basic/BasicTextUI.java
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ * javax/swing/plaf/basic/BasicToolTipUI.java
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ * javax/swing/plaf/basic/BasicViewportUI.java:
+ Reformatted slightly. Filled emtpy blocks with comments. Fixed some
+ slight API doc errors.
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/filechooser/FileFilter.java:
+ * javax/swing/filechooser/FileView.java:
+ Filled empty blocks with comments.
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/event/EventListenerList.java:
+ * javax/swing/event/InternalFrameAdapter.java:
+ * javax/swing/event/MouseInputListener.java:
+ Reformatted slightly. Filled emtpy blocks with comments. Fixed some
+ slight API doc errors
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/colorchooser/AbstractColorChooserPanel.java:
+ * javax/swing/colorchooser/ColorChooserComponentFactory.java:
+ * javax/swing/colorchooser/DefaultSwatchChooserPanel.java:
+ Filled empty blocks with comments.
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/border/AbstractBorder.java:
+ * javax/swing/border/BevelBorder.java:
+ * javax/swing/border/Border.java:
+ * javax/swing/border/CompoundBorder.java:
+ * javax/swing/border/EmptyBorder.java:
+ * javax/swing/border/EtchedBorder.java:
+ * javax/swing/border/LineBorder.java:
+ * javax/swing/border/MatteBorder.java:
+ * javax/swing/border/SoftBevelBorder.java:
+ * javax/swing/border/TitledBorder.java:
+ Reformatted slightly. Filled emtpy blocks with comments. Fixed some
+ slight API doc errors
+
+2005-10-18 Lillian Angel <langel@redhat.com>
+
+ * java/awt/GridBagLayout.java
+ (GetLayoutInfo): Added a null check for lastComponent. Prevents
+ NPE.
+
+2005-10-18 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTable.java
+ (JTable): Moved code around so all models are set before
+ any other function is called. Prevents all NPEs with
+ models.
+
+2005-10-18 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/DefaultListSelectionModel.java:
+ (setLeadSelectionIndex): Avoid index out of bounds error on initial
+ call of this method by checking explicitly for oldLeadIndex being -1.
+ Also remove unused BitSet newRange and oldRange.
+ (moveLeadSelectionIndex): New API method implemented (@since 1.5).
+ * javax/swing/plaf/basic/BasicListUI.java:
+ (ListAction.actionPerformed): Make code more readable by declaring
+ local variables for the actionCommand and for the list's
+ selectionModel. Implemented the following bindings:
+ selectLastRowChangeLead, scrollDownChangeLead, scrollUpChangeLead,
+ selectFirstRowChangeLead, selectNextRowChangeLead,
+ selectPreviousRowChangeLead, addToSelection, toggleAndAnchor,
+ extendTo.
+ (MouseInputHandler.mousePressed): Made code more readable by removing
+ unnecessary full qualification from variable 'list'. Change
+ behaviour of shift-click based on whether or not the anchor index is
+ selected.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java:
+ (initComponentDefaults): Added remaining bindings for
+ Table.ancestorMap.
+ * javax/swing/plaf/basic/BasicTableUI.java:
+ (TableAction.actionPerformed): Made type of variables rowModel and
+ colModel more specific to avoid many casts later on (makes code more
+ readable). Also declare local variable to store the action command to
+ make the code more readable. Implemented the following bindings:
+ selectNextRowChangeLead, selectPreviousRowChangeLead,
+ selectNextColumnChangeLead, selectPreviousColumnChangeLead,
+ addToSelection, extendTo, toggleAndAnchor. Added commented-out debug
+ statement to print unimplemented bindings when used. Added check for
+ the SPACE character to make sure it doesn't stop editing.
+
+2005-10-18 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java:
+ Removed leafIcon field.
+ (BasicTreeUI): Removed leafIcon initialization.
+ (installDefaults): Icon defaults were wrong, fixed.
+ (isLocationInExpandControl): Fixed to incorporated gap.
+ (mousePressed): Fixed to include correct icon widths. Sometimes
+ the labels icon is different from what the tree's default icon is
+ set to. Added a check for this.
+ (getCellBounds): No need to include gap here.
+ (getCurrentControlIcon): Fixed to use expandedIcon and collapsedIcon.
+ (paintRow): No need paint beyond preferred width of tree here.
+ (updateCurrentVisiblePath): If nothing is selected, the root should
+ be selected without focus.
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (installDefaults): Fixed defaults for the expanded/collapsed icons.
+
+2005-10-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JComboBox.java
+ (setModel): update the selectedItemReminder field,
+ (selectedItemChanged): only send ItemEvent.SELECTED event if the new
+ selection is non-null.
+
+2005-10-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (installComponents): only set default editor if the current editor is
+ null or implements UIResource,
+ (uninstallComponents): only clear editor if it implements UIResource.
+
+2005-10-18 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (installDefaults): Set the selected text color for the
+ text component.
+
+2005-10-18 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTree.java
+ (scrollPathToVisible): Reimplemented to make the path visible if its
+ parent is not expanded.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (installDefaults): Initialized row height for the tree.
+ (updateCurrentVisiblePath): Updated the visible row count.
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (installUI): Initialized row height for the tree.
+
+2005-10-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalComboBoxUI.java
+ (editablePropertyChanged): handle null selected item.
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (PropertyChangeHandler.propertyChange): Removed repaint call.
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/AbstractButton.java
+ Filled empty blocks with comments.
+ (ButtonChangeListener.stateChanged): Moved implementation from
+ inner class in createChangeListener to this protected class.
+ (setEnabled): Do nothing if actual state does not change.
+ (createChangeListener): Return instance of ButtonChangeListener
+ here.
+
+2005-10-18 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (buttonBackground): new field,
+ (shadow): renamed buttonShadow,
+ (darkShadow): renamed buttonDarkShadow,
+ (highlight): renamed buttonHighlight,
+ (installDefaults): initialise buttonBackground, plus updates for
+ renamed fields,
+ (uninstallDefaults): clear buttonBackground, plus updates for renamed
+ fields,
+ (createEditor): return subclass that implements UIResource,
+ (createArrowButton): use constructor that accepts colors,
+ (getMaximumSize): fix API doc error,
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): correct 'ComboBox.buttonDarkShadow' default.
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JViewport.java
+ (setView): Added repaint() call.
+ (revalidate): Removed unnecessary and unspecified method.
+ (reshape): Fire stateChanged if only the size changes. Do not fire
+ stateChanged if only the location changes.
+ (scrollRectToVisible): Reworked most of this method to correctly
+ determine the scroll offsets. Added validation of view as specified.
+
+2005-10-18 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/ScrollPaneLayout.java
+ (preferredLayoutSize): Removed check for JScrollPane argument.
+ Added code to respect the insets of the JScrollPane.
+ (minimumLayoutSize): Likewise.
+ (layoutContainer): Removed check for JScrollPane argument.
+
+2005-10-18 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/io/ObjectInputStream.java
+ (parseContent): Removed bogus println and fixed bug #24422.
+
+2005-10-17 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (setDividerLocation): Added a check for the size
+ of the splitpane, in some cases the divider's
+ initial location was being set to 0.
+
+2005-10-17 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JViewport.java:
+ (scrollRectToVisible): Return immediately if the View is null. Check
+ for contentRect being bigger than the port bounds separately in each
+ direction, rather than together.
+ * javax/swing/plaf/basic/BasicListUI.java:
+ (KeyHandler): Removed this private class that listened directly for
+ key presses. This is now handled through InputMap-ActionMap pairs.
+ (ActionListenerProxy): New class to wrap the Actions for this lists
+ ActionMap.
+ (ListAction): New class, the actions for keypresses on this list.
+ (convertModifiers): New private method converts key press modifiers to
+ the old style (CTRL_MASK instead of CTRL_DOWN_MASK, etc.).
+ (installKeyboardActions): Get the InputMap from the UIManager and
+ register new InputMap-ActionMap pairs, then set these as the parents
+ of the list's InputMap and ActionMap.
+ (selectNextIndex): Avoid NPE by checking if we're already at the last
+ index.
+ (selectPreviousIndex): Check if we're already at the first index.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java:
+ (initComponentDefaults): Added bindings for List.focusInputMap.
+
+2005-10-17 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (installUI): Moved call to installKeyboardActions and Listeners
+ to before expansion of root.
+ (paint): Added check to make sure the cached visible path is updated.
+ (treeExpanded): Added call to update visible path.
+ (treeCollapsed): Likewise.
+ (treeNodesChanged): Likewise.
+ (treeNodesInserted): Likewise.
+ (treeNodesRemoved): Likewise.
+ (treeStructureChanged): Likewise.
+ (paintRecursive): Moved code to paintRow.
+ (paintControlIcons): Fixed to paint custom control icons properly.
+ (paintExpandControl): Removed unneeded parameter.
+ (paintRow): Added code to paint the row with the correct width.
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (installUI): Moved code to expand the root after all the listeners
+ have been initialized.
+
+2005-10-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (ItemHandler.itemStateChanged): if combo box is editable, update edit
+ text field with new selection.
+
+2005-10-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/event/ListDataListener:
+ reformatted and added API docs.
+
+2005-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JPopupMenu.java
+ (setVisible): Set size according to the size property instead of
+ the preferredSize property.
+ * javax/swing/plaf/basic/BasicComboPopup.java
+ (ListMouseHandler.mouseReleased): Set comboBox selected index before
+ closing the popup.
+
+2005-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/table/DefaultTableCellRenderer.java
+ (getTableCellRendererComponent): Setup colors (more) correctly.
+ * javax/swing/DefaultListSelectionModel.java
+ (isSelectedIndex): Check for an illegal index argument.
+
+2005-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ Filled empty blocks with comments.
+ (setVisible): Notify AncestorListeners when visibility state is
+ changed.
+ (removeNotifiy): Notify AncestorListeners via fireAncestorEvent
+ method.
+ (addNotifiy): Notify AncestorListeners via fireAncestorEvent
+ method.
+
+2005-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JViewport.java
+ (setView): Removed unnecessary loop. We only have on component.
+ (isOptimizedDrawingEnabled): Added comment explaining why this
+ method is necessary.
+
+2005-10-17 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ Filled empty blocks with comments.
+ (FocusHandler.focusLost): Close popup when the combobox loses focus.
+ * javax/swing/plaf/basic/BasicComboPopup.java
+ Filled empty blocks with comments.
+ (updateListBoxSelectionForEvent): Implemented partly.
+ (ListMouseHandler.mouseReleased): Call updateListBoxSelectionForEvent.
+ (ListMouseMotionHandler.mouseReleased): Likewise.
+
+2005-10-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * examples/gnu/classpath/examples/swing/ComboBoxDemo.java:
+ (CustomCellRenderer): new inner class,
+ (comboState6): new field,
+ (combo11): new field,
+ (combo12): new field,
+ (createContent): add panel from createPanel6(),
+ (createPanel6): new method,
+ (actionPerformed): update state for new JComboBoxes,
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (installComponents): don't create arrowButton until after listBox is
+ created, set listBox to the JList created by the popup,
+ * javax/swing/plaf/metal/MetalComboBoxButton.java:
+ (MetalComboBoxButton(JComboBox, Icon, boolean, CellRendererPane,
+ JList)): set margins to zero,
+ (paintComponent): use list cell renderer to paint button content,
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): add 'List.font' default.
+
+2005-10-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/util/Properties.java:
+ (storeToXML(OutputStream,String)): Implemented.
+ (storeToXml(OutputStream,String,String)): Likewise.
+
+2005-10-17 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Focused_ORB.java: New file.
+ * gnu/CORBA/Functional_ORB.java,
+ org/omg/CORBA/ORB.java: Adapted to support the
+ gnu.CORBA.ListenerPort property.
+
2005-10-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/awt/image/BufferedImage.java:
@@ -112,6 +2149,367 @@
(defineAttributes(String,AttributeList)): Likewise.
(newElement(String)): Likewise.
+2005-10-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/DynamicImplementation.java: Made concrete.
+ (invoke): Implemented.
+ gnu/CORBA/Simple_delegate.java (request): Implemented.
+
+2005-10-14 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (treeNodesChanged): Added call to revalidate and resize tree.
+ * javax/swing/tree/DefaultTreeModel.java
+ (insertNodeInto): Needed to set parent for new node.
+
+2005-10-14 Robert Schuster <robertschuster@fsfe.org>
+
+ * java/net/URLStreamHandler.java:
+ (toExternalForm): Use "//" + authority format when file part starts
+ with two slashes.
+
+2005-10-14 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintLock): Removed unneeded field.
+ (isCompletelyDirty): New field.
+ (setBorder): Don't get active if actual value didn't change.
+ Otherwise trigger a repaint.
+ (paint): Mark this component as clean after painting when the clip
+ covered the whole component.
+ (paintImmediately): Find more sensible paint root via new helper
+ methods.
+ (paintDoubleBuffered): Don't synchronize here.
+ (setFont): Don't get active if actual value didn't change.
+ Otherwise trigger a repaint and revalidate.
+ (setBackground): Don't get active if actual value didn't change.
+ Otherwise trigger a repaint.
+ (setForeground): Don't get active if actual value didn't change.
+ Otherwise trigger a repaint.
+ (setUI): Trigger a repaint.
+ (findPaintRoot): New helper method.
+ (findOverlapFreeParent): New helper method.
+ (findOpaqueParent): New helper method.
+ * javax/swing/RepaintManager.java
+ (ComponentComparator): New inner class. Used to sort components
+ according to their depth in the containment hierarchy.
+ (dirtyComponents): Use HashMap instead of Hashtable.
+ (workDirtyComponents): New field.
+ (repaintOrder): New field.
+ (workRepaintOrder): New field.
+ (comparator): New field.
+ (invalidComponents): Use ArrayList instead of Vector.
+ (workInvalidComponents): New field.
+ (RepaintManager): Initialize new fields.
+ (removeInvalidComponent): Adjusted for ArrayList.
+ (addDirtyRegion): Return if component in question is not showing.
+ Insert the new component in the repaintOrder list.
+ (insertRepaintOrder): New method. Maintains a sorted list of
+ components.
+ (getDirtyRegion): Return empty Rectangle instead of null when
+ component is not dirty, as specified.
+ (markCompletelyDirty): Set flag in JComponent.
+ (markCompletelyClean): Synchronize access to fields.
+ (isCompletelyDirty): Use flag in JComponent to determine this
+ property.
+ (validateInvalidComponents): Use workInvalidComponents when
+ revalidating. This avoids blocking of application threads
+ in revalidate() calls.
+ (paintDirtyRegion): Use work* fields when
+ repainting. This avoids blocking of application threads
+ in repaint() calls. Simplify actual work, now we simply call
+ paintImmediatly() on the dirty components.
+
+2005-10-14 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/LookAndFeel.java
+ (makeIcon): Implemented.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (updateCachedPreferredSize): Should only add with of control icon if
+ not a leaf.
+ (mousePressed): Fixed to use new gap field.
+ (paintRecursive): Likewise.
+ (paintRow): Likewise.
+ (updateCurrentVisiblePath): Shouldn't include root if it is
+ not of a valid size to be painted.
+
+2005-10-14 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JLayeredPane.java
+ (isOptimizedDrawingEnabled): New method.
+
+2005-10-14 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/PolicyErrorHelper.java,
+ org/omg/CORBA/PolicyErrorHolder.java,
+ org/omg/CORBA/UnknownUserExceptionHelper.java,
+ org/omg/CORBA/UnknownUserExceptionHolder.java,
+ org/omg/CORBA/WrongTransactionHelper.java,
+ org/omg/CORBA/WrongTransactionHolder.java: New files.
+
+2005-10-14 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (nextTabStop): Tab size should be multiplied by the width of 'm', not
+ added to it.
+
+2005-10-14 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (getTabSize): Check the Document's properties for
+ PlainDocument.tabSizeAttribute before defaulting to 8.
+
+2005-10-14 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/BoxView.java:
+ (preferenceChanged): New method (overrides method in View). Set flag
+ indicating that cached layout information is invalid, then call super
+ implementation.
+
+2005-10-14 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/CompositeView.java: Minor doc fixes.
+ * javax/swing/text/BoxView.java: Minor doc fixes.
+
+2005-10-14 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTree.java
+ (getAccessibleContext): Fixed API docs, and returned the correct value.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (updateCachedPreferredSize): Fixed parameter passed to isLeaf, node
+ should be passed in and not a path.
+
+2005-10-14 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/DefaultCaret.java:
+ (ALWAYS_UPDATE): New field.
+ (NEVER_UPDATE): New field.
+ (UPDATE_WHEN_ON_EDIT): New field.
+ (insertUpdate): Fixed docs. Only update the dot if the policy is
+ ALWAYS_UPDATE or if the policy is UPDATE_WHEN_ON_EDT and the event
+ was generated on the Event Dispatch thread.
+ (removeUpdate): Fixed docs. Only update the dot if the policy is
+ ALWAYS_UPDATE, if the policy is UPDATE_WHEN_ON_EDT and the event was
+ generated on the Event Dispatch thread, or if the document length
+ has become less than the current dot position.
+ (setUpdatePolicy): New method.
+ (getUpdatePolicy): New method.
+
+2005-10-14 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/BoxLayout.java
+ (layoutContainer): Perform layout inside the container's treeLock.
+ Respect the insets of the container.
+
+2005-10-14 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTree.java
+ (getAccessibleSelectionCount): Fixed API documentation.
+ (getScrollableTracksViewportWidth): Was using height instead of
+ width, fixed this.
+ (getScrollableTracksViewportHeight): Likewise.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (BasicTreeUI): Initialized validCachedPreferredSize.
+ (updateCachedPreferredSize): Implemented.
+ (pathWasExpanded): Implemented.
+ (pathWasCollapsed): Implemented.
+ (installDefaults): Fixed API documentation.
+ (uninstallDefaults): Likewise.
+ (setPreferredMinSize): Likewise.
+ (getPreferredMinSize): Likewise.
+ (getPreferredSize): Reimplemented to use updateCachedPreferredSize.
+ (startEditing): set validCachedPreferredSize.
+ (editingStopped): Likewise.
+ (editingCanceled): Likewise.
+ (treeExpanded): Likewise.
+ (treeCollaped): Likewise.
+ (treeNodesInserted): Likewise.
+ (treeNodesRemoved): Likewise.
+ (treeStructureChanged): Likewise.
+ (getNextVisibleNode): Fixed API documentation.
+ (getNextNode): Likewise.
+ (getNextSibling): Likewise.
+ (getPreviousSibling): Likewise.
+ (getLevel): Likewise.
+ (paintVerticalPartOfLeg): Likewise.
+
+2005-10-14 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/PolicyErrorCodeHelper.java: New class.
+
+2005-10-14 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/LocalObject.java (_get_interface, _invoke, _is_local,
+ _orb, _releaseReply, _request, _servant_postinvoke, _servant_preinvoke,
+ validate_connection): New methods.
+
+2005-10-14 Michael Koch <konqueror@gmx.de>
+
+ * native/jni/midi-alsa/.cvsignore,
+ native/jni/midi-dssi/.cvsignore: New files
+
+2005-10-13 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/ObjectCreator.java (forName):
+ Use gnu.classpath.VMStackWalker.
+ * gnu/CORBA/Interceptor/Registrator.java,
+ gnu/CORBA/gnuValueHolder.java,
+ gnu/CORBA/stubFinder.java,
+ gnu/javax/rmi/CORBA/DelegateFactory.java,
+ gnu/javax/rmi/CORBA/StubDelegateImpl.java,
+ org/omg/CORBA/ORB.java: Load class via ObjectCreator.
+
+2005-10-13 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (updateDamage): Made this method protected, not package-private.
+
+2005-10-13 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/BoxLayout.java
+ (xChildren): New field.
+ (yChildren): New field.
+ (xTotal): New field.
+ (yTotal): New field.
+ (offsetsX): New field.
+ (offsetsY): New field.
+ (spansX): New field.
+ (spansY): New field.
+ (preferredLayoutSize): Rewritted to use cached values if available.
+ (minimumLayoutSize): Rewritted to use cached values if available.
+ (maximumLayoutSize): Rewritted to use cached values if available.
+ (layoutContainer): Rewritted to use cached values if available.
+ (getAlignmentX): Implemented.
+ (getAlignmentY): Implemented.
+ (invalidateLayout): Clear the cache.
+ (getSizeRequirements): Removed unneeded method. Replaced by
+ checkRequirements().
+ (checkTotalRequirements): New helper method.
+ (checkRequirements): New helper method.
+ (checkLayout): New helper method.
+
+2005-10-13 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeRequirements.java
+ (calculateAlignedPositions): Determine baseline using the total
+ requirements argument.
+ (adjustFromRight): Use float instead of int for baseline argument.
+ Don't handle the <minimum case.
+ (adjustFromLeft): Likewise.
+
+2005-10-13 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java:
+ Added leafIcon field.
+ (BasicTreeUI): Initialized leafIcon field.
+ (installDefaults): Fixed icon defaults.
+ (getPreferredSize): Fixed up code slightly.
+ (startEditing): Called revalidate because size of
+ view may change.
+ (EditingStopped): Likewise.
+ (EditingCanceled): Likewise.
+ (mousePressed): Fixed up icon sizes.
+ (paintRecursive): Fixed up width painted.
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (installDefaults): Fixed icon defaults.
+
+2005-10-13 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTableHeaderUI.java:
+ (paint): Reset the clip of the Graphics object after each iteration.
+
+2005-10-13 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTableUI.java:
+ (installDefaults): Initialize rendererPane.
+ (paintCell): New method to paint an individual cell using a
+ CellRendererPane, taking borders and highlighting into account.
+ (paint): Removed direct painting code, let paintCell handle this.
+
+2005-10-13 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/ScrollPaneLayout.java
+ (preferredLayoutSize): Added some more null checks to avoid NPEs.
+ (minimumLayoutSize): Added some more null checks to avoid NPEs.
+
+2005-10-13 Jan Roehrich <jan@roehrich.info>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (installUI): Fixed setting of local JTree reference
+
+2005-10-13 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (getPreferredSize): Added check to prevent NPE.
+ (mousePressed): Likewise.
+ (paintRecursive): Likewise.
+ (paintExpandedControlIcons): Likewise.
+ (paintRow): Fixed painting location of textarea.
+
+2005-10-13 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (updateDamage): Repaint the container if a new line is added.
+
+2005-10-13 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (getPathForRow): Added check to prevent NPE.
+ (getRowCount): Likewise.
+ (getRowForPath): Likewise.
+ (getPreferredSize): Adjusted width depending on x location and
+ icon.
+ (paintRecursive): Likewise.
+ (getPreviousNode): Added check to prevent NPE.
+ (getNextVisibleNode): Likewise.
+
+2005-10-13 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/PlainView.java
+ (lineBuffer): New field used as buffer to fetch text from a
+ document.
+ (getLineBuffer): New method, provides access to the new field
+ above.
+ (modelToView): Use new lineBuffer.
+ (drawSelectedText): Likewise.
+ (drawUnselectedText): Likewise.
+ (determineMaxLineLength): Likewise.
+ (viewToModel): Likewise.
+ (updateDamage): Likewise.
+
+2005-10-13 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/JTextComponent.java
+ (replaceSelection): Removed debug statement.
+ * javax/swing/text/PlainView.java
+ (updateDamage): Removed unnecessary repaint call.
+ (damageLineRange): Trigger repaint over the whole width of the
+ text component at the requested line range. Otherwise we might
+ not clear deleted text.
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (DocumentHandler.changedUpdate): Use visibleEditorRect as
+ initial allocation.
+ (DocumentHandler.removeUpdate): Use visibleEditorRect as
+ initial allocation.
+ (DocumentHandler.insertUpdate): Use visibleEditorRect as
+ initial allocation.
+ (getVisibleEditorRect): If component width and height values are
+ invalid (==uninitialized), return a Rectangle of (0,0,0,0) instead
+ of null.
+
+2005-10-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalFileChooserUI.java
+ (DirectoryComboBoxAction): new inner class,
+ (FileRenderer): new inner class,
+ (directoryModel): new private field.
+
+2005-10-13 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): added default value for
+ 'List.focusCellHighlightBorder'.
+
2005-10-12 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/awt/datatransfer/DataFlavor.java:
@@ -183,6 +2581,699 @@
* vm/reference/java/lang/reflect/Method.java:
(getTypeParameters()): Corrected return type.
+2005-10-12 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/UIDefaults.java
+ (getUIClass): Fixed to use the system class loader if
+ the loader is null.
+
+2005-10-12 David Daney <ddaney@avtrex.com>
+
+ PR classpath/24259
+ * gnu/java/net/LineInputStream.java: Import BufferedInputStream.
+ (Constructor): Don't do blockReads on BufferedInputStreams.
+ (readLine): Rename MIN_LENGTH to MAX_LENGTH. Limit buffer size to
+ MAX_LENGTH.
+
+2005-10-12 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JTable.java: Fixed some API docs and unused imports.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintImmediately): Find the paint root more cleverly, instead of
+ going up to the root.
+ (findPaintRoot): New helper method.
+ (findOverlapFreeParent): New helper method.
+ (findOpaqueParent): New helper method.
+ * javax/swing/RepaintManager.java
+ (addDirtyRegion): Collapse overlapping dirty regions into single
+ regions.
+ (paintDirtyRegions): Simple iterator over dirty regions and
+ paint them. The optimizations are done in JComponent and
+ addDirtyRegion.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/ScrollPaneLayout.java
+ (minimumLayoutSize): Added checks to avoid NPEs.
+
+2005-10-12 David Daney <ddaney@avtrex.com>
+
+ PR classpath/24086, PR classpath/24091, PR classpath/24104
+ * gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java: Removed.
+ * gnu/java/net/protocol/http/ResponseBodyReader.java: Removed.
+ * gnu/java/net/protocol/http/event/ConnectionEvent.java: Removed.
+ * gnu/java/net/protocol/http/event/ConnectionListener.java: Removed.
+ * gnu/java/net/protocol/http/event/RequestEvent.java: Removed.
+ * gnu/java/net/protocol/http/event/RequestListener.java: Removed.
+ * gnu/java/net/protocol/http/event/package.html: Removed.
+ * gnu/java/net/protocol/http/HTTPConnection.java: Cleaned up imports.
+ (connectionListeners): Removed.
+ (requestListeners): Removed.
+ (pool): New field.
+ (Constructor): Don't initialize connectionListeners or
+ requestListeners.
+ (useCount): New field.
+ (getPoolKey): New method.
+ (setPool): New method.
+ (release): New method.
+ (newRequest): Don't call fireRequestEvent. Use StringBuilder instead
+ of StringBuffer.
+ (close): Don't call fireConnectionEvent.
+ (getURI):Use StringBuilder instead of StringBuffer.
+ (addConnectionListener): Removed.
+ (removeConnectionListener): Removed.
+ (fireConnectionEvent): Removed.
+ (addRequestListener): Removed.
+ (removeRequestListener): Removed.
+ (fireRequestEvent): Removed.
+ * gnu/java/net/protocol/http/HTTPURLConnection.java:Cleaned up imports.
+ (connectionPool): Changed type to LinkedHashMap.
+ (maxConnections): Made static.
+ (responseSink): Changed type to InputStream.
+ (errorSink): Likewise.
+ (connect): Eliminate reader. Get responseSink from response.
+ (getConnection): Rewrote.
+ (getHeaderFields): Use null as key for status line. Return
+ unmodifiable Map.
+ * gnu/java/net/protocol/http/Headers.java: Extend LinkedHashMap,
+ instead of implement Map.
+ (headers): Removed.
+ (Constructor): Do not initialize headers.
+ (size): Removed.
+ (isEmpth): Removed.
+ (containsKey): Rewrote.
+ (containsValue): Removed.
+ (get): Call super.get().
+ (getValue): Likewise.
+ (getLongValue): New method.
+ (put): Call super.put().
+ (remove): Call super.remove().
+ (putAll): Rewrote.
+ (clear): Removed.
+ (keySet): Call super.keySet().
+ (values): Removed.
+ (entrySet): Call super.entrySet().
+ (equals): Removed.
+ (hashCode): Removed.
+ (parse): Use StringBuilder instead of StringBuffer.
+ (addValue): Call super.* instead of headers.*.
+ * gnu/java/net/protocol/http/LimitedLengthInputStream.java: New class.
+ * gnu/java/net/protocol/http/Request.java: Cleaned up imports.
+ (responseBodyReader): Removed.
+ (setResponseBodyReader): Removed.
+ (dispatch): Don't create LineInputStream. Don't call fireRequestEvent.
+ Don't append CRLF to Request body. Handle unsolicited 100 Continue
+ response.
+ (readResponse): Rewrote.
+ (readResponseBody): Renamed to ...
+ (createResponseBodyStream): ... And rewritten.
+ (parseAuthParams): Use StringBuilder instead of StringBuffer.
+ (getNonceCount): Likewise.
+ (handleSetCookie): Likewise.
+ * gnu/java/net/protocol/http/Response.java: Cleaned up imports.
+ (codeClass): Removed.
+ (body): New field.
+ (Constructor): Don't initialize codeClass. Initialize body.
+ (getCodeClass): Rewrote.
+ (getLongHeader): New method.
+ (getBody): New method.
+ * gnu/java/net/protocol/http/ChunkedInputStream.java (read): Use
+ StringBuilder instead of StringBuffer.
+ * gnu/java/net/protocol/http/Cookie.java (toString): Use StringBuilder
+ instead of StringBuffer.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicFileChooserUI.java
+ (getFileView): Don't call back into the JFileChooser, avoids
+ a StackOverflow.
+ (getApproveButtonText): Likewise.
+
+2005-10-12 Mark Wielaard <mark@klomp.org>
+
+ Fixes bug #22841
+ * java/io/ObjectInputStream (validators): Removed field.
+ (isDeserializing): Removed field.
+ (currentObjectValidators): New field.
+ (ObjectInputStream): Remove validators and isDeserializing
+ initialization.
+ (readObject): Remove isDeserializing logic. Don't call
+ invokeValidators() here.
+ (parseContent): Call invokeValidators() after TC_OBJECT done.
+ (registerValidation): Create currentObjectValidators if needed.
+ (invokeValidators): Rewritten.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/CellRendererPane.java
+ (paintComponent): Fix clipping of cells.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (paint): Fix clipping of cells.
+
+2005-10-12 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/AbstractDocument.java:
+ (insertString): Don't include an ElementChange if no children were
+ added.
+ (remove): Don't include an ElementChange if no children were removed.
+
+2005-10-12 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (insertOrRemoveUpdate): Renamed this method to udpateDamage because
+ changedUpdate calls it as well.
+ (updateDamage): This method used to be named insertOrRemoveDamage.
+ Changes are: If no children were added or removed, repaint only the
+ area containing the line that was changed. Also, if children were
+ added or removed, call repaint on the entire container. Also fixed a
+ serious logic error in the bounds for Document.getText().
+ (insertUpdate): Changed call from insertOrRemoveUpdate to updateDamage
+ and removed repaint call (this is done in updateDamage).
+ (removeUpdate): Likewise.
+ (changedUpdate): Implemented.
+ (damageLineRange): Implemented.
+
+2005-10-12 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (treeExpanded): Added revalidate call.
+ (treeCollapsed): Likewise.
+ (treeNodesInserted): Likewise.
+ (treeNodesRemoved): Likewise.
+ (treeStructureChanged): Likewise.
+
+2005-10-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): added defaults for FileView.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JViewport.java
+ (sizeChanged): A new flag, indicating when the size of the
+ viewport has changed relative to the last painting operation.
+ (reshape): Set sizeChanged flag if size has changed.
+ (paintBackingStore): Only create new backingstore image when
+ the size has changed.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (reshape): Fixed calculation of newBounds and oldBounds to create
+ rectangles relative to the parent, and not to the parent's parent.
+ Solves a painting problem in an app here.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/ComponentUI.java
+ (update): Only fill the current clip. This solves a problem with
+ components in JViewport and should also optimize drawing a little.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/ScrollPaneLayout.java
+ (preferredLayoutSize): Reworked. The old impl used to actually
+ modify the layout, which is not allowed.
+ (minimumLayoutSize): Reworked. The old impl used to actually
+ modify the layout, which is not allowed.
+ (layoutContainer): Reworked. The old impl did not properly determine
+ when the scrollbars should be visible and when not.
+
+2005-10-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (FileIcon16.getIconHeight): add result of getAdditionalHeight(),
+ (FolderIcon16.getIconHeight): add result of getAdditionalHeight(),
+ (checkBoxIcon): new private field,
+ (checkBoxMenuItemIcon): likewise,
+ (fileChooserDetailViewIcon): likewise,
+ (fileChooserHomeFolderIcon): likewise,
+ (fileChooserListViewIcon): likewise,
+ (fileChooserNewFolderIcon): likewise,
+ (fileChooserUpFolderIcon): likewise,
+ (radioButtonMenuItemIcon): likewise,
+ (internalFrameDefaultMenuIcon): likewise,
+ (treeComputerIcon): likewise,
+ (treeFloppyDriveIcon): likewise,
+ (treeHardDriveIcon): likewise,
+ (getCheckBoxIcon): return single instance,
+ (getCheckBoxMenuItemIcon): likewise,
+ (getFileChooserDetailViewIcon): likewise,
+ (getFileChooserHomeFolderIcon): likewise,
+ (getFileChooserListViewIcon): likewise,
+ (getFileChooserNewFolderIcon): likewise,
+ (getFileChooserUpFolderIcon): likewise,
+ (getRadioButtonMenuItemIcon): likewise,
+ (getInternalFrameDefaultMenuIcon): likewise,
+ (getTreeComputerIcon): likewise,
+ (getTreeFloppyDriveIcon): likewise,
+ (getTreeHardDriveIcon): likewise.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Set button to be opaque.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JList.java
+ (locationToIndex): Put opening brace on next line.
+ (indexToLocation): Call UI's indexToLocation.
+ (getCellBounds): Replaced cast with getUI() call.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JFileChooser.java
+ (getDialogTitle): If no dialog title has been set, forward this
+ call to the UI.
+ (getApproveButtonText): If no text has been set, forward this
+ call to the UI.
+ (getFileView): If no file view has been set, forward this call
+ to the UI.
+ (getInternalFileView): Removed unneeded method.
+ (getName): Call getFileView instead of getInternalFileView.
+ (getDescription): Call getFileView instead of getInternalFileView.
+ (getTypeDescription): Call getFileView instead of
+ getInternalFileView.
+ (getIcon): Call getFileView instead of getInternalFileView.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (setFont): Only get active if the new font differs from the old one.
+ Call revalidate when font changes.
+ (setUI): Call revalidate when UI changes.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComboBox.java
+ (isFocusTraversable): Removed unneeded and unspecified method.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JViewport.java
+ (ViewListener.componentResized): Only call revalidate instead of
+ going through weird reverting code.
+ (JViewport): First call updateUI, then set layout.
+ (setViewPosition): Don't do anything if there is no real
+ change.
+ (setView): Don't remove the old component. This is handled by
+ addImpl. Call revalidate().
+ * javax/swing/ViewportLayout.java
+ (layoutContainer): Preferably set view size to it's preferredSize
+ instead of its minimumSize.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/JTextComponent.java
+ (getToolTipText): New method.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): Fixed value for
+ Table.focusCellHighlightBorder.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+ (installDefaults): Use UIManager.get* methods instead of
+ UIManager.getDefaults().get* methods.
+ * javax/swing/plaf/basic/BasicColorChooserUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicDesktopPaneUI.java
+ (installDefaults): Only install background color, if installed
+ color is null or an UIResource instance.
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicLabelUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicListUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Added default for List.font.
+ * javax/swing/plaf/basic/BasicMenuBarUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicMenuUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicPanelUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicPopupMenuUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicProgressBarUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicSeparatorUI.java
+ (installDefaults): Use UIManager.get* methods instead of
+ UIManager.getDefaults().get* methods.
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicSpinnerUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicTableHeaderUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
+ (installDefaults): Use UIManager.get* methods instead of
+ UIManager.getDefaults().get* methods.
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicToolTipUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (installDefaults): Use new LookAndFeel install* methods. Use
+ UIManager.get* methods instead of UIManager.getDefaults().get*
+ methods.
+ * javax/swing/plaf/basic/BasicViewportUI.java
+ (installDefaults): Use new LookAndFeel install* methods.
+
+2005-10-12 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/LookAndFeel.java
+ (installBorder): Implemented.
+ (installColors): Implemented.
+ (installColorsAndFont): Implemented.
+
+2005-10-12 Mark Wielaard <mark@klomp.org>
+
+ Reported by Christian Thalinger <twisti@complang.tuwien.ac.at>
+ * native/jni/java-lang/java_lang_VMProcess.c
+ (Java_java_lang_VMProcess_nativeSpawn): Don't delete clazz local
+ reference twice.
+
+2005-10-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/event/SwingPropertyChangeSupport.java
+ (firePropertyChange(PropertyChangeEvent)): if old and new values are
+ both null, listeners should be notified.
+
+2005-10-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultComboBoxModel.java
+ (setSelectedItem): allow values not in list, and don't fire an event
+ if the value is unchanged.
+
+2005-10-11 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/GapContent.java:
+ (getPositionsInRange): Corrected interval check. This mirrors Roman's
+ change in GapContent from 2005-10-05 for adjustPositionsInRange and
+ setPositionsInRange.
+
+2005-10-11 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTextUI.java:
+ (viewToModel): Implemented.
+ * javax/swing/text/DefaultCaret.java:
+ (mousePressed): Implemented.
+ * javax/swing/text/PlainView.java:
+ (viewToModel): Implemented.
+
+2005-10-11 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (insertUpdate): Repaint the JTextComponent after the update.
+ (removeUpdate): Likewise.
+
+2005-10-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JFileChooser.java: Added API docs all over.
+
+2005-10-11 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JEditorPane.java
+ (AccessibleJEditorPaneHTML): New inner class.
+ (JEditorPaneAccessibleHypertextSupport): New inner class.
+ (getAccessibleContext): Handle special case when we have
+ a HTMLEditorKit.
+ (setEditorKit): Reset the accessibleContext.
+
+2005-10-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/filechooser/FileSystemView.java
+ (defaultFileSystemView): new private field,
+ (getFileSystemView): initialise (if necessary) and return
+ defaultFileSystemView.
+
+2005-10-11 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
+ (main): Message removed from the loop.
+
+2005-10-10 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
+ (main): 3 sec pause replaced by while(..) loop.
+
+2005-10-10 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Interceptor/Registrator.java,
+ gnu/CORBA/ObjectCreator.java,
+ gnu/CORBA/gnuValueHolder.java,
+ gnu/CORBA/stubFinder.java,
+ gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java,
+ gnu/javax/rmi/CORBA/StubDelegateImpl.java,
+ gnu/javax/rmi/CORBA/UtilDelegateImpl.java,
+ org/omg/CORBA/ORB.java: Use context class loader.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/View.java
+ (modelToView(pos, Shape)): New method.
+ (viewToModel(float, float, Shape)): New method.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JEditorPane.java
+ (AccessibleJEditorPane): New inner class.
+ (getAccessibleContext): Implemented to return an instance of
+ AccessibleJEditorPane.
+ * javax/swing/JScrollPane.java
+ (AccessibleJScrollPane): New inner class.
+ (getAccessibleContext): Implemented to return an instance of
+ AccessibleJScrollPane.
+ (setViewport): Call accessibleContext's resetViewPort() method.
+ * javax/swing/JTextArea.java
+ (AccessibleJTextArea): New inner class.
+ (getAccessibleContext): Implemented to return an instance of
+ AccessibleJTextArea.
+ * javax/swing/JTextField.java
+ (AccessibleJTextField): New inner class.
+ (getAccessibleContext): Implemented to return an instance of
+ AccessibleJTextField.
+ * javax/swing/JRootPane.java
+ (defaultPressAction): New field.
+ (defaultReleaseAction): New field.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JMenuBar.java
+ (AccessibleJMenuBar): New inner class.
+ (getAccessibleContext): Implemented to return an instance of
+ AccessibleJMenuBar.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintChildren): Skip children if their clip _doesn't_ hit the
+ current clip.
+ (setVisible): Do nothing if the actual value didn't change.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Graphics.java
+ (hitClip): Implemented this method.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Graphics.java: Reformatted file.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * java/beans/IndexedPropertyDescriptor.java
+ (setIndexedReadMethod): Changed signature to throw
+ IntrospectionException as specified.
+ (setIndexedWriteMethod): Changed signature to throw
+ IntrospectionException as specified.
+
+2005-10-10 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (rectCache): New field. Caches Rectangle objects for reuse.
+ (paintChildren): Changed to reuse cached Rectangle object.
+
+2005-10-10 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/border/TitledBorder.java
+ (TitledBorder(String)): Changed default justification and position,
+ (TitledBorder(Border)): Likewise,
+ (TitledBorder(Border, String)): Likewise,
+ (BorderPainter.paint(Graphics)): Use full width and height,
+ (BorderPainter.paintExcept): Fixed bounds for region 3,
+ (paintBorder): indented left justified title further, adjusted
+ ABOVE_TOP text position, adjusted bounds for call to paintExcept(),
+ updated for renamed fields in Measurements class,
+ (getMeasurements): added special handling for null text, increased
+ outer spacing, adjusted spacing for TOP, BOTTOM and BELOW_BOTTOM title
+ positions,
+ (Measurements.borderSpacing): renamed outerSpacing,
+ (Measurements.edgeSpacing): renamed innerSpacing,
+ (Measurements.getContentInsets): updated for renamed fields,
+ (Measurements.getMinimumSize): wrap at 80 columns.
+
+2005-10-09 Mark Wielaard <mark@klomp.org>
+
+ Fixes bug #24006
+ * java/net/Socket.java (bound): Make package private.
+ * java/net/ServerSocket.java (implAccept): Set Socket.bound to true.
+
+2005-10-07 Anthony Green <green@redhat.com>
+
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+ (process): call run_multiple_synths if required.
+
+2005-10-07 Anthony Green <green@redhat.com>
+
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_open_1): Attempt
+ to connect to the jack server automatically. Fail gracefully.
+
+2005-10-07 Anthony Green <green@redhat.com>
+
+ * gnu/javax/sound/midi/dssi/DSSISynthesizer.java (loadInstrument):
+ Implement.
+ (selectProgram_): New native method.
+ * include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h: Rebuilt.
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+ (selectProgram_): New function.
+
+2005-10-07 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkChoicePeer.java (postChoiceItemEvent):
+ Don't call select on the AWT Choice component.
+ * java/awt/Choice.java (processItemEvent): Set the selected index
+ without calling into the peers.
+
+2005-10-07 Anthony Green <green@redhat.com>
+
+ * gnu/javax/sound/midi/dssi/DSSISynthesizer.java
+ Doc cleanups.
+ (DSSISynthesizer.DSSISoundbank): New class.
+ (DSSISynthesizer.DSSIInstrument): New class.
+ (soundbanks, defaultSoundbank): New fields.
+ (getDefaultSoundbank): Implemented.
+ (getAvailableInstruments): Implemented.
+ (getProgramName_, getProgramBank_, getProgramProgram_): New native
+ methods.
+ (DSSISynthesizer): Create default soundbank.
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramName_1,
+ Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramBank_1,
+ Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramProgram_1):
+ New functions.
+ * include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h: Rebuilt.
+
+2005-10-07 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (tableChanged): Revalidate table if its structure changes.
+
+2005-10-07 Jan Roehrich <jan@roehrich.info>
+
+ * javax/swing/JTree.java: (JTree):
+ * javax/swing/plaf/basic/BasicTreeUI.java: (updateRenderer):
+ moved setting of TreeCellRenderer from JTree to BasicTreeUI.
+
+2005-10-07 Roman Kennke <kennke@aicas.com>
+
+ * java/beans/IndexedPropertyDescriptor.java
+ (setIndexedReadMethod): New method.
+ (setIndexedWriteMethod): New method.
+
+2005-10-07 Roman Kennke <kennke@aicas.com>
+
+ * java/beans/IndexedPropertyDescriptor.java: Reformatted.
+
+2005-10-07 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonUI.java
+ (currentIcon): Fix icon for disabled selected buttons.
+ (paint): Only paint focus indicator if button is actually
+ focusPainted.
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (installDefaults): Install icons for disabledIcon and
+ disabledSelectedIcon.
+ (paint): Paint the correct icon. Only paint focus indicator
+ if button is actually focusPainted.
+ * javax/swing/plaf/basic/BasicToggleButtonUI.java
+ (paint): Only paint focus indicator if button is actually
+ focusPainted.
+
+2005-10-07 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paint): Call paintBorder before paintChildren.
+ (reshape): Fire AncestorEvent if position has changed.
+ (fireAncestorMoved): New method. Fires AncestorEvents to this
+ component and all of it's children.
+
+2005-10-07 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/BorderFactory.java
+ (createLineBorder(Color)): Forward call to
+ createLineBorder(Color, int) with thickness of 1.
+
2005-10-06 Tom Tromey <tromey@redhat.com>
* java/util/ListResourceBundle.java (getKeys): Fixed return type.
@@ -204,6 +3295,155 @@
(headSet): Fixed return type.
* java/util/StringTokenizer.java: Implements Enumeration<Object>.
+2005-10-06 Anthony Green <green@redhat.com>
+
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_open_1): Ignore
+ controllers that aren't mapped to MIDI controls.
+
+2005-10-06 Anthony Green <green@redhat.com>
+
+ * INSTALL: Describe midi provider dependencies.
+
+ * native/jni/midi-dssi/README: New file.
+ * LICENSE (terms): Add notice about code copied from the DSSI
+ distribution.
+
+ * examples/gnu/classpath/examples/midi/Demo.java: New file.
+
+ * native/jni/midi-dssi/dssi_data.h (dssi_data): Add control_count,
+ control_port_map, control_value_map, sample_rate, and
+ control_values fields.
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+ (DEBUG_DSSI_PROVIDER): New macro.
+ (get_port_default): New function.
+ (set_control): New function.
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_open_1): Remove
+ debug output. Reformat. Allocate the control ports and assign
+ proper default values.
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOn_1): Use
+ JLONG_TO_PTR.
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOff_1): Ditto.
+ * gnu/javax/sound/midi/dssi/DSSISynthesizer.java
+ (Channel.controlChange): Implement.
+ (controlChange_): New native method.
+ * include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h: Rebuilt.
+
+ * gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java: Make
+ instance final.
+
+2005-10-06 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (determineMaxLength): Avoid NPE by checking the Segment that getText
+ returns. No need to return Math.max (0, maxLineLength) because
+ maxLineLength is guaranteed to be 0 or greater.
+
+2005-10-06 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (determineMaxLength): If maxLineLength is -1 we should return 0.
+ (insertOrRemoveUpdate): Avoid NPE by checking the Segment that
+ getText returns.
+
+2005-10-06 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/metadata/IIOMetadata.java: Complete.
+
+2005-10-06 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/BoxView.java
+ (paint): Only call paintChild if child allocation is not empty.
+ (layout): Don't store the width and height fields here.
+ (setSize): Store the width and height fields here.
+ * javax/swing/text/CompositeView.java
+ (getViewIndexAtPosition): Reworked child view searching.
+ (getInsideAllocation): Fixed insets calculation.
+ * javax/swing/text/FlowView.java
+ (FlowStrategy.layoutRow): Return an offset of -1 if no more child
+ views are in the logical view.
+ (FlowStrategy.createView): If there are no more child views,
+ then return null.
+ (LogicalView.getViewIndex): New method. Implements child view
+ searching for the LogicalView.
+ * javax/swing/text/GlyphView.java
+ (DefaultGlyphPainter.getHeight): Use Toolkit FontMetrics instead
+ of parent containers FontMetrics.
+ (DefaultGlyphPainter.getSpan): Use Toolkit FontMetrics instead
+ of parent containers FontMetrics.
+ * javax/swing/text/Utilities.java
+ (getTabbedTextOffset): Check for 0 in the char array and stop
+ there.
+ * javax/swing/text/View.java
+ (getContainer): If there's no parent, don't throw an Error, instead
+ return null as specified.
+
+2005-10-06 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/AbstractDocument.java: Implemeted locking.
+ (insertString): Obtain write lock before altering document.
+ (readLock): Implemented.
+ (readUnlock): Implemented.
+ (remove): Obtain write lock before altering document.
+ (render): Implemented.
+ (writeLock): Implemented.
+ (writeUnlock): Implemented.
+ (getCurrentWriter): Implemented.
+
+2005-10-06 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JLabel.java
+ (JLabel): Set alignmentX value to 0.0F.
+
+2005-10-06 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (startEditing): Should always change the bounds, whenever
+ we start editing.
+ (paintRow): Fixed location where editing component should
+ be drawn. The constant takes care of the space around the
+ icon.
+ * javax/swing/JTree.java
+ (JTree): Called updateUI first so currentVisiblePath is
+ cached right away. Prevents NPEs.
+
+2005-10-06 Tom Tromey <tromey@redhat.com>
+
+ * javax/print/attribute/SetOfIntegerSyntax.java (toString): Wrote.
+ (hashCode): Likewise.
+ (equals): Likewise.
+ (getMembers): Likewise.
+ (contains): Fixed boundary condition check.
+ (next): Wrote.
+ (normalize): Rewrote.
+ (SetOfIntegerSyntax): Updated.
+ (SetOfIntegerSyntax(String)): New constructor.
+ (skipNumber): New method.
+ (skipWhitespace): Likewise.
+
+2005-10-06 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicRootPaneUI.java
+ (installUI): Call new hook methods.
+ (installDefaults): New hook method.
+ (installComponents): New hook method.
+ (installListeners): New hook method.
+ (installKeyboardActions): New hook method.
+ (uninstallUI): New method.
+ (uninstallDefaults): New hook method.
+ (uninstallComponents): New hook method.
+ (uninstallListeners): New hook method.
+ (uninstallKeyboardActions): New hook method.
+
+2005-10-06 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (mousePressed): Shouldn't change x location for leaf.
+
+2005-10-06 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * configure.ac: Add Qt4 configury bits for OS-X.
+
2005-10-05 Tom Tromey <tromey@redhat.com>
* java/util/jar/Attributes.java: Implements Map<Object,Object>.
@@ -291,6 +3531,240 @@
* java/awt/Button.java (getListeners): Genericized.
* java/awt/Container.java (getListeners): Genericized.
+2005-10-05 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (paintRow): Fixed indentation.
+ (updateCurrentVisiblePath): Added FIXME
+ comment.
+
+2005-10-05 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/BoxView.java
+ (baselineLayout): New method.
+ (calculateMajorAxisRequirements): Reimplemented to use the
+ SizeRequirements utility methods.
+ (calculateMinorAxisRequirements): Reimplemented to use the
+ SizeRequirements utility methods.
+ (layout): Use the new baselineLayout method.
+ (layoutMajorAxis): Reimplemented to use the new
+ getChildRequirements method.
+ (layoutMinorAxis): Reimplemented to use the new
+ getChildRequirements method.
+ (getChildRequirements): New method.
+ (getSpan): New method.
+ (getOffset): New method.
+ (getAlignment): New method.
+ * javax/swing/text/ParagraphView.java
+ (Row.getAlignment): New method.
+ (getAlignment): New method.
+ * javax/swing/text/View.java
+ (getContainer): Improved error message in assertion a little.
+
+2005-10-05 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (installUI): Fixed to call toggleExpandState instead.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (getPathForRow): Used currentVisiblePath to get Path.
+ (getRowForPath): Used currentVisiblePath to get row.
+ (getRowCount): Returned currentVisiblePath length.
+ (updateLayoutCacheExpandedNodes): Took out unneeded code.
+ (installUI): Fixed to call toggleExpandState instead.
+ (getPreferredSize): Made more efficent by using currentVisiblePath.
+ (toggleExpandState): Called updateCurrentVisiblePath.
+ (getCellLocation): Made more efficent.
+ (paintNode): Removed.
+ (paintRecursive): Made more efficent, changed paintNode calls to
+ paintRow.
+ (getNextVisibleNode): Reimplemented to use currentVisiblePath.
+ (getPreviousVisibleNode): Likewise.
+ (paintRow): Implemented.
+ (updateCurrentVisiblePath): New helper used to cache the current
+ visible path.
+
+2005-10-05 Mark Wielaard <mark@klomp.org>
+
+ Reported by Nicolas Geoffray <nicolas.geoffray@lip6.fr>
+ * java/security/AccessController.java
+ (doPrivileged(PrivilegedExceptionAction)): If the Exception is a
+ Runtime exception, then throw the exception directly, otherwise
+ wrap it.
+ (doPrivileged(PrivilegedExceptionAction,AccessControlContext)):
+ Likewise.
+
+2005-10-05 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/GapContent.java
+ (setPositionsInRange): Changed check for interval end to actually
+ check for the position offsets.
+ (adjustPositionsInRange): Changed check for interval end to actually
+ check for the position offsets.
+ (dump): New method for debugging.
+ (dumpPositions): New method for debugging.
+
+2005-10-05 Christian Thalinger <twisti@complang.tuwien.ac.at>
+
+ * m4/acattribute.m4: Added.
+ * configure.ac: Added AC_C_ATTRIBUTE.
+ * native/fdlibm/java-assert.h: Added missing config.h include,
+ changed comments to C comments.
+ * native/jni/java-lang/java_lang_reflect_Array.c: Added missing
+ config.h include.
+
+2005-10-05 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (insertOrRemoveUpdate): New method.
+ (insertUpdate): New method.
+ (removeUpdate): New method.
+
+2005-10-05 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/JOptionPane.java
+ (showInputDialog(Component,Object,String,int,Icon,Object[],Object)):
+ Don't cast return value.
+ (internalShowInputDialog(Component,Object,String,int,Icon,Object[],
+ Object)): Likewise.
+
+2005-10-05 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/EmptyExceptionHolder.java,
+ gnu/CORBA/ForwardRequestHelper.java,
+ gnu/CORBA/Functional_ORB.java,
+ gnu/CORBA/Poa/gnuServantObject.java,
+ gnu/CORBA/_PolicyImplBase.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/universalHolder.java,
+ org/omg/CORBA/CompletionStatus.java,
+ org/omg/CORBA/NameValuePairHelper.java,
+ org/omg/CORBA/ObjectHelper.java,
+ org/omg/CORBA/PolicyHelper.java,
+ org/omg/CORBA/PolicyListHelper.java,
+ org/omg/CORBA/ServiceDetailHelper.java,
+ org/omg/CORBA/StringValueHelper.java,
+ org/omg/CORBA/WStringValueHelper.java,
+ org/omg/CosNaming/BindingHelper.java,
+ org/omg/CosNaming/BindingIteratorHelper.java,
+ org/omg/CosNaming/BindingIteratorPOA.java,
+ org/omg/CosNaming/BindingTypeHelper.java,
+ org/omg/CosNaming/NameComponentHelper.java,
+ org/omg/CosNaming/NameHelper.java,
+ org/omg/CosNaming/NamingContextExtHelper.java,
+ org/omg/CosNaming/NamingContextExtPOA.java,
+ org/omg/CosNaming/NamingContextHelper.java,
+ org/omg/CosNaming/NamingContextPOA.java,
+ org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java,
+ org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java,
+ org/omg/CosNaming/_BindingIteratorImplBase.java,
+ org/omg/CosNaming/_NamingContextImplBase.java,
+ org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java,
+ org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java,
+ org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java,
+ org/omg/DynamicAny/DynAnySeqHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairSeqHelper.java,
+ org/omg/DynamicAny/NameValuePairHelper.java,
+ org/omg/DynamicAny/NameValuePairSeqHelper.java,
+ org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java,
+ org/omg/IOP/CodecPackage/FormatMismatchHelper.java,
+ org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java,
+ org/omg/IOP/CodecPackage/TypeMismatchHelper.java,
+ org/omg/IOP/IORHelper.java,
+ org/omg/IOP/MultipleComponentProfileHelper.java,
+ org/omg/IOP/ServiceContextHelper.java,
+ org/omg/IOP/ServiceContextListHelper.java,
+ org/omg/IOP/TaggedComponentHelper.java,
+ org/omg/IOP/TaggedProfileHelper.java,
+ org/omg/PortableInterceptor/ForwardRequestHelper.java,
+ org/omg/PortableInterceptor/InvalidSlotHelper.java,
+ org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java,
+ org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java,
+ org/omg/PortableServer/CurrentPackage/NoContextHelper.java,
+ org/omg/PortableServer/ForwardRequestHelper.java,
+ org/omg/PortableServer/IdAssignmentPolicyValue.java,
+ org/omg/PortableServer/IdUniquenessPolicyValue.java,
+ org/omg/PortableServer/ImplicitActivationPolicyValue.java,
+ org/omg/PortableServer/LifespanPolicyValue.java,
+ org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java,
+ org/omg/PortableServer/POAManagerPackage/State.java,
+ org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java,
+ org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java,
+ org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java,
+ org/omg/PortableServer/POAPackage/NoServantHelper.java,
+ org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java,
+ org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java,
+ org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java,
+ org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java,
+ org/omg/PortableServer/POAPackage/WrongAdapterHelper.java,
+ org/omg/PortableServer/POAPackage/WrongPolicyHelper.java,
+ org/omg/PortableServer/RequestProcessingPolicyValue.java,
+ org/omg/PortableServer/Servant.java,
+ org/omg/PortableServer/ServantLocatorHelper.java,
+ org/omg/PortableServer/ServantRetentionPolicyValue.java,
+ org/omg/PortableServer/ThreadPolicyValue.java: Added minor codes for BAD_PARAM and NO_RESOURCES.
+ * gnu/CORBA/Minor.java: Introduces new minor codes.
+ * org/omg/CORBA/BAD_OPERATION.java,
+ org/omg/CORBA/MARSHAL.java,
+ org/omg/CORBA/NO_RESOURCES.java: Documentation update.
+
+2005-10-05 Stuart Ballard <stuart.a.ballard@gmail.com>
+
+ * java/rmi/LoaderHandler.java (packagePrefix): Match Sun's value.
+ * java/rmi/RemoteRef.java (packagePrefix): Likewise.
+ * java/rmi/RemoteObject.java (readObject): Hardcode the GNU package
+ prefix.
+
+2005-10-05 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/AbstractDocument.java:
+ (remove): If removing content returns an UndoableEdit, then add an
+ ElementEdit to the DocumentEvent before firing.
+ * javax/swing/text/GapContent.java:
+ (UndoRemove): New class to implement UndoableEdit for remove operation.
+ (remove): Return an UndoableEdit instead of null.
+
+2005-10-05 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/LabelView.java
+ (LabelView): Implemented the constructor.
+ (setPropertiesFromAttributes): New method.
+ (changedUpdate): New method.
+ (getBackground): New method.
+ (setBackground): New method.
+ (getForeground): New method.
+ (getFont): New method.
+ (getFontMetrics): New method.
+ (isUnderline): New method.
+ (setUnderline): New method.
+ (isSubscript): New method.
+ (setSubscript): New method.
+ (isSuperscript): New method.
+ (setSuperscript): New method.
+ (isStrikeThrough): New method.
+ (setStrikeThrough): New method.
+
+2005-10-05 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/table/JTableHeader.java
+ (accessibleContext): Removed unneeded field. The protected
+ field with the same name should be used instead.
+ (JTableHeader): Moved field initialization to new method
+ initializeLocalVars().
+ (setColumnModel): Add and remove this to the old and new model.
+ (columnAdded): New listener method.
+ (columnMarginChanged): New listener method.
+ (columnMoved): New listener method.
+ (columnRemoved): New listener method.
+ (columnSelectionChanged): New listener method.
+ (resizeAndRepaint): New method.
+ (initializeLocalVars): New method.
+
2005-10-04 Tom Tromey <tromey@redhat.com>
* java/awt/Dialog.java (show): Now deprecated.
@@ -301,6 +3775,539 @@
* java/lang/ref/Reference.java (nextOnQueue): Changed type.
* java/lang/ref/ReferenceQueue.java (first): Changed type.
+2005-10-04 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicFileChooserUI.java: Added API docs all
+ over.
+
+2005-10-04 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/AbstractDocument.java:
+ (insertString): If inserting a string into the Content returns an
+ UndoableEdit, then add an ElementEdit to the DocumentEvent before
+ firing.
+ (remove): Don't fire a removeUpdate unless some content was actually
+ removed.
+ * javax/swing/text/GapContent.java:
+ (UndoInsertString): New class to implement UndoableEdit functions.
+ (insertString): Return an UndoableEdit instead of null. Also use
+ locally calculated length of String rather than calculating again.
+ * javax/swing/text/JTextComponent.java:
+ (setText): If the Document is an AbstractDocument this should pass
+ through AbstractDocument.replace rather than calling remove and insert.
+ * javax/swing/text/PlainView.java:
+ (determineMaxLength): Keep track of which line was the longest as well
+ as the length of it. We'll need this to know when the longest line is
+ removed and we need to redetermine the longest line.
+
+2005-10-04 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/ImageWriter.java
+ (processWarningOccurred(int,String,String)): New method.
+ * javax/imageio/ImageReader.java
+ (processWarningOccurred(String,String)): New method.
+
+2005-10-04 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/ImageReader.java (getDestination): Throw
+ IIOException, not IOException.
+ * javax/imageio/ImageTypeSpecifier.java
+ (createGrayscale(int,int,boolean)): Rename from createGrayScale.
+ (createGrayscale(int,int,boolean,boolean)): Likewise.
+ (createIndexed): Rename from createIndex.
+
+2005-10-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * doc/www.gnu.org/corba.wml:
+ Link to http://doc.omg.org/vendor-tags.
+
+2005-10-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Minor.java: New file.
+ * gnu/CORBA/CDR/IDLTypeHelper.java,
+ gnu/CORBA/CDR/UnknownExceptionCtxHandler.java,
+ gnu/CORBA/CDR/Vio.java,
+ gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/CDR/gnuRuntime.java,
+ gnu/CORBA/CDR/noHeaderInput.java,
+ gnu/CORBA/DynAn/gnuDynValue.java,
+ gnu/CORBA/GIOP/CloseMessage.java,
+ gnu/CORBA/GIOP/ErrorMessage.java,
+ gnu/CORBA/GIOP/MessageHeader.java,
+ gnu/CORBA/GIOP/v1_2/RequestHeader.java,
+ gnu/CORBA/IOR.java,
+ gnu/CORBA/Poa/ForwardedServant.java,
+ gnu/CORBA/Version.java,
+ gnu/CORBA/cdrEncapsCodec.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/gnuRequest.java,
+ gnu/CORBA/streamReadyHolder.java,
+ gnu/CORBA/universalHolder.java,
+ gnu/javax/rmi/CORBA/UtilDelegateImpl.java,
+ gnu/javax/rmi/CORBA/corbaObjectOutput.java,
+ gnu/javax/rmi/CORBA/gnuRmiUtil.java,
+ org/omg/CORBA/StringValueHelper.java,
+ org/omg/CORBA/StructMemberHelper.java,
+ org/omg/CORBA/UnionMemberHelper.java,
+ org/omg/CORBA/ValueMemberHelper.java,
+ org/omg/CORBA/WStringValueHelper.java,
+ org/omg/CORBA/_IDLTypeStub.java,
+ org/omg/DynamicAny/DynAnyFactoryHelper.java,
+ org/omg/DynamicAny/_DynAnyFactoryStub.java,
+ org/omg/IOP/TaggedComponentHelper.java,
+ org/omg/IOP/TaggedProfileHelper.java,
+ org/omg/PortableInterceptor/CurrentHelper.java,
+ org/omg/PortableServer/POAHelper.java,
+ org/omg/PortableServer/ServantActivatorHelper.java,
+ org/omg/PortableServer/ServantLocatorHelper.java:
+ Initialising minor codes for MARSHAL.
+ * org/omg/CORBA/SystemException.java: Documentation update and
+ add minor code to the exception message.
+ * org/omg/CORBA/MARSHAL.java: Documentation update.
+
+2005-10-04 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/plaf/metal/MetalBorders.java (paintBorder): Check
+ whether Component is JTextComponent.
+
+2005-10-04 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * javax/imageio/ImageWriter.java (availableLocales, locale,
+ originatingProvider, output, progressListeners, warningListeners,
+ warningLocales): Initialize.
+ (addIIOWriteProgressListener): Check progressListeners against null
+ to avoid NPE. Create new ArrayList if progressListeners is null.
+ (addIIOWriteWarningListener): Likewise for warningListeners.
+ (processImageComplete): Check progressListeners against null to
+ avoid NPE.
+ (processImageProgress): Likewise.
+ (processImageStarted): Likewise.
+ (processThumbnailComplete): Likewise.
+ (processThumbnailProgress): Likewise.
+ (processThumbnailStarted): Likewise.
+ (processWarningOccurred): Likewise for warningListeners.
+ (processWriteAborted): Likewise for progressListeners.
+ (removeAllIIOWriteProgressListeners): Likewise.
+ (removeAllIIOWriteWarningListeners): Likewise.
+ (removeIIOWriteProgressListener): Likewise.
+ (removeIIOWriteWarningListener): Likewise for warningListeners.
+
+ * javax/imageio/ImageReader.java (addIIOReadProgressListener): Check
+ progressListeners against null to avoid NPE. Create new ArrayList
+ if progressListeners is null.
+ (addIIOReadUpdateListener): Likewise for updateListeners.
+ (addIIOReadWarningListener): Likewise for warningListeners.
+ (processImageComplete): Check progressListeners against null to
+ avoid NPE.
+ (processImageProgress): Likewise.
+ (processImageStarted): Likewise.
+ (processImageUpdate): Likewise for updateListeners.
+ (processPassComplete): Likewise.
+ (processPassStarted): Likewise.
+ (processReadAborted): Likewise for progressListeners.
+ (processSequenceComplete): Likewise.
+ (processSequenceStarted): Likewise.
+ (processThumbnailComplete): Likewise.
+ (processThumbnailPassComplete): Likewise for updateListeners.
+ (processThumbnailPassStarted): Likewise.
+ (processThumbnailProgress): Likewise for progressListeners.
+ (processThumbnailStarted): Likewise.
+ (processThumbnailUpdate): Likewise for updateListeners.
+ (processWarningOccurred): Likewise for warningListeners.
+ (removeIIOReadProgressListener): Likewise for progressListeners.
+ (removeIIOReadUpdateListener): Likewise for updateListeners.
+ (removeIIOReadWarningListener): Likewise for warningListeners.
+
+2005-10-04 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/metal/MetalToolTipUI.java
+ (paint): Added space around the toolTip's accelerator.
+ (fetchAcceleratorString): Added code to get mnemonic for
+ JMenuItem if it does not have an accelerator.
+
+2005-10-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/DefaultCaret.java
+ (repaint): Adjust repaint rectangle.
+ (setVisible): Only repaint if the visible property actually changed.
+
+2005-10-04 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/JTextComponent.java: Reformatted file.
+
+2005-10-04 Roman Kennke <kennke@aicas.com>
+
+ Fixes Bug #24080
+ * javax/swing/SizeRequirements.java
+ (adjustGreater): Added check to prevent overflow.
+
+2005-10-04 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicToolTipUI.java
+ (accText): removed,
+ (accDeliminator): removed,
+ (accFont): removed,
+ (accFore): removed,
+ (getPreferredSize): removed accelerator code (now in MetalToolTipUI),
+ (getAcceleratorText): removed (equivalent is now in MetalToolTipUI),
+ (paint): removed accelerator painting,
+ * javax/swing/plaf/metal/MetalToolTipUI.java
+ (padSpaceBetweenStrings): new field,
+ (MetalToolTipUI): initialise defaults,
+ (getAcceleratorString): new method,
+ (installUI): new method,
+ (uninstallUI): new method,
+ (isAcceleratorHidden): new method,
+ (getPreferredSize): new method,
+ (paint): new method,
+ (fetchAcceleratorString): new private method,
+ (acceleratorToString): new private method,
+ * examples/gnu/classpath/examples/swing/Demo.java
+ (mkButton): set tool tip.
+
+2005-10-04 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (getFont): Fall back to peer.getGraphics().getFont() if no font
+ is found.
+ (getGraphics): Set font here. This avoids a loop in the above
+ fallback.
+ * gnu/java/awt/peer/gtk/GdkGraphics.java
+ (GdkGraphics): Don't initialize font here. This would cause a
+ loop in the above fallback.
+
+2005-10-04 Anthony Green <green@redhat.com>
+
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+ (process): Add comments. Remove unused gettimeofday call.
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_open_1): Remove
+ debug output. Add comments.
+ (Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOn_1,
+ Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOff_1): Add
+ comments. Remove bogus __attribute__((unused)).
+ * native/jni/midi-dssi/dssi_data.h (JLONG_TO_PTR, PTR_TO_JLONG):
+ Document helper macros.
+ (dssi_data): Document.
+ * native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c:
+ Formatting fixes.
+ * native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c
+ (Java_gnu_javax_sound_midi_alsa_AlsaPortDevice_run_1receiver_1thread_1):
+ Remove debugging output.
+
+2005-10-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Set text to "" here.
+
+2005-10-04 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java (clearRect): Check bg
+ against null to avoid NPE.
+
+2005-10-03 Tom Tromey <tromey@redhat.com>
+
+ * gnu/java/awt/peer/qt/QtToolkit.java (initToolkit): Use Configuration
+ to see if library should be loaded.
+
+2005-10-03 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainView.java:
+ (maxLineLength): New variable to cache the length of the longest line.
+ (determineMaxLength): New implementation method.
+ (getPreferredSpan): Call determine max length instead of calculating
+ it here.
+
+2005-10-03 Tom Tromey <tromey@redhat.com>
+
+ * java/awt/image/ComponentSampleModel.java (numBands): Updated
+ javadoc.
+ (ComponentSampleModel): Set numBands.
+ * java/awt/image/SampleModel.java (numBands): Now protected.
+
+2005-10-03 Tom Tromey <tromey@redhat.com>
+
+ * java/awt/Polygon.java (evaluateCrossings): Removed @see.
+ * java/awt/image/ImageConsumer.java (SINGLEPASS): Javadoc fix.
+ * java/awt/Image.java (getGraphics): Removed @see.
+ * java/awt/MenuComponent.java (setEnabled): Javadoc fix.
+ (setBackground): Likewise.
+ * java/awt/event/MouseEvent.java: Added import for javadoc.
+ * java/awt/im/spi/InputMethodDescriptor.java: Added import for javadoc.
+ (getAvailableLocales): Javadoc fix.
+ * java/awt/KeyboardFocusManager.java: Added import for javadoc.
+ (defaultPolicy): Javadoc fix.
+ (setGlobalObject): Javadoc fixes.
+ (getObject): Likewise.
+ (getGlobalObject): Likewise.
+ * java/awt/im/InputMethodRequests.java: Added imports for javadoc.
+ * java/awt/im/spi/InputMethodContext.java: Added imports for javadoc.
+ (enableClientWindowNotification): Javadoc fix.
+ * java/awt/im/spi/InputMethod.java: Added imports for javadoc.
+ (removeNotify): Javadoc fix.
+ (notifyClientWindowChange): Likewise.
+ * java/awt/im/InputContext.java: Added import for javadoc.
+ * java/awt/image/ColorModel.java (getDataElements): Javadoc fix.
+ * java/awt/geom/Area.java (recursiveSubdivide): Javadoc fix.
+ * java/awt/geom/GeneralPath.java (GeneralPathIterator): Javadoc fix.
+ * java/awt/im/InputMethodHighlight.java: Javadoc fixes. Added
+ imports.
+ * java/awt/color/ICC_Profile.java (getInstance): Javadoc fix.
+ (getInstance): Likewise.
+ * java/awt/EventQueue.java: Organized imports.
+ * java/awt/image/BufferedImage.java: Organized imports.
+ * java/awt/image/PackedColorModel.java (initMasks): Javadoc fix.
+ * java/awt/GraphicsConfiguration.java (createCompatibleVolatileImage):
+ Javadoc fixes.
+ * java/awt/DefaultKeyboardFocusManager.java (delayRequests): Javadoc
+ fix.
+ * java/awt/ColorPaintContext.java (ColorPaintContext): Javadoc fix.
+
+2005-10-03 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JOptionPane.java
+ (getInputValue): If the option selected is 'Cancel', then
+ the input value is set to null.
+ (showInternalConfirmDialog): Added check to prevent NPE.
+ (showInternalConfirmDialog): Likewise.
+ (showInternalConfirmDialog): Likewise.
+ (showInternalConfirmDialog): Likewise.
+ (showInternalOptionDialog): Likewise.
+ (showOptionDialog): Likewise.
+
+2005-10-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/rmi/CORBA/ValueHandler.java (getRunTimeCodeBase):
+ Fixed return type.
+ * gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java
+ (getRunTimeCodeBase): Implemented.
+
+2005-10-03 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JMenuItem.java
+ (init): Set horizontalTextPosition to TRAILING, instead of
+ LEFT. Icons are drawn in the correct spot now.
+
+2005-10-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * doc/www.gnu.org/corba.wml: New file.
+
+2005-10-03 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (layoutLabel): place text to the right of the icon, if there is one.
+
+2005-10-03 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalComboBoxButton.java
+ (paintComponent): reposition text and truncate if necessary,
+ (truncateText): private utility method.
+
+2005-10-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * NEWS: Added entry about Classpath VMCID and IIOP.
+
+2005-10-02 Anthony Green <green@redhat.com>
+
+ * native/jni/Makefile.am: Maybe build ALSA code.
+ Maybe build DSSI code.
+
+ * gnu/javax/sound/midi/alsa/AlsaPortDevice.java,
+ gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java
+ gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java
+ gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java
+ gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java: Rebuilt.
+ native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c,
+ native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.c,
+ native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaSequencerDevice.c,
+ native/jni/midi-dssi/dssi_data.h, native/jni/midi-dssi/Makefile.am,
+ native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c
+ native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c,
+ native/jni/midi-alsa/Makefile.am: New files.
+
+ * include/Makefile.am: Add sound header files.
+ * include/gnu_javax_sound_midi_alsa_AlsaPortDevice.h,
+ include/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h
+ include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h
+ include/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.h,
+ include/gnu_javax_sound_midi_alsa_AlsaSequencerDevice.h: New
+ files.
+
+ * configure.ac (AC_CONFIG_FILES): Add
+ native/jni/midi-alsa/Makefile, native/jni/midi-dssi/Makefile.
+
+2005-10-02 Mark Wielaard <mark@klomp.org>
+
+ * java/awt/Font.java (peer): Make field transient.
+ (Font(String,int,int)): Explicitly set name field.
+ (Font(String,Map)): Likewise.
+ (readObject): New private method.
+
+2005-10-02 Mark Wielaard <mark@klomp.org>
+
+ * java/io/ObjectOutputStream.java (writeObject): Add defining class
+ to NotSerializableException.
+
+2005-10-02 Tom Tromey <tromey@redhat.com>
+
+ * java/net/URLStreamHandler.java (hostsEqual): Javadoc fix.
+ * java/net/URLClassLoader.java (definePackage): Javadoc fixes.
+ * java/net/Inet4Address.java (Inet4Address): Javadoc fix.
+ * java/net/Socket.java (getLocalAddress): Javadoc fix.
+ * java/net/DatagramSocket.java (connect): Javadoc fix.
+
+2005-10-02 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/rmi/PortableServer.java,
+ gnu/javax/rmi/CORBA/ValueHandlerImpl.java,
+ javax/rmi/BAD_OPERATION.java,
+ javax/rmi/ORB.java,
+ javax/rmi/CORBA/ObjectImpl.java,
+ javax/rmi/CORBA/SystemException.java: Deleted.
+
+2005-10-02 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/javax/rmi/CORBA/corbaObjectOutput.java (main):
+ Removed method.
+
+2005-10-02 Casey Marshall <csm@gnu.org>
+
+ * gnu/javax/crypto/DiffieHellmanImpl.java (random): removed.
+ (<init>): removed 'random' initialization.
+ (engineDoPhase): use params from the incoming key; generate the
+ intermediate result from the incoming key, not a random one; only
+ support one-phase DH, for now.
+ (engineInit): removed 'random' initialization.
+
+2005-10-02 Robert Schuster <robertschuster@fsfe.org>
+
+ * gnu/xml/stream/XMLOutputFactoryImpl.java:
+ (setProperty): Added 'else'.
+
+2005-10-02 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CDR/Vio.java,
+ gnu/CORBA/CDR/cdrBufOutput.java,
+ gnu/CORBA/CDR/gnuRuntime.java,
+ gnu/javax/rmi/CORBA/corbaObjectInput.java,
+ gnu/javax/rmi/CORBA/dwoTester.java,
+ gnu/javax/rmi/CORBA/gnuRmiUtil.java: Corrected copyright
+ header identation.
+
+2005-10-02 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CDR/ArrayValueHelper.java,
+ gnu/CORBA/CDR/IDLTypeHelper.java,
+ gnu/CORBA/CDR/UnknownExceptionCtxHandler.java,
+ gnu/CORBA/CDR/gnuRuntime.java,
+ gnu/CORBA/CDR/gnuValueStream.java,
+ gnu/CORBA/CDR/VMVio.java,
+ gnu/CORBA/IorProvider.java,
+ gnu/javax/rmi/CORBA/TieTargetRecord.java,
+ gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java,
+ gnu/javax/rmi/CORBA/corbaObjectInput.java,
+ gnu/javax/rmi/CORBA/corbaObjectOutput.java,
+ gnu/javax/rmi/CORBA/dwoTester.java,
+ gnu/javax/rmi/CORBA/gnuRmiUtil.java: New files.
+ * gnu/CORBA/CDR/aligningInputStream.java,
+ gnu/CORBA/CDR/aligningOutputStream.java:
+ gnu/CORBA/CDR/Vio.java,
+ gnu/CORBA/CDR/cdrBufInput.java,
+ gnu/CORBA/CDR/cdrBufOutput.java,
+ gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/CDR/noHeaderInput.java,
+ gnu/CORBA/Functional_ORB.java,
+ gnu/CORBA/GIOP/MessageHeader.java,
+ gnu/CORBA/GIOP/ServiceContext.java,
+ gnu/CORBA/IOR_Delegate.java,
+ gnu/CORBA/IOR_contructed_object.java,
+ gnu/CORBA/Interceptor/Registrator.java,
+ gnu/CORBA/NamingService/NameParser.java,
+ gnu/CORBA/NamingService/NamingServiceTransient.java,
+ gnu/CORBA/ObjectCreator.java,
+ gnu/CORBA/Poa/LocalDelegate.java,
+ gnu/CORBA/Poa/ORB_1_4.java,
+ gnu/CORBA/Poa/gnuPOA.java,
+ gnu/CORBA/Poa/gnuServantObject.java,
+ gnu/CORBA/Simple_delegate.java,
+ gnu/CORBA/gnuAny.java,
+ gnu/CORBA/gnuRequest.java,
+ org/omg/CORBA/OMGVMCID.java,
+ org/omg/CORBA/StringValueHelper.java,
+ org/omg/CORBA/SystemException.java,
+ org/omg/CORBA/WStringValueHelper.java,
+ org/omg/CORBA/portable/ObjectImpl.java,
+ org/omg/CORBA_2_3/ORB.java,
+ org/omg/CORBA_2_3/portable/InputStream.java,
+ org/omg/CORBA_2_3/portable/OutputStream.java: Modified to support
+ RMI over CORBA mechanism.
+ * gnu/javax/rmi/CORBA/DelegateFactory.java,
+ gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java,
+ gnu/javax/rmi/CORBA/StubDelegateImpl.java,
+ gnu/javax/rmi/CORBA/UtilDelegateImpl.java,
+ javax/rmi/CORBA/ClassDesc.java,
+ javax/rmi/CORBA/PortableRemoteObjectDelegate.java,
+ javax/rmi/CORBA/Stub.java,
+ javax/rmi/CORBA/StubDelegate.java,
+ javax/rmi/CORBA/Tie.java,
+ javax/rmi/CORBA/Util.java,
+ javax/rmi/CORBA/UtilDelegate.java,
+ javax/rmi/CORBA/ValueHandler.java,
+ javax/rmi/CORBA/package.html,
+ javax/rmi/PortableRemoteObject.java,
+ javax/rmi/package.html: New files (replacing).
+ * gnu/javax/rmi/CORBA/ValueHandlerImpl.java,
+ gnu/javax/rmi/PortableServer.java: Modified to keep the code
+ compileable between subsequent patches.
+
+2005-10-02 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/ImageIO.java: Fix compilation problems.
+
+2005-10-01 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ (MetalScrollBarPropertyChangeHandler.propertyChange):
+ Only set free standing when increase or decrease button isn't null.
+ If not FREE_STANDING_PROP pass up event to super class.
+
+2005-10-02 Mark Wielaard <mark@klomp.org>
+
+ Workarounds for bug #24166
+ * javax/imageio/ImageIO.java (filter): Catch IOException in
+ canDecodeInput().
+ (TranscoderFilter.WriterObjectFilter): Renamed to TranscoderFilter.
+ (getImageReadersBySuffix): Use ReaderObjectFilter, not the nonexisting
+ ReaderSuffixFilter.
+ (createImageInputStream): Test with Class.isAssignableFrom() and for
+ foundSpi == null.
+ (createImageOutputStream): Likewise and use output, not input.
+ (getImageReader): Always return null for now.
+ (getImageReaders): Use input, not object.
+ (getImageWriters): Rename formatName to format and create a
+ WriterObjectFilter with type and format not just object.
+ (getImageWriter): Always return null for now.
+ (getImageTranscoders): Create TranscoderFilter not ImageTranscoderSpi
+ instance.
+
+2005-10-02 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicButtonUI.java: API doc updates.
+
+2005-10-02 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * javax/imageio/IIOException.java: Document.
+ * javax/imageio/IIOImage.java: Document.
+ * javax/imageio/IIOParam.java: Complete and document.
+ * javax/imageio/IIOParamController.java: Document.
+ * javax/imageio/ImageIO.java: Complete and document.
+ * javax/imageio/ImageReader.java: Complete and document.
+ * javax/imageio/ImageTranscoder.java: Document.
+ * javax/imageio/ImageTypeSpecifier.java: Complete and document.
+ * javax/imageio/ImageWriter.java: Complete and document.
+ * javax/imageio/package.html: Write.
+
2005-10-01 Jeroen Frijters <jeroen@frijters.net>
* vm/reference/java/lang/reflect/Constructor.java
@@ -316,6 +4323,51 @@
(getGenericParameterTypes): New method.
(getGenericReturnType): New method.
+2005-10-01 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/23890:
+ * java/util/Calendar.java (equals): Include other calendar
+ attributes.
+ (hashCode): Updated.
+ * java/util/GregorianCalendar.java (hashCode): New method.
+ (equals): Use super.equals().
+
+2005-10-01 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * java/awt/image/ComponentSampleModel.java (numBands): Shadow
+ package-private field in parent class with this protected field.
+ * java/awt/image/SampleModel.java (numBands): Make field
+ package-private.
+
+2005-10-01 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/23880:
+ * gnu/java/security/x509/ext/Extension.java (Value.hashCode): New
+ method.
+ * gnu/java/security/der/BitString.java (hashCode): New method.
+ * javax/security/auth/x500/X500Principal.java (hashCode): New method.
+
+2005-10-01 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/net/URLClassLoader.java
+ (Resource.name): Removed field.
+ (JarURLResource.name): Added field.
+ (FileResource.getURL): Use File.toURL() instead of doing it in
+ a way that breaks on Windows.
+
+2005-10-01 Mark Wielaard <mark@klomp.org>
+
+ * doc/www.gnu.org/include/layout.wml: Point Tasks menu item to
+ mediation wiki.
+ * doc/www.gnu.org/tasks.wml: Redirect to mediation wiki.
+
+2005-10-01 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked):
+ Call cairo_pattern_set_extend after gr->pattern has been set and checked
+ versus NULL.
+
2005-09-30 Jeroen Frijters <jeroen@frijters.net>
* gnu/java/lang/reflect/FieldSignatureParser.java: New file.
@@ -324,6 +4376,360 @@
gnu/java/lang/reflect/MethodSignatureParser.java:
Finished implementation.
+2005-09-30 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTextPane.java
+ (replaceSelection): Don't update the caret position here.
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (DocumentHandler.insertUpdate): Likewise.
+ (DocumentHandler.removeUpdate): Likewise.
+ * javax/swing/text/DefaultCaret.java
+ (DocumentHandler): New inner class. Handles caret position updates.
+ (PropertyChangeHandler): New inner class. (Un)installs document
+ listener when the text component's document changes.
+ (install): Install the new listeners on the text component.
+ (deinstall): Deinstall the new listeners on the text component.
+ * javax/swing/text/DefaultEditorKit.java
+ (DefaultKeyTypedAction.actionPerformed): Don't update the caret
+ position here.
+
+2005-09-30 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): updateUI should be called after
+ everything is initialized, so everything is revalidated.
+ * javax/swing/JMenuItem.java
+ (JMenuItem): Added call to init so model is set.
+ (JMenuItem): Likewise.
+ * javax/swing/JOptionPane.java
+ (createDialog): Removed invalidate and repaint calls.
+ (JOptionPane): Likewise.
+ * javax/swing/JPopupMenu.java
+ (setVisible): Changed size to be the preferred size.
+
+2005-09-30 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (paintTabArea): Added check to adjust runCount if
+ it is less that tabCount.
+
+2005-09-30 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/PlainDocument.java:
+ (removeUpdate): Fixed length of new LeafElement and off-by-one error
+ in call to rootElement.replace().
+
+2005-09-30 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (propertyChange): No reason to reset the layout manager here.
+ (setDividerLocation): Changed to check right component, not left.
+ Also, updated the location to a valid spot.
+
+2005-09-30 David Gilbert <david.gilbert@object-refinery.com>
+
+ * examples/gnu/classpath/examples/swing/SliderDemo.java:
+ New file.
+
+2005-09-30 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/AbstractButton.java
+ (setActionCommand): Added check to prevent NPE.
+ (getMnemonic): Likewise.
+ (setMnemonic): Likewise.
+ (setSelected): Likewise.
+ (isSelected): Likewise.
+ (setEnabled): Likewise.
+ (doClick): Likewise.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (paintMenuItem): Added check to prevent NPE.
+ (paintText): Likewise.
+
+2005-09-30 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (propertyChange): Added call to reset the layout manager
+ whenever the size of the divider is changed.
+ (setDividerLocation): Added adjustment to container
+ sizes if the divider goes over the bottom/right side.
+ Also, fixed the size of the right/top component.
+ (validLocation): Added check for min/max location returned.
+
+2005-09-30 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/StyleContext.java:
+ (SmallAttributeSet.getAttribute): If the attribute we're looking for is
+ ResolveAttribute, don't try to check the resolve parent, because this
+ will cause an infinite loop.
+
+2005-09-30 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (accessibleContext): Removed unneeded field. This is already
+ declared in JComponent.
+ * javax/swing/Box.java
+ (accessibleContext): Removed unneeded field. This is already
+ declared in JComponent.
+ * javax/swing/JFrame.java
+ (EXIT_ON_CLOSE): New constant field.
+
+2005-09-30 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/GapContent.java:
+ (shiftEnd): Call adjustPositionsInRange rather than getPositionsInRange
+ and then iterating over the set and adjusting them.
+ (shiftGap): Likewise.
+ (shiftGapStartDown): Call setPositionsInRange rather than
+ getPositionsInRange and then iterating over the set to set each
+ Position.
+ (shiftGapEndUp): Likewise.
+ (setPositionsInRange): New implementation method.
+ (adjustPositionsInRange): New implementation method.
+ (resetMarksAtZero): Call setPositionsInRange rather than
+ getPositionsInRange and then iterating over the set to set each
+ Position.
+
+2005-09-30 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (getScrollableUnitIncrement): Respect the direction argument.
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (VSBChangeListener.stateChanged): Compare ypos with viewPosition.y
+ instead of viewPosition.x.
+ (ViewportChangeHandler.stateChanged): Call
+ syncScrollPaneWithViewport in all cases, not only when the
+ extents have changed.
+ (syncScrollPaneWithViewport): Also sync the maximum and value
+ properties of the scrollbar models with the viewport.
+
+2005-09-30 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (paint): Only call paintFocus if button is actually focused.
+
+2005-09-30 Roman Kennke <kennke@aicas.com>
+
+ Fixes Bug #24115
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Don't call init() from here. Moved some
+ initialization code from init() to the constructor.
+ (init): Moved most of the initialization code to the constructor.
+ * javax/swing/JCheckBox.java
+ (JCheckBox()): call this(..) instead of super(..). Don't call init()
+ here, this is already performed by the JToggleButton constructor.
+ (JCheckBox(Action)): Don't call init() here, this is already
+ performed by the JToggleButton constructor.
+ (JCheckBox(Icon)): call this(..) instead of super(..). Don't call
+ init() here, this is already performed by the JToggleButton
+ constructor.
+ (JCheckBox(Icon, boolean)): Likewise.
+ (JCheckBox(String)): Likewise.
+ (JCheckBox(String, boolean)): Likewise.
+ (JCheckBox(String, Icon)): Likewise.
+ (JCheckBox(String, Icon, boolean)): Don' call init here. This is
+ already performed by the JToggleButton constructor. Set the
+ correct defaults for horizontalAlignment and borderPainted
+ properties here.
+ * javax/swing/JRadioButton.java
+ (JRadioButton(String, Icon, boolean)): Use acccessor methods
+ instead of directly manipulating package private fields of
+ AbstractButton.
+ * javax/swing/JToggleButton.java
+ (JToggleButton(String, Icon, boolean)): Set correct value for the
+ alignmentX property.
+
+2005-09-30 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/JFileChooser.java: Import AccessibleRole.
+
+2005-09-30 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+ (cp_gtk_graphics2d_init_jni): Check ExceptionOccured after running
+ class initializer.
+
+2005-09-30 Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/awt/peer/gtk/GdkFontMetrics.java (initFont): New static
+ method.
+ (GdkFontMetrics): Use initFont() in super() call.
+
+2005-09-30 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+ (Java_gnu_java_awt_peer_gtk_GdkTextLayout_getOutline): Initialize all
+ fields of the FT_Outline_Funcs ftCallbacks struct.
+ (_moveTo): Takes an void * as argument.
+ (_lineTo): Likewise.
+ (_quadTo): Likewise.
+ (_curveTo): Likewise.
+
+2005-09-30 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/JFileChooser.java:
+ (getAccessibleContext): Implement.
+ (AccessibleJFileChooser): Inner class implemented.
+
+2005-09-30 Jeroen Frijters <jeroen@frijters.net>
+
+ Fixes Bug 24122
+ * gnu/xml/transform/TransformerImpl.java
+ (writeStreamResult): Added call to connection.setDoInput(false).
+
+2005-09-29 Tom Tromey <tromey@redhat.com>
+
+ * java/net/URLConnection.java (setDoInput): Javadoc fix.
+ (setDoOutput): Likewise.
+ (setContentHandlerFactory): Likewise.
+ (setFileNameMap): Likewise.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (installUI): Call the new installKeyboardActions hook.
+ (uninstallUI): Call the new uninstallKeyboardActions hook.
+ (installKeyboardActions): New hook method.
+ (uninstallKeyboardActions): New hook method.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (ActionScroller.ActionScroller): Added constructor.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (KeyHandler): New inner class.
+ (createKeyListener): New method.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (getLeftChildIndent): Fixed method signature.
+ (drawCentered): Fixed method signature.
+
+2005-09-29 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/23381:
+ * java/beans/PropertyDescriptor.java (hashCode): New method.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/OverlayLayout.java: Added API docs all over.
+
+2005-09-29 David Gilbert <david.gilbert@object-refinery.com>
+
+ * examples/gnu/classpath/examples/swing/ButtonDemo.java
+ (createContent): add a close button,
+ (actionPerformed): perform close action,
+ * examples/gnu/classpath/examples/swing/ComboBoxDemo.java
+ (createContent): add a close button,
+ (actionPerformed): perform close action.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeRequirements.java
+ (getAlignedSizeRequirements): Fixed calculation of preferred and
+ maximum size as well as the alignment.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ Fixes Bug #23851
+ * javax/swing/OverlayLayout.java
+ (OverlayLayout): Implemented.
+ (invalidateLayout): Implemented.
+ (addLayoutComponent(Component, Object)): Implemented.
+ (addLayoutComponent(String, Component)): Implemented.
+ (removeLayoutComponent): Implemented.
+ (preferredLayoutSize): Implemented.
+ (minimumLayoutSize): Implemented.
+ (maximumLayoutSize): Implemented.
+ (getLayoutAlignmentX): Implemented.
+ (getLayoutAlignmentY): Implemented.
+ (layoutContainer): Implemented.
+ (checkRequirements): New private helper method.
+ (checkTotalRequirements): New private helper method.
+ (checkLayout): New private helper method.
+
+2005-09-29 David Gilbert <david.gilbert@object-refinery.com>
+
+ * examples/gnu/classpath/examples/swing/ComboBoxDemo.java: new demo.
+
+2005-09-29 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * java/awt/print/PrinterJob.java
+ (print(PrintRequestAttributeSet)): Remove abstract modifier and
+ implement.
+
+2005-09-29 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JPopupMenu.java
+ (setVisible): use current size, not preferred size, when checking for
+ screen edge,
+ * javax/swing/plaf/basic/BasicComboPopup.java
+ (show): include top and bottom insets in preferred size,
+ * javax/swing/plaf/metal/MetalComboBoxButton.java
+ (MetalComboBoxButton): don't pass icon to super class,
+ (paintComponent): call super.paintComponent() and reworked label
+ drawing.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ Fixes Bug #24105
+ * javax/swing/text/GapContent.java
+ (GapContentPosition.getOffset): Adjusted assert statement.
+ (shiftGap): Adjusted index in getPositionsInRange call. Call
+ resetMarksAtZero if gapStart has moved to 0.
+ (replace): Call shiftGap and shiftGapEndUp only if necessary.
+ (resetMarksAtZero): New method.
+
+2005-09-29 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicMenuItemUI.java:
+ Added a new field for the gap between the icon and text.
+ (setPreferredMenuItemSize): Changed gap from defaultTextIconGap
+ to defaultTextArrowIconGap
+
+2005-09-29 Tom Tromey <tromey@redhat.com>
+
+ * java/rmi/activation/ActivationGroup_Stub.java (serialVersionUID):
+ New field.
+
+2005-09-28 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #24080
+ * java/awt/Window.java
+ (show): Fixed the synchronized block to fix deadlock
+ problem.
+
+2005-09-29 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java
+ (getOutline): Implement as native
+ * include/gnu_java_awt_peer_gtk_GdkTextLayout.h
+ Add declaration
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+ (getOutline): Implement.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ * java/rmi/server/RMIClassLoader.java
+ (loadClass(URL, String)): New method.
+
+2005-09-29 Roman Kennke <kennke@aicas.com>
+
+ Fixes Bug #24114
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (installDefaults): Set the background color correctly.
+
+2005-09-29 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicIconFactory.java
+ (getMenuArrowIcon): adjusted the size and painting of the returned
+ icon,
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (paintMenuItem): adjusted arrow icon position.
+
2005-09-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/awt/peer/qt/QtGraphics.java:
@@ -383,6 +4789,251 @@
(getExceptionTypes()): Likewise.
(getParameterTypes()): Likewise.
+2005-09-28 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/AbstractDocument.java:
+ (BranchElement.getElementIndex): If there are no children, don't return
+ -1, instead getStartOffset() will throw NPE. Also, if no child Element
+ contains the specified offset, return the closest one.
+
+2005-09-28 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (showTip): Added check to prevent NPE.
+ (adjustLocation): Changed else if to if, to
+ check final y position of tooltip incase
+ it is still cut off.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * java/rmi/server/RMIClassLoader.java:
+ Moved all implementation code to
+ gnu.java.rmi.server.RMIClassLoaderImpl.
+ (getProviderInstance): New helper method to find a provider.
+ (getDefaultProviderInstance): New helper method to find a provider.
+ (loadClass(String, String, Class)): New method.
+ * gnu/java/rmi/server/RMIClassLoaderImpl.java:
+ New class. The implementation is moved from
+ java.rmi.server.RMIClassLoader.
+
+2005-09-28 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/AbstractDocument.java:
+ (AbstractElement.getResolveParent): If the AttributeSet's
+ getResolveParent returns null, use the Element's parent's AttributeSet.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * java/rmi/activation/ActivationGroup_Stub.java:
+ New class.
+
+2005-09-28 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (paint): No need to call calculateThumbLocation, called
+ by calculateGeometry.
+
+2005-09-28 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #23934
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (paint): Called calculateGeometry, so the slider is
+ initially set up.
+
+2005-09-28 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #24080
+ * java/awt/Window.java
+ (show): Added a synchronized block to fix deadlock
+ problem.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicSliderUI.java
+ (ActionScroller): Added unused class for binary compatibility.
+ * javax/swing/plaf/basic/BasicTableHeaderUI.java
+ (MouseInputHandler): Made inner class public as specified.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (FocusHandler): Made inner class public as specified.
+ (MouseInputHandler): Made inner class public as specified.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonUI.java
+ (currentIcon): Made method package private, so that other button
+ UIs can access it.
+ (paint): Removed unnecessary call to paintButtonNormal().
+ (paintButtonNormal): Removed unnecessary method. The background
+ is already filled correctly when paint() is entered.
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (paint): Call the new paintFocus() method instead of the inherited
+ from BasicButtonUI.
+ (paintFocus): New method. Paints the focus indicator for
+ JRadioButtons and subclasses.
+ * javax/swing/plaf/basic/BasicToggleButtonUI.java
+ (paint): New method. Implements custom painting. Mostly, this
+ is needed in order to call the new paintIcon() method.
+ (paintIcon): New method. Narrows the types from the super-class
+ method.
+
+2005-09-28 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/Utilities.java:
+ (getRowEnd): Call getText() rather than trying to get the Element-
+ specific portion to avoid GapContent errors.
+ (getRowStart): Likewise.
+
+2005-09-28 Tom Tromey <tromey@redhat.com>
+
+ * javax/sound/midi/MidiUnavailableException.java (serialVersionUID):
+ New field.
+ * javax/sound/midi/InvalidMidiDataException.java (serialVersionUID):
+ New field.
+
+2005-09-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/UIDefaults.java
+ (getBoolean(Object)): API doc correction.
+
+2005-09-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalButtonListener.java
+ (propertyChange): check new value of property to determine which
+ border to set.
+
+2005-09-28 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java
+ (installDefaults): Fixed checks for setting defaults.
+ Should check if default is null also.
+
+2005-09-28 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #24077
+ * gnu/java/awt/peer/gtk/GdkFontMetrics.java
+ (GdkFontMetrics): Added a check for the font
+ being null. Fixed a NPE.
+ * gnu/java/awt/peer/gtk/GdkGraphics.java
+ (GdkGraphics): Added check if the font is null.
+ If it is, the font should be set to the default.
+ (setFont): If font parameter is null, this.font should not
+ be changed.
+ * javax/swing/JPopupMenu.java:
+ Fixed API documentation to say 'JDialog' rather than
+ 'JWindow'.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonUI.java
+ (currentIcon): Made method package private, so that other button
+ UIs can access it.
+ (paint): Removed unnecessary call to paintButtonNormal().
+ (paintButtonNormal): Removed unnecessary method. The background
+ is already filled correctly when paint() is entered.
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (paint): Call the new paintFocus() method instead of the inherited
+ from BasicButtonUI.
+ (paintFocus): New method. Paints the focus indicator for
+ JRadioButtons and subclasses.
+ * javax/swing/plaf/basic/BasicToggleButtonUI.java
+ (paint): New method. Implements custom painting. Mostly, this
+ is needed in order to call the new paintIcon() method.
+ (paintIcon): New method. Narrows the types from the super-class
+ method.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (createDefaultTheme): Change default back to DefaultMetalTheme.
+ The Ocean theme is too inconsistent.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Font.java
+ (tk): Made method package private. Must not be protected.
+ (getFontFromToolkit): Made method package private. Must not
+ be protected.
+ (getPeerFromToolkit): Made method package private. Must not
+ be protected.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (createMouseWheelListener): New hook method for creating
+ mouse wheel listeners.
+ (installListeners): Use new hook method to create mouse wheel
+ listeners.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalProgressBarUI.java
+ (createUI): Removed Hashtable lookup.
+ * javax/swing/plaf/metal/MetalSeparatorUI.java
+ (paint): New method. Uses the metal colors for drawing separators.
+ * javax/swing/plaf/metal/MetalSplitPaneUI.java
+ (createUI): Removed Hashtable lookup.
+ * javax/swing/plaf/metal/MetalTabbedPaneUI.java
+ (createUI): Removed Hashtable lookup.
+ * javax/swing/plaf/metal/MetalTextFieldUI.java
+ (createUI): Removed Hashtable lookup.
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (createUI): Removed Hashtable lookup.
+ * javax/swing/plaf/metal/Ocean.java
+ (addCustomEntriesToTable): New method. Adds some custom UI defaults
+ for the Ocean theme.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ (paintThumb): Use new MetalUtils.fillMetalPattern signature.
+ * javax/swing/plaf/metal/MetalSplitPaneDivider.java
+ (paint): Use new MetalUtils.fillMetalPattern signature.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
+ (paintPalette): Use new MetalUtils.fillMetalPattern signature.
+ (paintComponent): Use new MetalUtils.fillMetalPattern signature.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java
+ (MenuItemBorder.paintBorder): Fixed painting so that a thin white
+ line is drawn on the left of unarmed items. Fixed color handling.
+ (PopupMenuBorder.borderInsets): Fixed insets.
+ (PopupMenuBorder.paintBorder): Removed left white line. This is
+ drawn now in the MenuItemBorder.
+ (ToolBarBorder.paintBorder): Use correct call to new MetalUtils
+ fillMetalPattern method signature.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalUtils.java
+ (fillMetalPattern): If we have a Graphics2D, then go into
+ optimized drawing mode.
+ (fillMetalPattern2D): New method. Implements pattern drawing using
+ textures.
+ (initializePattern): New method. Initializes the texture.
+
+2005-09-28 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Font.java: Reformatted file.
+
+2005-09-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (TreeHardDriveIcon): new private class,
+ (TreeFloppyDriveIcon): new private class,
+ (TreeComputerIcon): new private class,
+ (getTreeControlIcon): implemented,
+ (getTreeComputerIcon): implemented,
+ (getTreeHardDriveIcon): implemented.
+
+2005-09-28 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java
+ (ToolBarBorder): now implements SwingConstants.
+
2005-09-27 Tom Tromey <tromey@redhat.com>
* java/sql/Timestamp.java (compareTo(Date)): Changed argument type
@@ -456,6 +5107,147 @@
(CaseInsensitiveComparator): Updated.
(CaseInsensitiveComparator.compare): Changed argument types.
+2005-09-27 Anthony Green <green@redhat.com>
+
+ * javax/sound/midi/MidiSystem.java (getSequence): Add
+ missing methods.
+ * javax/sound/midi/Sequencer.java (stopRecording): Ditto.
+ * javax/sound/midi/ShortMessage.java (ShortMessage): Ditto.
+ (setMessage): Fix visibility. Add missing implementations.
+ * javax/sound/midi/ShoundbankResouce.java: Rename "soundBank" to
+ "soundbank", and "getSoundBank" to "getSoundbank".
+
+2005-09-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java
+ (rolloverBorder): new field,
+ (getRolloverBorder): new method,
+ * javax/swing/plaf/metal/MetalButtonListener.java: new class,
+ * javax/swing/plaf/metal/MetalButtonUI.java
+ (instance): removed field,
+ (constructor): initialise fields from UI defaults,
+ (getFocusColor): just return field value,
+ (getSelectColor): just return field value,
+ (getDisabledTextColor): just return field value,
+ (createUI): return a new instance every time,
+ (installDefaults): check for isRolloverEnabled and install rollover
+ border if necessary,
+ (uninstallDefaults): implemented,
+ (createButtonListener): implemented,
+ (paintButtonPressed): implemented,
+ (paintFocus): implemented,
+ (paintText): implemented.
+
+2005-09-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/SimpleAttributeSet.java:
+ (containsAttribute): Check the resolve parent if the attribute is not
+ found locally.
+ (containsAttributeLocally): New package-private method.
+ (isEqual): Re-implemented. Return true if the two sets have the same
+ size and this set contains the given set.
+
+2005-09-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JSeparator.java
+ (updateUI): Removed invalidate call. This is unnecessary.
+ * javax/swing/plaf/basic/BasicSeparatorUI.java
+ (paint): Reworked painting so that it paints the separator
+ correctly.
+ (getPreferredSize): Fixed to return the correct values according
+ to the JDK.
+ (getMinimumSize): Likewise.
+ (getMaximumSize): Likewise.
+
+2005-09-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java
+ (RolloverButtonBorder): new class.
+
+2005-09-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/BoxLayout.java
+ (preferredLayoutSize): Fixed to respect the containers insets.
+ (layoutComponent): Likewise.
+
+2005-09-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeRequirements.java
+ (calculateTiledPositions): Only adjust sizes if the allocated
+ span is actually different from the used span.
+ (calculateAlignedPositions): Call adjustFromRight also if
+ baseline == 0, otherwise we get strange results because 0 * x = 0.
+
+2005-09-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/SimpleAttributeSet.java:
+ (removeAttributes(AttributeSet)): Only remove attributes from the
+ current set if their keys AND values are found in the given set
+
+2005-09-27 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #24067
+ * java/awt/Component.java
+ (removeNotify): Should call hide on the peer before
+ disposing of it. This stops the flashing when the
+ tooltips are removed from the component.
+ * javax/swing/plaf/basic/BasicToolTipUI.java
+ (getPreferredSize): If the accelerator is null, we should
+ paint the mnenomic if it is available.
+
+2005-09-27 Tom Tromey <tromey@redhat.com>
+
+ * java/awt/Window.java (createBufferStrategy): Can throw AWTException.
+ * java/awt/Canvas.java (createBufferStrategy): Can throw AWTException.
+
+2005-09-27 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #24044
+ * javax/swing/ToolTipManager.java
+ (showTip): currentTip needs to be revalidated on HeavyWeightPopups
+ * javax/swing/plaf/basic/BasicToolTipUI.java
+ (getPreferredSize): Fixed to get the preferred size of the
+ tooltip including the accelerator, if it has one.
+ (paint): Fixed to paint the accelerator in its font
+ and color, if it has one.
+
+2005-09-27 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/Utilities.java:
+ (getRowEnd): New method.
+ (getRowStart): New method.
+
+2005-09-27 Tom Tromey <tromey@redhat.com>
+
+ * java/beans/beancontext/BeanContextServicesSupport.java
+ (BCSSChild.serialVersionUID): Fixed.
+ * java/beans/beancontext/BeanContextSupport.java
+ (BCSChild.serialVersionUID): Fixed.
+
+2005-09-27 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ (installDefaults): get border from UI defaults,
+ * javax/swing/plaf/metal/MetalBorders.java:
+ (ToolBarBorder): new class,
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): added tool bar border default,
+ * javax/swing/plaf/metal/MetalToolBarUI.java
+ (MetalContainerListener): new class,
+ (instance): removed field,
+ (MetalRolloverListener): new class,
+ (contListener): new field,
+ (rolloverListener): new field,
+ (createUI): return a new instance every time,
+ (createRolloverListener): implemented,
+ (createContainerListener): implemented,
+ (createNonRolloverBorder): implemented.
+
+2005-09-27 Anthony Green <green@redhat.com>
+
+ * javax/sound/midi/MidiFileFormat.java (bytes, microseconds):
+ Rename to byteLength and microsecondLength respectively.
+
2005-09-26 Tom Tromey <tromey@redhat.com>
* java/util/Formatter.java (format): Set fmtLocale.
@@ -468,6 +5260,132 @@
(singleDateTimeConversion): New method.
(dateTimeConversion): Likewise.
+2005-09-26 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (showTip): validating of toolTipWindow should not have been
+ removed.
+
+2005-09-26 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (showTip): Removed validating of currentTip. setVisible(true)
+ does this. Also, removed validating of toolTipWindow because
+ show() does this.
+
+2005-09-27 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeRequirements.java
+ (adjustGreater): Special handle the case when the components have
+ no spare room for adjustment.
+ (adjustSmaller): Special handle the case when the components have
+ no spare room for adjustment.
+
+2005-09-27 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (hide): Repaint component before invalidating the parent.
+ (show): Repaint component before invalidating the parent.
+ * javax/swing/JComponent.java
+ (revalidate): Check if we are in the event thread, and if not,
+ then queue a self-request in the event thread.
+ (setVisible): Repaint the parent and queue a revalidate.
+
+2005-09-27 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/JComboBox.java
+ (firePopupMenuCanceled): Implement
+ (firePopupMenuWillBecomeInvisible): Implement
+ (firePopupMenuWillBecomeVisible): Implement
+
+2005-09-27 Sven de Marothy <sven@physto.se>
+
+ * javax/swing/text/html/CSS.java
+ (getAttribute,getAllAttributeKeys): Implement
+
+2005-09-26 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTree.java
+ (JTree): Root should be visible by default.
+ * javax/swing/ToolTipManager.java
+ (showTip): Added check for validity of currentTip. Prevents
+ over-validating.
+ (hideTip): currentTip should be reset.
+ * javax/swing/JMenuItem.java
+ (setAccelerator): Registered accelerator as a keyboard action.
+
+2005-09-26 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/reflect/Proxy.java: Javadoc fix.
+ * java/io/OutputStreamWriter.java (OutputStreamWriter): Javadoc fix.
+
+2005-09-26 Anthony Green <green@redhat.com>
+
+ * javax/sound/midi/Synthesizer.java (loadInstrument,
+ unloadInstrument, remapInstrument, loadAllInstruments,
+ unloadAllInstruments, unloadInstrument, loadInstrument): Don't
+ declare the unchecked IllegalArgumentException.
+ * javax/sound/midi/MidiSystem.java (getMidiDevice, write): Ditto.
+ * javax/sound/midi/ShortMessage.java: Fix 80-column formatting
+ problem.
+ * javax/sound/midi/Sequence.java: Ditto.
+ * javax/sound/midi/MidiMessage.java: Ditto.
+ * javax/sound/midi/MidiSystem.java: Ditto.
+ * javax/sound/midi/MidiFileFormat.java: Ditto.
+
+2005-09-26 Anthony Green <green@redhat.com>
+
+ * javax/sound/midi/InvalidMidiDataException.java
+ * javax/sound/midi/MidiFileFormat.java
+ * javax/sound/midi/ControllerEventListener.java
+ * javax/sound/midi/Patch.java javax/sound/midi/Sequence.java
+ * javax/sound/midi/SysexMessage.java javax/sound/midi/Sequencer.java
+ * javax/sound/midi/spi/MidiFileReader.java
+ * javax/sound/midi/spi/MidiFileWriter.java
+ * javax/sound/midi/spi/SoundbankReader.java
+ * javax/sound/midi/spi/MidiDeviceProvider.java
+ * javax/sound/midi/Track.java javax/sound/midi/MidiChannel.java
+ * javax/sound/midi/MetaMessage.java javax/sound/midi/Instrument.java
+ * javax/sound/midi/MidiMessage.java
+ * javax/sound/midi/MidiUnavailableException.java
+ * javax/sound/midi/Transmitter.java javax/sound/midi/MidiEvent.java
+ * javax/sound/midi/VoiceStatus.java javax/sound/midi/MidiDevice.java
+ * javax/sound/midi/SoundbankResource.java
+ * javax/sound/midi/Soundbank.java javax/sound/midi/Receiver.java
+ * javax/sound/midi/MetaEventListener.java
+ * javax/sound/midi/ShortMessage.java
+ * javax/sound/midi/Synthesizer.java
+ * javax/sound/midi/MidiSystem.java: New files.
+
+2005-09-26 Lillian Angel <langel@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkDialogPeer.java
+ (create): If the dialog is a toolTip or a
+ PopupMenu, its type should be set to:
+ GDK_WINDOW_TYPE_HINT_MENU, so the parent
+ window does not lose focus.
+ * javax/swing/JTree.java
+ (setModel): Should update the UI everytime the
+ model is changed.
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (installUI): Should not set the root to be visible.
+ (paintControlIcons): changed to use getVisibleRect.
+ * javax/swing/plaf/metal/MetalTreeUI.java
+ (installUI): Should not set the root to be visible.
+
+2005-09-26 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * gnu/java/text/BaseBreakIterator.java:
+ (following): Removed unused local variable.
+
+2005-09-26 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeRequirements.java
+ (calculateTiledPositions): Improved to also take minimum and maximum
+ sizes into account and better use the allocated space.
+ (adjustGreater): New helper function.
+ (adjustSmaller): New helper function.
+
2005-09-25 Jeroen Frijters <jeroen@frijters.net>
* gnu/java/lang/reflect/ClassSignatureParser.java,
@@ -505,6 +5423,47 @@
* java/util/Formatter.java (lineSeparator): Use SystemProperties.
+2005-09-25 Casey Marshall <csm@gnu.org>
+
+ Fixes PR classpath/23916. Fix suggested by Santiago Gala
+ <sgala@apache.org>.
+ * java/security/AccessControlContext.java
+ (<init>): update javadoc; check SecurityPermission
+ "createAccessControlContext" if a security manager is set.
+ (getProtectionDomains): new method.
+ * vm/reference/java/security/VMAccessController.java
+ (DEBUG): set to 'gnu.classpath.Configuration.DEBUG.'
+ (pushContext, popContext): add debug statement.
+ (getContext): debug output changes; include the DomainCombiner
+ specified in the AccessControlContext, if any.
+
+2005-09-25 Tom Tromey <tromey@redhat.com>
+
+ * javax/security/sasl/SaslServerFactory.java: Updated javadoc.
+ * javax/security/sasl/Sasl.java: Updated javadoc.
+ * javax/security/sasl/SaslClientFactory.java: Updated javadoc.
+ * javax/security/sasl/RealmChoiceCallback.java: Updated javadoc.
+ * javax/security/sasl/RealmCallback.java: Updated javadoc.
+ * javax/security/sasl/AuthenticationException.java: Updated
+ javadoc.
+ * javax/security/sasl/SaslServer.java (getNegotiatedProperty):
+ Don't throw SaslException.
+ * javax/security/sasl/SaslClient.java (getNegotiatedProperty):
+ Don't throw SaslException.
+ * javax/security/sasl/SaslException.java (serialVersionUID): New
+ field.
+ * javax/security/sasl/AuthorizeCallback.java (AuthorizeCallback):
+ Implements Serializable.
+ (serialVersionUID): New field.
+
+2005-09-25 Casey Marshall <csm@gnu.org>
+
+ * gnu/java/security/provider/Gnu.java
+ (<init>): add Diffie-Hellman key factory and key pair generator.
+ * gnu/java/security/provider/DiffieHellmanKeyFactoryImpl.java,
+ * gnu/java/security/provider/DiffieHellmanKeyPairGeneratorImpl.java:
+ new files.
+
2005-09-24 Tom Tromey <tromey@redhat.com>
* java/util/FormattableFlags.java (PLUS, SPACE, ZERO, COMMA,
@@ -525,6 +5484,564 @@
Fixed.
* java/util/Formatter.java: New file.
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeRequirements.java
+ (calculateAlignedPositions): Improved algorithm to better respect
+ the minimum and maximum size and to better use the available space.
+ (adjustFromRight): New helper method.
+ (adjustFromLeft): New helper method.
+
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/BoxLayout.java
+ (layoutContainer): Respect the insets of the container.
+
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ Fixed some API comments.
+ (paintChildren): Set clip to exclude the border area.
+
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paint): Paint border after the children are painted. Otherwise the
+ children could draw over the border.
+
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SizeRequirements.java
+ (getAlignedRequirements): Implemented this method.
+ (calculateAlignedPositions): Implemented this method.
+ * javax/swing/BoxLayout.java
+ (Direction): Removed unneeded inner interface.
+ (Horizontal): Removed unneeded inner class.
+ (Vertical): Removed unneeded inner class.
+ (SizeReq): Removed unneeded inner class.
+ (preferredLayoutSize): Reimplemented to use SizeRequirements.
+ (minimumLayoutSize): Reimplemented to use SizeRequirements.
+ (maximumLayoutSize): Reimplemented to use SizeRequirements.
+ (layoutContainer): Reimplemented to use SizeRequirements.
+ (layoutAlgorithm): Removed unneeded package private method.
+ (distributeSpace): Removed unneeded package private method.
+ (getSizeRequirements): New private helper method.
+
+2005-09-24 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/imageio/bmp/BMPDecoder.java
+ (BMPDecoder): Fix static field references.
+
+2005-09-24 Sven de Marothy <sven@physto.se>
+
+ * java/awt/Font.java
+ Fixed comments.
+ (pointSize): New field.
+ (Font): Set size fields.
+ (getSize, getSize2D): Return size fields.
+
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paint): Check if clip == null and if so set it to the component's
+ bounds.
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java
+ (getClipBounds): Added null check so that null is returned when
+ clip == null, instead of throwing an NPE while accessing
+ null.getBounds2D().
+
+2005-09-24 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+ (Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit): Replace deprecated
+ gtk colormap stuff.
+
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paint): Activate double buffering if it is not already activated.
+ (paintImmediately2): Prepare a component graphics object here and
+ call paintDoubleBuffered with this.
+ (paintDoubleBuffered): Changed to work nicely with the new paint()
+ and paintImmediately2() methods.
+
+2005-09-24 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Added font default for
+ FormattedTextField.font. Solves an NPE that was caused by a null
+ font on a JFormattedTextField.
+
+2005-09-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultComboBoxModel.java
+ (addElement): always fire event for interval added, and call
+ setSelectedItem() if this is the first item.
+
+2005-09-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultComboBoxModel.java: updated API docs all over.
+
+2005-09-24 Sven de Marothy <sven@physto.se>
+
+ * java/awt/FontMetrics.java
+ (getMaxCharBounds, hasUniformLineMetrics): New methods.
+
+2005-09-24 Sven de Marothy <sven@physto.se>
+
+ * gnu/javax/imageio/bmp/BMPDecoder.java,
+ * gnu/javax/imageio/bmp/BMPImageReaderSpi.java,
+ * gnu/javax/imageio/bmp/DecodeBF32.java,
+ * gnu/javax/imageio/bmp/DecodeRGB8.java,
+ * gnu/javax/imageio/bmp/BMPException.java,
+ * gnu/javax/imageio/bmp/BMPInfoHeader.java,
+ * gnu/javax/imageio/bmp/DecodeRGB1.java,
+ * gnu/javax/imageio/bmp/DecodeRLE4.java,
+ * gnu/javax/imageio/bmp/BMPFileHeader.java,
+ * gnu/javax/imageio/bmp/DecodeRGB24.java,
+ * gnu/javax/imageio/bmp/DecodeRLE8.java,
+ * gnu/javax/imageio/bmp/BMPImageReader.java,
+ * gnu/javax/imageio/bmp/DecodeBF16.java,
+ * gnu/javax/imageio/bmp/DecodeRGB4.java:
+ New files.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java
+ (setFont): If font == null, simply return. Avoids a NPE.
+
+2005-09-23 Sven de Marothy <sven@physto.se>
+
+ * java/io/OutputStreamWriter.java:
+ (OutputStreamWriter): Added missing constructors.
+
+2005-09-23 Lillian Angel <langel@redhat.com>
+
+ * java/awt/Component.java
+ (getFont): Should return null, not a default font.
+ * javax/swing/ToolTipManager.java
+ (showTip): Called revalidate currentTip before painted, and
+ called validate on JDialog toolTip.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SwingUtilities.java
+ (layoutCompoundLabel): Removed debug code.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JScrollPane.java
+ (setHorizontalScrollBar): Removed handling of listeners on the model.
+ This is now done in the BasicScrollPaneUI.
+ (setHorizontalScrollBarPolicy): Added revalidate call.
+ (setVerticalScrollBar): Removed handling of listeners on the model.
+ This is now done in the BasicScrollPaneUI.
+ (setVerticalScrollBarPolicy): Added revalidate call.
+ (setViewport): Removed handling of listeners on the viewport.
+ This is now done in the BasicScrollPaneUI.
+ (createScrollListener): Removed unnecessary and undocumented method.
+ The functionality of this method is moved to BasicScrollPaneUI
+ as specified.
+ (JScrollPane): Removed initialization of removed listener.
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (HSBChangeListener): New inner class.
+ (VSBChangeListener): New inner class.
+ (ViewportChangeHandler): New inner class.
+ (PropertyChangeHandler): New inner class.
+ (MouseWheelHandler): New inner class.
+ (installUI): Also call installListeners.
+ (installListeners): New method. Initializes the listeners on the
+ scrollpane.
+ (createHSBChangeListener): New method.
+ (createVSBChangeListener): New method.
+ (createViewport): New method.
+ (createPropertyChangeListener): New method.
+ (uninstallUI): Also call uninstallListeners.
+ (uninstallListeners): New method.
+ (syncScrollPaneWithViewport): New method.
+ (updateColumnHeader): New method.
+ (updateRowHeader): New method.
+ (updateScrollBarDisplayPolicy): New method.
+ (updateViewport): New method.
+
+2005-09-23 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JTextField.java: Reformatted and added API docs.
+
+2005-09-23 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (showTip): Set lightWeightPopupEnabled to default.
+ Validated and repainted new containerPanel and
+ repainted toolTipWindow and repainted currentTip. The
+ toolTips paint well now.
+
+2005-09-23 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (paintRecursive): Changed clip to be the visible
+ rectangle of the view.
+
+2005-09-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/DefaultComboBoxModel.java
+ (DefaultComboBoxModel(Object[])): set selected item,
+ (DefaultComboBoxModel(Vector): likewise,
+ (addElement): reimplemented,
+ (removeElementAt): update selected item,
+ (removeAllElements): clear selected item and fire correct event,
+ (setSelectedItem): update item always,
+ (getElementAt): return null for index out of bounds,
+ * javax/swing/plaf/metal/MetalComboBoxButton.java
+ (paintComponent): check for null selection.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ Added some deprecated and unused fields for binary compatibility.
+ (installListeners): Fixed method parameters.
+ (installUI): Call installListeners with fixed method parameters.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicPanelUI.java
+ (uninstallUI): New method.
+ (uninstallDefaults): New method.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ (MinimumHeight): New constant field.
+ (MinimumWidth): New constant field.
+ (minimumWidth): Removed unused field.
+ (minimumHeight): Removed unused field.
+ (installDefaults): Removed initializing of minimumSize and
+ minimumHeight.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Initialize OptionPane.minimumSize from
+ constant fields in BasicOptionPaneUI.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicMenuUI.java
+ (ChangeHandler): Added some deprecated and unused fields for
+ binary compatibility.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (deactivateFrame): New method.
+ (InternalFramePropertyChangeListener.propertyChange): Call
+ new deactivate() method instead of getDesktopManager.deactivate()
+
+2005-09-23 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #24022
+ * javax/swing/plaf/basic/BasicTreeUI.java
+ (paint): Took out unneeded code.
+
+2005-09-23 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #23529
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (mousepressed): Made delay shorted while pressing the arrow
+ button. This makes the scrollbar move more smoothly.
+ (mouseReleased): Reset the delay to the default, so single
+ clicks only move the scrollbar 1 unit. Also, when the
+ mouse is released, the scrollbar should move 1 unit.
+ (shouldScroll): Should not be able to scroll by block
+ when the mouse is in the thumbRect.
+ (mousePressed): Made delay shorted while pressing in the
+ scroll area. This makes the scrollbar move more smoothly.
+ (mouseReleased): Should move the scrollbar 1 block when the
+ mouse is released. Also, reset the timer to default delay.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicDesktopPaneUI.java
+ (installKeyboardActions): Call renamed method registerKeyboardActions.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicDesktopPaneUI.java
+ (registerKeyboardAction): Renamed this method to
+ registerKeyboardActions as specifie.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicListUI.java
+ (FocusHandler.repaintCellFocus): Marked protected instead of
+ package private as specified.
+ (KeyHandler.keyPressed): Call new methods selectNextIndex and
+ selectPreviousIndex instead of doing the work here.
+ (PropertyChangeHandler.propertyChange): Update the
+ updateLayoutStateNeeded field correctly.
+ (BasicListUI): Removed listener initialization. Moved this
+ to installListeners.
+ (installListeners): Initialize listeners here instead in the
+ constructor. Use the createXXXListener hooks instead of creating
+ the listeners directly.
+ (createFocusListener): New hook method for creating a focus listener.
+ (createListDataListener): New hook method for creating a list
+ data listener.
+ (createListSelectionListener): New hook method for creating a list
+ selection listener.
+ (createMouseInputListener): New hook method for creating a mouse
+ input listener.
+ (createPropertyChangeListener): New hook method for creating a
+ property change listener.
+
+2005-09-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java
+ (OptionDialogBorder): new class.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicColorChooserUI.java
+ (uninstallDefaultChoosers): New method.
+ (uninstallUI): Call uninstallDefaultChoosers.
+
+2005-09-23 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/SwingUtilities.java
+ (layoutCompoundLabel): Fix the case when verticalTextPosition=BOTTOM
+ and without icon. The label text slipped out of the view rectangle
+ in this case.
+
+2005-09-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (setCurrentTheme): throw exception if argument is null, improved API
+ docs.
+
+2005-09-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JPanel.java
+ (accessibleContext): Removed this unnecessary field. Use the
+ inherited field of the same name from JComponent instead.
+
+2005-09-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/UIManager.java
+ (static_initializer): Load MetalLookAndFeel only as fallback, if
+ the system property 'swing.defaultlaf' is not defined. Before
+ it has accidentally loaded the MetalLookAndFeel in all cases,
+ regardless of the property setting.
+
+2005-09-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paintChildren): If a child component is invisible, skip it.
+ Handle the (rare) case when no clip is set as if it's set to the
+ child component's bounds. These fixes should make Swing working
+ again as before.
+
+2005-09-22 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetResizable):
+ Replace deprecated gtk_window_set_policy with gtk_window_set_resizable.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkMenuPeer_delItem): Replace deprecated
+ gtk_container_children with gtk_container_get_children.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_nativeSetHelpMenu): Likewise.
+ (Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_delMenu): Likewise.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+ (Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap): Replace deprecated
+ gdk_pixmap_unref with g_object_unref.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked):
+ Replace deprecated gdk_cursor_destroy with gdk_cursor_unref.
+ (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent):
+ Replace deprecated gtk_container_children with
+ gtk_container_get_children.
+ (find_fg_color_widget): Replace deprecated macro GTK_IS_OPTION_MENU with
+ GTK_IS_COMBO_BOX.
+ (component_button_release_cb): Replace deprecated gdk_window_get_size
+ with gdk_drawable_get_size.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup):
+ Replace deprecated gtk_radio_button_group with
+ gtk_radio_button_get_group.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove): Likewise.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create): Replace deprecated
+ gtk_type_new with gtk_drawing_area_new.
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState): Replace deprecated
+ gdk_*_ref with g_object_ref.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II): Likewise.
+ Replace deprecated gdk_rgb_get_cmap with gdk_rgb_get_colormap.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage): Replace
+ deprecated gdk_*_ref with g_object_ref.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked): Likewise.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose): Replace deprecated
+ gdk_*_unref with g_object_unref.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea): Replace deprecated
+ gdk_window_copy_area with gdk_draw_drawable.
+ (Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor): Replace deprecated
+ gdk_color_alloc with gdk_colormap_alloc_color.
+
+2005-09-22 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/Utilities.java:
+ (getWordEnd): Implemented.
+ (getWordStart): Implemented.
+
+2005-09-22 Keith SEitz <keiths@redhat.com>
+
+ * gnu/classpath/jdwp/event/filters/StepFilter.java (StepFilter): Do not test
+ for null thread ID -- just test if it has not been garbage collected.
+ * gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java (ThreadOnlyFilter):
+ Likewise.
+
+2005-09-22 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JPopupMenu.java
+ (setVisible): Size of menu should always be the preferred
+ size. It was sometimes cutting of the accelerator.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java:
+ Increased defaultAcceleratorLabelGap field to 10, to
+ make menuItem more readable.
+
+2005-09-22 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/Utilities.java:
+ (getPreviousWord): Fixed incorrect logic. Use preceding() instead of
+ following(), previous() instead of next().
+
+2005-09-22 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * gnu/java/text/BaseBreakIterator.java:
+ (following): Don't restore old CharacterIterator index.
+
+2005-09-22 Tom Tromey <tromey@redhat.com>
+
+ * javax/swing/JList.java (AccessibleJList): New constructor.
+
+2005-09-22 Tom Tromey <tromey@redhat.com>
+
+ * java/net/ServerSocket.java (accept): Use correct security manager
+ call.
+
+2005-09-22 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/Utilities.java:
+ (getNextWord): Implemented.
+ (getPreviousWord): Implemented.
+
+2005-09-22 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/plaf/MetalLookAndFeel.java
+ (initComponentDefaults): Changed back to original
+ values.
+
+2005-09-22 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (showTip): Moved tooltip location adjustments to a
+ helper method.
+ (adjustLocation): New helper method.
+ * javax/swing/plaf/basic/BasicLookAndFeel.java
+ (initComponentDefaults): Fixed defaults for Table,
+ TableHeader, Tree to match JDK.
+ * javax/swing/plaf/MetalLookAndFeel.java
+ (initComponentDefaults): Fixed defaults for Table and
+ TableHeader to match JDK.
+ * javax/swing/plaf/basic/BasicToolTipUI.java
+ (defaultBorder): Removed, along with inner class. Not needed.
+ (installDefaults): Changed border to be the default border in
+ L&F.
+
+2005-09-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JSpinner.java
+ (ListEditor): New inner class. Provides an editor for the
+ SpinnerListModel.
+
+2005-09-22 Tom Tromey <tromey@redhat.com>
+
+ * java/io/FileWriter.java (FileWriter): Typo fix.
+
+2005-09-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JApplet.java
+ (accessibleContext): Made field protected as specified.
+ * javax/swing/JButton.java
+ (accessibleContext): Removed field. The inherited JComponents
+ accessibleContext field should be used instead.
+ * javax/swing/JLabel.java
+ (accessibleContext): Removed field. The inherited JComponents
+ accessibleContext field should be used instead.
+ * javax/swing/JRootPane.java
+ (JRootPane): Removed unnecessary setDoubleBuffered() call.
+
+2005-09-22 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/html/HTML.java:
+ (SYNTHETIC): Renamed variable SYNTETIC to SYNTHETIC.
+ (Tag): Changed comment for static Tag IMPLIED.
+
+2005-09-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JViewport.java
+ (JViewport): Initialize cached fields for blitting.
+ (setViewPosition): Repaint viewport.
+ (revalidate): Set damaged flag. Used for blitting.
+ (reshape): Likewise.
+ (paint): New method. Decide which paint method to use.
+ (computeBlit): New method. Computes the parameters for blitting.
+ (paintSimple): New method. Performs painting in simple mode.
+ (paintBackingStore): New method. Performs painting in backingstore
+ mode.
+ (paintBlit): New method. Performs painting in blit mode. For
+ now this falls back to backing store mode.
+ * javax/swing/plaf/basic/BasicViewportUI.java
+ (ChangeListener): Removed inner class.
+ (installDefaults): Load default for background color. Changed
+ signature to protected.
+ (installListeners): Removed method.
+ (uninstallDefaults): Changed signature to protected.
+ (installUI): Call installDefaults().
+ (uninstallUI): Call uninstallDefaults().
+ (getPreferredSize): Removed.
+ (paint): Removed.
+ (paintSimple): Removed.
+ (paintBackingStore): Removed.
+
+2005-09-22 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (AccessibleJComponent.addPropertyChangeListener): Partly omplemented.
+ (AccessibleJComponent.getAccessibleStateSet): Partly implemented.
+ (doubleBuffered): Default value of this field is true.
+ (paint): Moved double buffer painting stuff to separate method.
+ (paintChildren): Don't call into AWT painting code here. This allows
+ for a small optimization.
+ (paintImmediately): Don't go up to the parent window, try to start
+ painting on the nearest JRootPane if possible.
+ (paintImmediately2): New method. Actually performs repainting
+ on the repaint root.
+ (paintDoubleBuffered): New method. Performs painting using
+ a double buffer.
+ (paintSimple): New method. Performs painting without buffer.
+
+2005-09-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/filechooser/FileFilter.java: reformatted and added API
+ docs.
+
2005-09-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/classpath/ByteArray.java,
@@ -576,6 +6093,205 @@
* vm/reference/java/lang/VMPackage.java:
Fixed address within GPL.
+2005-09-21 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (showTip): Fixed location of tooltip. Sometimes
+ the ToolTip was being cut off.
+
+2005-09-21 Mark Wielaard <mark@klomp.org>
+
+ * gnu/classpath/ByteArray.java: Reindent boilerplate.
+
+2005-09-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/classpath/ByteArray.java,
+ * gnu/javax/crypto/DiffieHellmanImpl.java,
+ * gnu/javax/crypto/GnuDHPrivateKey.java,
+ * gnu/javax/crypto/RSACipherImpl.java:
+ Fixed address within GPL license.
+
+2005-09-21 Mark Wielaard <mark@klomp.org>
+
+ * lib/split-for-gcj.sh: Cut list to 3 package levels deep.
+
+2005-09-21 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/html/HTML.java:
+ (Tag): Changed name of IMPLIED Tag from "implied" to "p-implied" to
+ match the JDK.
+ * javax/swing/text/html/HTMLDocument.java:
+ (AdditionalComments): New field.
+
+2005-09-21 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/html/HTMLDocument.java:
+ (getBase): Implemented.
+ (setBase): Implemented.
+ (getPreservesUnknownTags): Implemented.
+ (setPreservesUnknownTags): Implemented.
+ (BlockElement): New class partially implemented.
+
+2005-09-21 Tom Tromey <tromey@redhat.com>
+
+ * java/awt/BorderLayout.java: Reverted field reordering.
+
+2005-09-21 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JTable.java
+ (distributeSpill): Fixed a NPE.
+ * javax/swing/ToolTipManager.java
+ (mouseExited): No need to do this stuff, removed code.
+ (showTip): Revalidating and repainting too much, removed.
+ (hideTip): Likewise.
+
+2005-09-21 Tom Tromey <tromey@redhat.com>
+
+ * java/awt/BorderLayout.java (invalidateLayout): Updated comment.
+ (setBounds): Likewise.
+ (MIN, MAX, PREF): Moved nearer top of file.
+ (getLayoutComponent): New methods.
+ (getConstraints): New method.
+ (vgap, hgap, north, south, east, west): Reordered fields to conform
+ to serialization spec.
+
+2005-09-21 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/html/HTMLDocument.java:
+ (LeafIterator): New class.
+ (getIterator): Implemented.
+ (Iterator): New abstract class.
+
+2005-09-21 Tom Tromey <tromey@redhat.com>
+
+ * java/math/BigDecimal.java (ZERO, ONE): Now public. Updated
+ javadoc.
+ (TEN): New constant.
+ * java/math/BigInteger.java (ZERO): Updated javadoc.
+ (ONE): Likewise.
+ (TEN): New constant.
+
+2005-09-21 Lillian Angel <langel@redhat.com>
+
+ Fixes Bug #23937
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ (propertyChange): When WANTS_INPUT_PROPERTY is changed,
+ the buttons should be updated.
+ (getButtons): Applied patch in bug report. Sets default
+ buttons.
+
+2005-09-21 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (showTip): Added code to move currentPoint to a new place.
+ (getGoodPoint): Removed, not needed.
+
+2005-09-21 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalFileChooserUI.java: new file (partial
+ implementation).
+
+2005-09-20 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JPopupMenu.java
+ (setVisible): If HeavyWeightPopup, setLightWeightPopupEnabled
+ is false.
+ * javax/swing/ToolTipManager.java
+ (showTip): Change so toolTips on lightWeightPopups are
+ added different than those on heavyWeightPopups.
+ (canToolTipFit): Removed. This is not needed/used.
+
+2005-09-20 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/ToolTipManager.java
+ (mouseMoved): Removed unneeded code. If the mouse
+ moves into another component, then mouseEntered would
+ do the same thing. Otherwise, it is not needed.
+ (showTip): Fixed so that the containerPanel is an
+ instance of Panel. Made code more efficent.
+ Tooltips were causing weird problems with the
+ JMenus.
+ (getGoodPoint): Fixed to return a better location.
+ * javax/swing/plaf/basic/BasicMenuBarUI.java
+ (mouseClicked): Fixed to prevent a NPE.
+
+2005-09-20 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/22906:
+ * gnu/java/net/protocol/jar/Connection.java (get): Added useCaches
+ argument.
+ (connect): Updated.
+
+2005-09-20 Tom Tromey <tromey@redhat.com>
+
+ * javax/print/DocFlavor.java (serialVersionUID): Fixed typo.
+
+2005-09-19 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/text/DefaultEditorKit.java:
+ (write): Partially Implemented and made slight correction to API docs.
+ * javax/swing/text/html/HTMLEditorKit.java:
+ (createDefaultDocument): Override parent method because we need to
+ return an HTMLDocument not a DefaultStyledDocument.
+
+2005-09-20 Roman Kennke <kennke@aicas.com>
+
+ Fixes PR #23900.
+ * javax/swing/JLayeredPane.java
+ (remove(int)): Removed repaint() call. This is unnecessary because
+ already triggered by Container.remove().
+ (remove(Component)): Removed this superfluous method. It's not
+ in the specs and the functionality is already in Container.
+ (paint): New method. Overridden in order to provide reasonable
+ painting for JLayeredPanes.
+
+2005-09-20 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (UpdateHandler): Renamed to PropertyChangeHandler. This name is
+ closer to the purpose of this class.
+ (PropertyChangeHandler.propertyChange): Delegate property change
+ to propertyChange hook method in the enclosing BasicTextUI.
+ (propertyChange): New protected method. This serves as a hook
+ for subclasses to handle property changes in the text component.
+ * javax/swing/plaf/basic/BasicTextFieldUI.java
+ (properyChange): Handle editable property here and adjust background
+ accordingly.
+
+2005-09-20 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/text/DefaultStyledDocument.java
+ (getParagraphElement): If the position argument is out of the
+ document's bounds, then the closest paragraph element must be
+ returned. This is fixed.
+
+2005-09-20 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (resizeAndRepaint): New protected method.
+
+2005-09-20 Tom Tromey <tromey@redhat.com>
+
+ * javax/xml/namespace/QName.java: Now Serializable.
+ (serialVersionUID): New field.
+ (qName, hashCode): Now transient.
+ (QName): Don't compute qName here.
+ (equals): Now final.
+ (hashCode): Simplified.
+ (toString): Compute qName here.
+
+2005-09-20 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/metal/MetalBorders.java
+ (getTextFieldBorder): This method must return an BorderUIResource
+ instance. Fixed.
+
+2005-09-20 Mark Wielaard <mark@klomp.org>
+
+ Reported by Martin Cordova <martin.cordova@gmail.com>
+ * native/jni/java-net/javanet.c (_javanet_accept): Throw
+ SocketTimeoutException on EAGAIN timeout.
+
2005-09-20 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/basic/BasicButtonUI.java
@@ -729,7 +6445,9 @@
cast. If acquireComponentForMouseEvent reveals we're going to
re-dispatch this event to ourselves (and loop infinitely), return. Also
replaced contentPane by glassPane as the source argument to
- SwingUtilities.convertMouseEvent since the glassPane is the real source.
+ SwingUtilities.convertMouseEvent since the glassPane is the real
+ source.
+
2005-09-19 David Gilbert <david.gilbert@object-refinery.com>
* javax/swing/plaf/basic/BasicArrowButton.java
@@ -4756,7 +10474,7 @@
(setReference): New method.
* gnu/classpath/jdwp/id/ObjectId.java (getObject): New method.
* gnu/classpath/jdwp/id/ReferenceTypeId.java (getType): New method.
- * gnu/classpath/jdwp/id/StringId.java (getString): New method.
+ * gnu/classpath/jdwp/id/StriNgId.java (getString): New method.
* gnu/classpath/jdwp/id/ThreadGroupId.java (getThreadGroup): New method.
* gnu/classpath/jdwp/id/ThreadId.java (getThread): New method.
@@ -16716,7 +22434,7 @@
gnu/java/locale/LocaleInformation_gu_IN.java,
gnu/java/locale/LocaleInformation_gv.java,
gnu/java/locale/LocaleInformation_gv_GB.java,
- gnu/java/locale/LocaleInformation_he.java,
+ gnujava/locale/LocaleInformation_he.java,
gnu/java/locale/LocaleInformation_he_IL.java,
gnu/java/locale/LocaleInformation_hi.java,
gnu/java/locale/LocaleInformation_hi_IN.java,
@@ -17926,7 +23644,7 @@
* java/util/logging/LogManager.java: Reformatted.
(readConfiguration): If a logger for a key is not found, create one.
-2005-02-16 Michael Koch <konqueror@gmx.de>
+2005-02-16
* scripts/checkstyle-config.xml: Activate JavadocStyle and
IllegalInstantiation tests.
diff --git a/INSTALL b/INSTALL
index 78f027825..c6ce1d1bc 100644
--- a/INSTALL
+++ b/INSTALL
@@ -79,6 +79,29 @@ Suggested Software
- texinfo 4.2 or higher.
+ For building the ALSA midi provider code you will need
+ ALSA. http://www.alsa-project.org.
+
+ For building the DSSI midi synthesizer provider code you will
+ need DSSI from http://dssi.sourceforge.net. This, in turn,
+ introduces many dependencies, including:
+
+ - liblo: the Lightweight OSC implementation
+ http://plugin.org.uk/liblo/
+
+ - LADSPA: Linux Audio Developer's Simple Plugin API
+ http://www.ladspa.org
+
+ - the JACK Audio Connection Kit: A low latency audio server
+ http://jackit.sourceforge.net
+
+ - libsndfile: an audio file I/O library
+ http://www.mega-nerd.com/libsndfile/
+
+ - fluidsynth: a real-time SoundFont 2 based soft-synth
+ http://www.fluidsynth.org/
+
+
This package was designed to use the GNU standard for configuration
and makefiles. To build and install do the following:
diff --git a/LICENSE b/LICENSE
index 240f834dd..273623b2c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -284,3 +284,17 @@ All these files are distributed under the following terms:
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in these Data Files or Software without prior
written authorization of the copyright holder.
+
+
+The file native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+contains two functions (get_port_default and set_control) derived from
+example code in the DSSI distribution (http://dssi.sourceforge.net).
+The original DSSI example code is distributed under the following
+terms:
+
+ Copyright 2004 Chris Cannam, Steve Harris and Sean Bolton.
+
+ Permission to use, copy, modify, distribute, and sell this software
+ for any purpose is hereby granted without fee, provided that the
+ above copyright notice and this permission notice are included in
+ all copies or substantial portions of the software.
diff --git a/NEWS b/NEWS
index 4d9185259..2eac895a4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,29 @@
+New for the subsequent release:
+
+* The java.net.HttpURLConnection implementation no longer buffers the
+ entire response body in memory. This means that response bodies
+ larger than available memory can now be handled.
+
+* The Andrew Watson, Vice President and Technical Director of the Object
+ Management Group, has officially assigned us 20 bit Vendor Minor Code Id:
+ 0x47430 ("GC") that will mark remote Classpath - specific system exceptions.
+ Obtaining the VMCID means that GNU Classpath now is a recogniseable type of
+ node in a highly interoperable CORBA world.
+
+* Classpath now includes the first working draft to support the RMI over
+ IIOP protocol. The current implementation is capable for remote invocations,
+ transferring various Serializables and Externalizables via RMI-IIOP protocol.
+ It can flatten graphs and, at least for the simple cases, is interoperable
+ with Sun's jdk 1.5.
+
+Runtime interface changes:
+
+* Changed implementation of VMClassLoader.getPackage(s) : new method
+ VMClassLoader.getBootPackages should be implemented by the vm, and sould
+ return a string array of boot package names ("java.lang", "java.net", ...).
+ Feedback from vm implementors for usability and relevance of the
+ getBootPackages method would be greatly appreciated.
+
New in release 0.18 (Sep 6, 2005)
* GNU JAWT implementation, the AWT Native Interface, which allows direct
diff --git a/configure.ac b/configure.ac
index 4f9ea2e91..d54e6d18a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,6 +103,32 @@ AC_ARG_ENABLE([xmlj],
AM_CONDITIONAL(CREATE_XMLJ_LIBRARY, test "x${COMPILE_XMLJ}" = xyes)
dnl -----------------------------------------------------------
+dnl ALSA code (enabled by default)
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE([alsa],
+ [AS_HELP_STRING(--disable-alsa,compile ALSA providers (enable by --enable-alsa) [default=yes])],
+ [case "${enableval}" in
+ yes) COMPILE_ALSA=yes ;;
+ no) COMPILE_ALSA=no ;;
+ *) COMPILE_ALSA=yes ;;
+ esac],
+ [AC_CHECK_HEADERS([alsa/asoundlib.h],COMPILE_ALSA=yes,COMPILE_ALSA=no)])
+AM_CONDITIONAL(CREATE_ALSA_LIBRARIES, test "x${COMPILE_ALSA}" = xyes)
+
+dnl -----------------------------------------------------------
+dnl DSSI code (enabled by default)
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE([alsa],
+ [AS_HELP_STRING(--disable-dssi,compile DSSI providers (enable by --enable-dssi) [default=yes])],
+ [case "${enableval}" in
+ yes) COMPILE_DSSI=yes ;;
+ no) COMPILE_DSSI=no ;;
+ *) COMPILE_DSSI=yes ;;
+ esac],
+ [AC_CHECK_HEADERS([dssi.h],COMPILE_DSSI=yes,COMPILE_DSSI=no)])
+AM_CONDITIONAL(CREATE_DSSI_LIBRARIES, test "x${COMPILE_DSSI}" = xyes)
+
+dnl -----------------------------------------------------------
dnl GTK native peer (enabled by default)
dnl -----------------------------------------------------------
AC_ARG_ENABLE([gtk-peer],
@@ -150,6 +176,35 @@ AC_ARG_ENABLE([qt-peer],
[COMPILE_QT_PEER=no])
AM_CONDITIONAL(CREATE_QT_PEER_LIBRARIES, test "x${COMPILE_QT_PEER}" = xyes)
+
+dnl -----------------------------------------------------------
+dnl Sets the native libraries installation dir
+dnl -----------------------------------------------------------
+AC_ARG_WITH([native-libdir],
+ [AS_HELP_STRING(--with-native-libdir,sets the installation directore for native libraries [default='${libdir}/${PACKAGE}'])],
+ [
+ nativelibdir=${withval}
+ ],
+ [
+ nativelibdir='${libdir}/${PACKAGE}'
+ ])
+
+AC_SUBST(nativelibdir)
+
+dnl -----------------------------------------------------------
+dnl Sets the Java library installation dir.
+dnl -----------------------------------------------------------
+AC_ARG_WITH([glibj-dir],
+ [AS_HELP_STRING(--with-glibj-dir,sets the installation directory for glibj.zip [default='${libdir}/${PACKAGE}'])],
+ [
+ glibjdir=${withval}
+ ],
+ [
+ glibjdir='${datadir}/${PACKAGE}'
+ ])
+
+AC_SUBST(glibjdir)
+
dnl -----------------------------------------------------------
dnl Regenerate headers at build time (disabled by default)
dnl -----------------------------------------------------------
@@ -242,6 +297,7 @@ if test "x${COMPILE_JNI}" = xyes; then
[AC_MSG_RESULT(no)])])])
AC_C_CONST
+ AC_C_ATTRIBUTE
dnl See if we HAVE_ICONV, how ICONV_CONST is set and LTLIBICONV
AM_ICONV
@@ -297,30 +353,66 @@ if test "x${COMPILE_JNI}" = xyes; then
dnl Check for AWT related Qt4
if test "x${COMPILE_QT_PEER}" = xyes; then
- PKG_CHECK_MODULES(QT, QtGui >= 4.0.1)
- dnl Check needed because in some cases the QtGui includedir
- dnl doesn't contain the subsystem dir.
- QT_INCLUDE_DIR=$($PKG_CONFIG --variable=includedir QtGui)
- EXTRA_QT_INCLUDE_DIR="$QT_INCLUDE_DIR/Qt"
- AC_CHECK_FILE([$QT_INCLUDE_DIR/QWidget],
- AC_MSG_NOTICE([No extra QT_INCLUDE_DIR needed]),
- AC_CHECK_FILE([$EXTRA_QT_INCLUDE_DIR/QWidget],
- QT_CFLAGS="$QT_CFLAGS -I$EXTRA_QT_INCLUDE_DIR",
- AC_MSG_WARN([QWidget not found])))
- AC_MSG_NOTICE([Set QT_CFLAGS... $QT_CFLAGS])
- AC_CHECK_PROG(MOC, [moc], [moc])
- AC_SUBST(QT_CFLAGS)
- AC_SUBST(QT_LIBS)
+ PKG_CHECK_MODULES(QT, QtGui >= 4.0.1, HAVE_QT4="yes", HAVE_QT4="no")
+ if test "x$HAVE_QT4" = "xyes"; then
+ dnl Check needed because in some cases the QtGui includedir
+ dnl doesn't contain the subsystem dir.
+ QT_INCLUDE_DIR=$($PKG_CONFIG --variable=includedir QtGui)
+ EXTRA_QT_INCLUDE_DIR="$QT_INCLUDE_DIR/Qt"
+ AC_CHECK_FILE([$QT_INCLUDE_DIR/QWidget],
+ AC_MSG_NOTICE([No extra QT_INCLUDE_DIR needed]),
+ AC_CHECK_FILE([$EXTRA_QT_INCLUDE_DIR/QWidget],
+ QT_CFLAGS="$QT_CFLAGS -I$EXTRA_QT_INCLUDE_DIR",
+ AC_MSG_WARN([QWidget not found])))
+ AC_CHECK_PROG(MOC, [moc], [moc])
+ fi
+ if test "x$HAVE_QT4" = "xno"; then
+ AC_MSG_NOTICE([Looking for QT_CFLAGS and QT_LIBS without pkg-config])
+ case "$host_os" in
+ darwin*)
+ AC_ARG_WITH([qt4dir],
+ [AS_HELP_STRING([--with-qt4dir=DIR],
+ [Qt4 installation directory used for OS-X.
+ For other systems use pkg-config.])],
+ [QT4DIR=$withval]
+ )
+ if test x"$QT4DIR" = x ; then
+ AC_MSG_ERROR([*** No path for Qt4 --with-qt4dir option given])
+ fi
+ AC_MSG_RESULT([QT4DIR... $QT4DIR])
+ AC_CHECK_PROG(MOC, [moc], [$QT4DIR/bin/moc], [], $QT4DIR/bin)
+ if test x"$MOC" = x; then
+ AC_MSG_ERROR([*** This is not the right Qt installation])
+ fi
+ QT_CFLAGS="-F$QT4DIR/lib -I$QT4DIR/lib/QtCore.framework/Headers"
+ QT_CFLAGS="$QT_CFLAGS -I$QT4DIR/lib/QtGui.framework/Headers"
+ QT_LIBS="-Xlinker -F$QT4DIR/lib -Xlinker -framework -Xlinker QtCore"
+ QT_LIBS="$QT_LIBS -Xlinker -framework -Xlinker QtGui"
+ ;;
+ *)
+ AC_MSG_ERROR([*** Please check PKG_CONFIG_PATH or the version
+ of your installed Qt4 installation.])
+ ;;
+ esac
fi
+ AC_MSG_NOTICE([Set QT_CFLAGS... $QT_CFLAGS])
+ AC_SUBST(QT_CFLAGS)
+ AC_SUBST(QT_LIBS)
+fi
if test "x${enable_gtk_cairo}" = xyes; then
PKG_CHECK_MODULES(CAIRO, cairo >= 0.5.0)
- PKG_CHECK_MODULES(PANGOFT2, pangoft2)
fi
+
+ PKG_CHECK_MODULES(PANGOFT2, pangoft2)
+ PKG_CHECK_MODULES(FREETYPE2, freetype2)
+
AC_SUBST(CAIRO_LIBS)
AC_SUBST(CAIRO_CFLAGS)
AC_SUBST(PANGOFT2_LIBS)
AC_SUBST(PANGOFT2_CFLAGS)
+ AC_SUBST(FREETYPE2_LIBS)
+ AC_SUBST(FREETYPE2_CFLAGS)
fi
CLASSPATH_WITH_JAVAH
@@ -489,6 +581,8 @@ native/jni/java-util/Makefile
native/jni/gtk-peer/Makefile
native/jni/qt-peer/Makefile
native/jni/xmlj/Makefile
+native/jni/midi-alsa/Makefile
+native/jni/midi-dssi/Makefile
native/target/Makefile
native/target/Linux/Makefile
native/target/generic/Makefile
@@ -497,7 +591,9 @@ scripts/Makefile
scripts/classpath.spec
lib/Makefile
lib/gen-classlist.sh
+lib/copy-vmresources.sh
examples/Makefile
examples/Makefile.jawt])
AC_CONFIG_COMMANDS([gen-classlist],[chmod 755 lib/gen-classlist.sh])
+AC_CONFIG_COMMANDS([copy-vmresources],[chmod 755 lib/copy-vmresources.sh])
AC_OUTPUT
diff --git a/doc/www.gnu.org/corba.wml b/doc/www.gnu.org/corba.wml
new file mode 100644
index 000000000..cb9d7c58d
--- /dev/null
+++ b/doc/www.gnu.org/corba.wml
@@ -0,0 +1,37 @@
+#include "include/layout.wml"
+
+<subject "GNU Classpath CORBA interoperability page">
+
+<box>
+
+<boxtitle>GNU Classpath::Object management group</boxtitle>
+<boxitem>
+This page is referenced from the official
+<a href="http://doc.omg.org/vendor-tags">OMG Vendor tag list</a>,
+maintained by the <a href = "http://www.corba.org/">OMG</a>.
+It is is designed to help programmers debugging interoperation
+with our ORB.
+</boxitem>
+
+<boxtitle>GNU Classpath::CORBA interoperability</boxtitle>
+<boxitem>
+<ol>
+<li><a href="http://developer.classpath.org/mediation/CorbaInteroperability">
+Interoperability information (system exception minor codes, etc).</a></li>
+<li><a href="http://developer.classpath.org/doc/">GNU Classpath API Specification</a></li>
+<li><a href="bugs.html">Bug database.</a></li>
+<li>GNU Classpath CORBA vs:
+<a href="http://www.kaffe.org/~stuart/japi/htmlout/h-jdk12-classpath.html">JDK 1.2</a>
+<a href="http://www.kaffe.org/~stuart/japi/htmlout/h-jdk13-classpath.html">JDK 1.3</a>
+<a href="http://www.kaffe.org/~stuart/japi/htmlout/h-jdk14-classpath.html">JDK 1.4</a>
+ (updated nightly)</li>
+<li><a href="http://www.gnu.org/software/classpath/classpath.html">Project home page</a></li>
+</ol>
+Registered information
+<ul>
+<li>GNU Classpath Vendor Minor Code Id (VMCID) is 0x47430xxx
+("GC\x00\x00" - "GC\x0f\xff").</li>
+</ul>
+</boxitem>
+
+</box>
diff --git a/doc/www.gnu.org/include/layout.wml b/doc/www.gnu.org/include/layout.wml
index a82849205..485b98601 100644
--- a/doc/www.gnu.org/include/layout.wml
+++ b/doc/www.gnu.org/include/layout.wml
@@ -116,7 +116,7 @@
<menuitem><createlink name="CVS" url="http://savannah.gnu.org/cvs/?group=classpath"></menuitem>
<menutitle>Development</menutitle>
-<menuitem><createlink name="Tasks" url="tasks.html"></menuitem>
+<menuitem><createlink name="Tasks" url="http://developer.classpath.org/mediation/ClasspathOpenTasks"></menuitem>
<menuitem><createlink name="Docs" url="docs/docs.html"></menuitem>
<menuitem><createlink name="Testing" url="benchmarks.html#testing"></menuitem>
<menuitem><createlink name="Benchmarks" url="benchmarks.html#benchmarks"></menuitem>
diff --git a/doc/www.gnu.org/tasks.wml b/doc/www.gnu.org/tasks.wml
index 00959bd9a..34e36512f 100755
--- a/doc/www.gnu.org/tasks.wml
+++ b/doc/www.gnu.org/tasks.wml
@@ -1,326 +1,14 @@
-#include "include/layout.wml"
+<html>
+<head>
+<title>GNU Classpath Tasklist - GNU Project - Free Software Foundation (FSF)</title>
+<META HTTP-EQUIV="Refresh"
+ CONTENT="0; URL=http://developer.classpath.org/mediation/ClasspathOpenTasks">
+</head>
+<body>
+This page has moved. If your browser doesn't automatically redirect to
+its new location, click
+<a href="http://developer.classpath.org/mediation/ClasspathOpenTasks">
+http://developer.classpath.org/mediation/ClasspathOpenTasks</a>.
+</body>
+</html>
-##
-#
-# Special Tags
-#
-
-# <task
-# title="task title"
-# contact="contact person"
-# skills="..."
-# estimation="..."
-# >
-# ... task description ...
-# </task>
-
-
-
-# the task counter
-#
-<set-var __TASKSEQCNT=1>
-
-<define-tag task-section endtag=required>
- <preserve name>
- <set-var %attributes>
-{#TASKINDEX#:
- <boxitem>
- <!---boxtitle--->
- <strong><get-var __TASKSEQCNT>. <get-var name></strong> <br>
- <!---/boxtitle--->
-:#TASKINDEX#}
- <boxtitle><get-var __TASKSEQCNT>. <get-var name></boxtitle>
- <set-var __TASKCNT=1>
- %body
-{#TASKINDEX#:
- </boxitem>
- <br>
-:#TASKINDEX#}
- <increment __TASKSEQCNT>
- <restore name>
-</define-tag>
-
-<define-tag task endtag=required>
-<preserve title>
-<preserve contact>
-<preserve skills>
-<preserve estimation>
-<set-var %attributes>
-{#TASKINDEX#:
- <!---strong--><a href="tasks.html#task<get-var __TASKSEQCNT>_<get-var __TASKCNT>"><get-var __TASKSEQCNT>.<get-var __TASKCNT> <get-var title></a><!---/strong--> (<get-var estimation>)<br>
-:#TASKINDEX#}
- <boxitem>
- <h3><a name="task<get-var __TASKSEQCNT>_<get-var __TASKCNT>"><get-var __TASKSEQCNT>.<get-var __TASKCNT> <get-var title></a></h3>
- <table border="0">
- <tr><td valign="top"><strong>Description:</strong></td><td>%body</td></tr>
- <tr><td><strong>Skills:</strong></td><td><get-var skills></td></tr>
- <tr><td><strong>Estimated time:</strong></td><td><get-var estimation></td></tr>
- <tr><td><strong>Contact person:</strong></td><td><get-var contact></td></tr>
- </table>
- </boxitem>
-<increment __TASKCNT>
-<restore estimation>
-<restore skills>
-<restore contact>
-<restore title>
-
-</define-tag>
-
-
-<define-tag sb>
- Sascha Brawer
-</define-tag>
-<define-tag mw>
- Mark Wielaard
-</define-tag>
-<define-tag pr>
- Patrik Reali
-</define-tag>
-<define-tag cm>
- Casey Marshall
-</define-tag>
-<define-tag dt>
- Dalibor Topic
-</define-tag>
-<define-tag mk>
- Michael Koch
-</define-tag>
-
-<set-var last-modified-author="prk">
-
-<subject "GNU Classpath Tasklist">
-
-<h1>GNU Classpath Tasklist</h1>
-
-<box>
-
-<boxitem>
-This list is a collection of tasks for helping GNU Classpath's progress. They are a good starting point if you would like to help in producing a complete and high-quality free Java implementation.
-
-<p>Another source of inspiration are GNU Classpath's <createlink name="task list" url="http://savannah.gnu.org/pm/?group=classpath"> and <createlink name="patch list" url="http://savannah.gnu.org/patch/?group=classpath"> on Savannah, though these are usually meant for the project members.
-</boxitem>
-
-<boxtitle>Index</boxtitle>
-{#TASKINDEX#}
-
-
-
-<task-section name="Graphics">
-<task
- title="javax.imageio"
- estimation="2 weeks"
- skills=""
- contact="<sb> or <mk>"
->
-Write an implementation of the javax.imageio framework.
-</task>
-
-<task
- title="Constructive Area Geometry"
- estimation="6 weeks (?)."
- skills="Computational geometry skills"
- contact="<sb>"
->
-Implement java.awt.geom.Area. This would be useful for some
-graphics applications.
-</task>
-
-<task
- title="Composite Contexts"
- estimation="2 days for each operator"
- skills="It helps if you are familiar with the java.awt.image framework."
- contact="<sb>"
->
-Implement some CompositeContexts for Porter/Duff operators on raster
-images. This would be useful for supporting 2D graphics. See
-java.awt.AlphaComposite and its createContext method.
-</task>
-
-</task-section>
-
-<task-section name="CORBA">
-<task
- title="Help with CORBA implementation"
- estimation="This depends on the sub-task you pick."
- skills="Know or be ready to read the OMG documentation."
- contact="Audrius Meskauskas"
->
-The CORBA implementation in the Classpath project is
-now a working but incomplete prototype. A number of CORBA
-related tasks are available. If you are not a CORBA expert, you should be ready
-to learn by reading the <createlink name="OMG specifications"
-url="http://www.omg.org/cgi-bin/doc?formal/04-03-12"> and probably by writing some
-relatively simple classes.
-</task>
-</task-section>
-
-<task-section name="Testing">
-<task
- title="Make Mauve an application"
- estimation=""
- skills=""
- contact="<pr>"
->
-On some environments, it is not possible to run shell scripts
-because there is no shell. Make the Mauve test suite a self-contained
-application (one big JAR file).
-</task>
-
-<task
- title="Write Mauve tests"
- estimation=""
- skills=""
- contact="<mw>"
->
-Write Mauve tests.
-</task>
-
-<task
- title="Mauve tests for javax.image.io"
- estimation="1 week"
- skills=""
- contact="<sb>"
->
-<p>Write Mauve tests for reading in images. You could use the test images
-at libpng.org and write Mauve testlets that load each image from
-a file. Compute a hash (such as SHA-1) over the contents of the
-DataBuffer. If the hash matches, the test succeeds.
-</p><p>
-Note that we don't have javax.imageio yet, so you'd have to develop
-this with the Sun JDK.
-</p>
-</task>
-
-<task
- title="Generator for Mauve tests"
- estimation="2 weeks (prototype) + 2 weeks (tuning)"
- skills=""
- contact="<dt>"
->
-Write a program which automatically generates basic Mauve tests.
-
-
-</task>
-
-</task-section>
-
-<task-section name="Automation">
-
-<task
- title="Script for running regression tests"
- estimation="1 week"
- skills="???"
- contact=""
->
-Write a script that once a night checks out Classpath from cvs,
-compiles it, runs the Mauve test suite (also from cvs) on it
-using some free JVM (e.g. Kissme), and posts the results to
-some web site. For comparison, it would be very helpful if the
-same Mauve testlets were also run with a current Sun JVM.
-</task>
-
-<task
- title="Integrate Classpath testsuite into Mauve"
- estimation=""
- skills=""
- contact="<mw>"
->
-Classpath has a rather small number of tests in the subdirectories
-test/ and testsuite/. Look through these tests and check whether the
-same functionality is already tested by Mauve. If not, write a
-Mauve testlet and submit it to mauve-patches@sources.redhat.com <mailto:mauve-patches@sources.redhat.com>.
-The goal is to remove the test suite from Classpath.
-</task>
-
-
-<task
- title="Script for running Japitools"
- estimation="1 week"
- skills=""
- contact="???"
->
-Write a script that once a night checks out Classpath from cvs,
-runs Japitools on it, and posts the results on some web site.
-</task>
-
-<task
- title="Script for running gjdoc"
- estimation="1 week"
- skills=""
- contact=""
->
-Write a script that once a night checks out Classpath from cvs,
-runs gjdoc on it, and posts the generated documentation on some
-web site. While you're at it, fix gjdoc so it copies embedded
-documentation images (classpath-tools support request #102205).
-</task>
-
-<task
- title="JAR file verification"
- estimation=""
- skills=""
- contact="<mw>"
->
-</task>
-</task-section>
-
-<task-section name="Native stuff">
-
-<task
- title="Libiconv Service Provider for java.nio.charset"
- estimation="2 weeks"
- skills=""
- contact=""
->Write a service provider for java.nio.charset that uses the
-libiconv library for converting character encodings to and
-from UTF-16. This would be a first step for replacing
-gnu.java.io.EncodingManager by the java.nio.charset framework,
-which is richer and not specific to Classpath.
-</task>
-</task-section>
-
-<task-section name="Security">
-
-<task
- title="Security Audit"
- estimation=""
- skills=""
- contact=""
->We need to make a pass over the Classpath Java source, making sure
-that all required calls to the SecurityManager are in place. At the same
-time we need to ensure that there is no way to get around
-SecurityManager by directly calling code in gnu.*.
-</task>
-
-<task
- title="Security Testing"
- estimation=""
- skills=""
- contact=""
->We need Mauve tests for all the calls to SecurityManager.
-Additionally, enabling a security manager will probably reveal
-code in Classpath that needs to be wrapped in AccessController.doPrivileged().
-</task>
-
-</task-section>
-
-<task-section name="Related Projects">
-<task
- title="Help GNU Crypto"
- estimation=""
- skills=""
- contact="<cm>"
->
-</task>
-<task
- title="Help Classpath-x"
- estimation=""
- skills=""
- contact=""
->
-??? (maybe this should be more specific, e.g. "Write an
-IMAP plug-in for javax.mail on top of inetlib" (if they want
-this at all)
-</task-section>
-
-</box>
diff --git a/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java b/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
index b4a37720f..fb5ebdbb5 100644
--- a/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
+++ b/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
@@ -73,7 +73,7 @@ import org.omg.CosNaming.NamingContextHelper;
*/
public class Demo
{
- public static void main(final String[] args)
+ public static void main(String[] an_args)
{
// We create the following naming graph:
// <ROOT CONTEXT>
@@ -90,6 +90,8 @@ public class Demo
System.out.println("Starting the GNU Classpath " +
"built-in transient naming service"
);
+
+ final String[] args = an_args;
new Thread()
{
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
index 85f233a1d..f53609cf7 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/Demo.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication;
+import java.io.File;
+
import gnu.classpath.examples.CORBA.SimpleCommunication.communication.DirectTest;
import gnu.classpath.examples.CORBA.SimpleCommunication.communication.RequestTest;
@@ -61,23 +63,34 @@ public class Demo
{
public static void main(final String[] args)
{
+ File ior = new File("IOR.txt");
+ if (ior.exists())
+ ior.delete();
+
// Start the server.
new Thread()
{
public void run()
{
- comServer.start_server(args);
+ DemoServer.start_server(args);
}
}.start();
- System.out.println("Waiting for three seconds for the server to start...");
-
- // Pause some time for the server to start.
- try {
- Thread.sleep(3000);
- }
- catch (InterruptedException ex) {
- }
+ System.out.print("Waiting for the server to start ");
+ while (!ior.exists())
+ {
+ // Pause some time for the server to start.
+ try
+ {
+ Thread.sleep(200);
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ System.out.print(".");
+ }
+ System.out.println("ok.");
+ System.out.println();
// Test the stream oriented communication.
DirectTest.main(args);
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java
index d4e0c56b2..d7b1a7771 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/comServer.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/DemoServer.java
@@ -1,4 +1,4 @@
-/* comServer.java --
+/* DemoServer.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication;
-import gnu.classpath.examples.CORBA.SimpleCommunication.communication.comServant;
+import gnu.classpath.examples.CORBA.SimpleCommunication.communication.DemoServant;
import org.omg.CORBA.ORB;
@@ -47,7 +47,7 @@ import java.io.PrintStream;
/**
* This is the server class that handles the client requests,
- * delegating the functionality to the {@link comServant}.
+ * delegating the functionality to the {@link DemoServant}.
*
* When starting, the server writes the IOR.txt file into the current
* folder. With the information, stored in this file, the server
@@ -62,7 +62,7 @@ import java.io.PrintStream;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class comServer
+public class DemoServer
{
public static void main(String[] args)
@@ -78,7 +78,7 @@ public class comServer
final ORB orb = org.omg.CORBA.ORB.init(args, null);
// Create the servant and register it with the ORB.
- comServant tester = new comServant();
+ DemoServant tester = new DemoServant();
orb.connect(tester);
// Storing the IOR reference.
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java
index 08d1759d8..c07b77b17 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comServant.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoServant.java
@@ -1,4 +1,4 @@
-/* comServant.java --
+/* DemoServant.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,12 +45,6 @@ import org.omg.CORBA.DoubleHolder;
import org.omg.CORBA.ShortHolder;
import org.omg.CORBA.StringHolder;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.PrintStream;
-
/**
* This class handles the actual server functionality in this test
* application. When the client calls the remote method, this
@@ -62,8 +56,8 @@ import java.io.PrintStream;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class comServant
- extends _comTesterImplBase
+public class DemoServant
+ extends _DemoTesterImplBase
{
/**
* The field, that can be set and checked by remote client.
@@ -129,7 +123,7 @@ public class comServant
/**
* Accept and return the structures.
*/
- public returnThis passStructure(passThis in_structure)
+ public StructureToReturn passStructure(StructureToPass in_structure)
{
System.out.println("SERVER: ***** Transferring structures");
System.out.println("SERVER: Received " + in_structure.a + ":" +
@@ -137,7 +131,7 @@ public class comServant
);
// Create and send back the returned structure.
- returnThis r = new returnThis();
+ StructureToReturn r = new StructureToReturn();
r.c = in_structure.a + in_structure.b;
r.n = 555;
r.arra = new int[] { 11, 22, 33 };
@@ -147,14 +141,14 @@ public class comServant
/**
* Pass and return the tree structure
*/
- public void passTree(nodeHolder tree)
+ public void passTree(TreeNodeHolder tree)
{
System.out.println("SERVER: ***** Transferring tree");
StringBuffer b = new StringBuffer();
// This both creates the tree string representation
- // and changes the node names.
+ // and changes the TreeNode names.
getImage(b, tree.value);
System.out.println("SERVER: The tree was: " + b + ", returning changed.");
}
@@ -190,11 +184,11 @@ public class comServant
*
* @param parameter specifies which exception will be thrown.
*
- * @throws ourUserException for the non negative parameter.
+ * @throws WeThrowThisException for the non negative parameter.
* @throws BAD_OPERATION for the negative parameter.
*/
public void throwException(int parameter)
- throws ourUserException
+ throws WeThrowThisException
{
System.out.println("SERVER: ***** Testing exceptions");
if (parameter > 0)
@@ -202,7 +196,7 @@ public class comServant
System.out.println("SERVER: Throwing the user exception, " +
"specific field = "+parameter
);
- throw new ourUserException(parameter);
+ throw new WeThrowThisException(parameter);
}
else
{
@@ -215,12 +209,12 @@ public class comServant
/**
* Visit all tree nodes, getting the string representation
- * and adding '++' to the node names.
+ * and adding '++' to the TreeNode names.
*
* @param b the buffer to collect the string representation.
- * @param n the rott tree node.
+ * @param n the rott tree TreeNode.
*/
- private void getImage(StringBuffer b, node n)
+ private void getImage(StringBuffer b, TreeNode n)
{
b.append(n.name);
n.name = n.name + "++";
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java
index 495807eb9..f3766f325 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester.java
@@ -1,4 +1,4 @@
-/* comTester.java --
+/* DemoTester.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,12 +45,12 @@ import org.omg.CORBA.StringHolder;
/**
* The interface of our remote object. Some IDL compiles split it
- * into "comTester" and "comTesterOperations", but we do not see
+ * into "DemoTester" and "comTesterOperations", but we do not see
* much sense in doing this here.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public interface comTester
+public interface DemoTester
{
/**
* Passes wide (UTF-16) string and narrow (ISO8859_1) string.
@@ -77,14 +77,14 @@ public interface comTester
/**
* Passes and returns the structures.
*/
- returnThis passStructure(passThis in_structure);
+ StructureToReturn passStructure(StructureToPass in_structure);
/**
* Pass and return the tree structure
*
- * @param tree the root node of the tree.
+ * @param tree the root TreeNode of the tree.
*/
- void passTree(nodeHolder tree);
+ void passTree(TreeNodeHolder tree);
/**
* Just prints the "Hello" message.
@@ -102,10 +102,10 @@ public interface comTester
void theField(int newTheField);
/**
- * Throws either 'ourUserException' with the 'ourField' field
+ * Throws either 'WeThrowThisException' with the 'ourField' field
* initialised to the passed positive value
* or system exception (if the parameter is zero or negative).
*/
void throwException(int parameter)
- throws ourUserException;
+ throws WeThrowThisException;
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
index 5cf372b26..732b00cfb 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/DirectTest.java
@@ -57,7 +57,7 @@ import java.io.IOException;
* where the program has been started.
*
* The IOR.txt file is written by the server
- * {@link gnu.classpath.examples.CORBA.SimpleCommunication.comServer}.
+ * {@link gnu.classpath.examples.CORBA.SimpleCommunication.DemoServer}.
* The server should be reachable over Internet, unless blocked by
* security tools.
*
@@ -83,7 +83,7 @@ public class DirectTest
/**
* The invocation target.
*/
- comTester object;
+ DemoTester object;
/**
* Get the object reference.
@@ -102,7 +102,7 @@ public class DirectTest
String ior = new String(c);
DirectTest we = new DirectTest();
- we.object = (comTester) orb.string_to_object(ior);
+ we.object = (DemoTester) orb.string_to_object(ior);
we.Demo();
orb.shutdown(false);
}
@@ -199,11 +199,11 @@ public class DirectTest
{
System.out.println("***** Pass structure");
- passThis arg = new passThis();
+ StructureToPass arg = new StructureToPass();
arg.a = "A";
arg.b = "B";
- returnThis r = object.passStructure(arg);
+ StructureToReturn r = object.passStructure(arg);
System.out.println(" Fields of the returned structure:");
@@ -257,15 +257,15 @@ public class DirectTest
// +-- bb
System.out.println("***** Pass and return the tree.");
- node n = nod("Root");
+ TreeNode n = nod("Root");
- n.children = new node[] { nod("a"), nod("b") };
- n.children [ 1 ].children = new node[] { nod("ba"), nod("bb") };
- n.children [ 1 ].children [ 0 ].children = new node[] { nod("bac") };
+ n.children = new TreeNode[] { nod("a"), nod("b") };
+ n.children [ 1 ].children = new TreeNode[] { nod("ba"), nod("bb") };
+ n.children [ 1 ].children [ 0 ].children = new TreeNode[] { nod("bac") };
- nodeHolder nh = new nodeHolder(n);
+ TreeNodeHolder nh = new TreeNodeHolder(n);
- // The server should add '++' to each node name.
+ // The server should add '++' to each TreeNode name.
object.passTree(nh);
// Convert the returned tree to some strig representation.
@@ -288,7 +288,7 @@ public class DirectTest
object.throwException(123);
throw new InternalError();
}
- catch (ourUserException uex)
+ catch (WeThrowThisException uex)
{
System.out.println(" The user exception with field " + uex.ourField +
", has been thrown on remote side."
@@ -312,9 +312,9 @@ public class DirectTest
/**
* Get the string representation of the passed tree.
* @param b the string buffer to accumulate the representation.
- * @param n the tree (root node).
+ * @param n the tree (root TreeNode).
*/
- private void getImage(StringBuffer b, node n)
+ private void getImage(StringBuffer b, TreeNode n)
{
b.append(n.name);
b.append(": (");
@@ -328,15 +328,15 @@ public class DirectTest
}
/**
- * Create a node with the given header.
+ * Create a TreeNode with the given header.
*
- * @param hdr the node header.
- * @return the created node.
+ * @param hdr the TreeNode header.
+ * @return the created TreeNode.
*/
- private node nod(String hdr)
+ private TreeNode nod(String hdr)
{
- node n = new node();
- n.children = new node[ 0 ];
+ TreeNode n = new TreeNode();
+ n.children = new TreeNode[ 0 ];
n.name = hdr;
return n;
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
index 977fb4282..9c908e520 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
@@ -1,3 +1,39 @@
+/* RequestTest.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
@@ -7,14 +43,10 @@ import java.io.FileReader;
import java.io.IOException;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ByteHolder;
-import org.omg.CORBA.DoubleHolder;
import org.omg.CORBA.ExceptionList;
import org.omg.CORBA.NVList;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Request;
-import org.omg.CORBA.ShortHolder;
-import org.omg.CORBA.StringHolder;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.UnknownUserException;
@@ -25,7 +57,7 @@ import org.omg.CORBA.UnknownUserException;
* where the program has been started.
*
* The IOR.txt file is written by the server
- * {@link gnu.classpath.examples.CORBA.SimpleCommunication.comServer}.
+ * {@link gnu.classpath.examples.CORBA.SimpleCommunication.DemoServer}.
* The server should be reachable over Internet, unless blocked by
* security tools.
*
@@ -106,7 +138,6 @@ public class RequestTest
throw new InternalError();
}
testSystemException();
- testUserException();
testWideNarrowStrings();
}
@@ -135,13 +166,6 @@ public class RequestTest
Request r =
object._create_request(null, "passSimple", orb.create_list(0), null);
- ByteHolder a_byte = new ByteHolder((byte) 0);
- ShortHolder a_short = new ShortHolder((short) 3);
- StringHolder a_string = new StringHolder("[string 4]");
-
- // This is an 'out' parameter; the value must not be passed to servant.
- DoubleHolder a_double = new DoubleHolder(56.789);
-
r.add_inout_arg().insert_octet((byte) 0);
r.add_in_arg().insert_long(2);
r.add_inout_arg().insert_short((short) 3);
@@ -188,7 +212,7 @@ public class RequestTest
try
{
ExceptionList exList = orb.create_exception_list();
- exList.add(ourUserExceptionHelper.type());
+ exList.add(WeThrowThisExceptionHelper.type());
Request rq =
object._create_request(null, "throwException", orb.create_list(1),
@@ -217,7 +241,7 @@ public class RequestTest
System.out.println("**** Test user exception:");
ExceptionList exList = orb.create_exception_list();
- exList.add(ourUserExceptionHelper.type());
+ exList.add(WeThrowThisExceptionHelper.type());
Request rq =
object._create_request(null, "throwException", orb.create_list(1), null,
@@ -228,7 +252,7 @@ public class RequestTest
rq.invoke();
UnknownUserException uku = (UnknownUserException) rq.env().exception();
- ourUserException our_exception = ourUserExceptionHelper.extract(uku.except);
+ WeThrowThisException our_exception = WeThrowThisExceptionHelper.extract(uku.except);
System.out.println(" Our user exception, field " + our_exception.ourField +
", has been thrown on remote side."
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java
index 2a680b91b..d17e91fba 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass.java
@@ -1,4 +1,4 @@
-/* passThis.java --
+/* StructureToPass.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,9 +44,14 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class passThis
+public class StructureToPass
implements org.omg.CORBA.portable.IDLEntity
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The first string, stored in this structure (defined as
* "narrow string").
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
index 6b9f4ce01..c41ebe237 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHelper.java
@@ -1,4 +1,4 @@
-/* passThisHelper.java --
+/* StructureToPassHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
-import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TypeCode;
@@ -46,17 +45,17 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
- * The helper operations for the {@link passThis}.
+ * The helper operations for the {@link StructureToPass}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class passThisHelper
+public abstract class StructureToPassHelper
{
/**
- * The repository ID of the {@link passThis}.
+ * The repository ID of the {@link StructureToPass}.
*/
private static String id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThis:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPass:1.0";
/**
* Get the repository id.
@@ -69,9 +68,9 @@ public abstract class passThisHelper
/**
* Read the structure from the CDR stram.
*/
- public static passThis read(InputStream istream)
+ public static StructureToPass read(InputStream istream)
{
- passThis value = new passThis();
+ StructureToPass value = new StructureToPass();
value.a = istream.read_string();
value.b = istream.read_wstring();
return value;
@@ -88,13 +87,13 @@ public abstract class passThisHelper
members [ 0 ] = new StructMember("a", member, null);
member = ORB.init().create_string_tc(0);
members [ 1 ] = new StructMember("b", member, null);
- return ORB.init().create_struct_tc(passThisHelper.id(), "passThis", members);
+ return ORB.init().create_struct_tc(StructureToPassHelper.id(), "StructureToPass", members);
}
/**
* Write the structure into the CDR stream.
*/
- public static void write(OutputStream ostream, passThis value)
+ public static void write(OutputStream ostream, StructureToPass value)
{
ostream.write_string(value.a);
ostream.write_wstring(value.b);
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java
index 0d93cbaf6..5bbe6908e 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/passThisHolder.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToPassHolder.java
@@ -6,32 +6,32 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
-public final class passThisHolder
+public final class StructureToPassHolder
implements Streamable
{
- public passThis value;
+ public StructureToPass value;
- public passThisHolder()
+ public StructureToPassHolder()
{
}
- public passThisHolder(passThis initialValue)
+ public StructureToPassHolder(StructureToPass initialValue)
{
value = initialValue;
}
public void _read(InputStream i)
{
- value = passThisHelper.read(i);
+ value = StructureToPassHelper.read(i);
}
public org.omg.CORBA.TypeCode _type()
{
- return passThisHelper.type();
+ return StructureToPassHelper.type();
}
public void _write(OutputStream o)
{
- passThisHelper.write(o, value);
+ StructureToPassHelper.write(o, value);
}
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java
index b7c3923ce..5dc843ae8 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn.java
@@ -1,4 +1,4 @@
-/* returnThis.java --
+/* StructureToReturn.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,9 +44,14 @@ import org.omg.CORBA.portable.IDLEntity;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class returnThis
+public class StructureToReturn
implements IDLEntity
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The string field.
*/
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
index 79838d75c..42fb7a574 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHelper.java
@@ -1,4 +1,4 @@
-/* returnThisHelper.java --
+/* StructureToReturnHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,6 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
-import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
@@ -46,17 +45,17 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
- * This class defines the helper operations for {@link returnThis}.
+ * This class defines the helper operations for {@link StructureToReturn}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class returnThisHelper
+public abstract class StructureToReturnHelper
{
/**
* The repository id.
*/
private static String _id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThis:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturn:1.0";
/**
* Return the repository id.
@@ -69,9 +68,9 @@ public abstract class returnThisHelper
/**
* Read the structure from the CDR stream.
*/
- public static returnThis read(InputStream istream)
+ public static StructureToReturn read(InputStream istream)
{
- returnThis value = new returnThis();
+ StructureToReturn value = new StructureToReturn();
value.n = istream.read_long();
value.c = istream.read_wstring();
value.arra = new int[ 3 ];
@@ -95,7 +94,7 @@ public abstract class returnThisHelper
member = ORB.init().get_primitive_tc(TCKind.tk_long);
member = ORB.init().create_array_tc(3, member);
members [ 2 ] = new StructMember("arra", member, null);
- return ORB.init().create_struct_tc(returnThisHelper.id(), "returnThis",
+ return ORB.init().create_struct_tc(StructureToReturnHelper.id(), "StructureToReturn",
members
);
}
@@ -103,7 +102,7 @@ public abstract class returnThisHelper
/**
* Write the structure to the CDR stream.
*/
- public static void write(OutputStream ostream, returnThis value)
+ public static void write(OutputStream ostream, StructureToReturn value)
{
ostream.write_long(value.n);
ostream.write_wstring(value.c);
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java
index 294e37ac3..c70f9cfcc 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/returnThisHolder.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/StructureToReturnHolder.java
@@ -10,25 +10,25 @@ import org.omg.CORBA.portable.Streamable;
/**
* The holder for the structure, returned from the server.
*/
-public final class returnThisHolder
+public final class StructureToReturnHolder
implements Streamable
{
/**
* The enclosed structure.
*/
- public returnThis value = null;
+ public StructureToReturn value = null;
/**
* Create the empty holder.
*/
- public returnThisHolder()
+ public StructureToReturnHolder()
{
}
/**
* Crate the holder with the defined initial value.
*/
- public returnThisHolder(returnThis initialValue)
+ public StructureToReturnHolder(StructureToReturn initialValue)
{
value = initialValue;
}
@@ -38,7 +38,7 @@ public final class returnThisHolder
*/
public void _read(InputStream in)
{
- value = returnThisHelper.read(in);
+ value = StructureToReturnHelper.read(in);
}
/**
@@ -46,7 +46,7 @@ public final class returnThisHolder
*/
public TypeCode _type()
{
- return returnThisHelper.type();
+ return StructureToReturnHelper.type();
}
/**
@@ -55,6 +55,6 @@ public final class returnThisHolder
*/
public void _write(OutputStream out)
{
- returnThisHelper.write(out, value);
+ StructureToReturnHelper.write(out, value);
}
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java
index 527d02d06..b267f39ea 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/node.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode.java
@@ -1,4 +1,4 @@
-/* node.java --
+/* TreeNode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,12 +44,17 @@ package gnu.classpath.examples.CORBA.SimpleCommunication.communication;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class node
+public class TreeNode
implements org.omg.CORBA.portable.IDLEntity
{
- /** The node name */
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /** The TreeNode name */
public String name = null;
- /** The node children. */
- public node[] children = null;
+ /** The TreeNode children. */
+ public TreeNode[] children = null;
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
index 8d4121cda..f111d0eac 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHelper.java
@@ -1,4 +1,4 @@
-/* nodeHelper.java --
+/* TreeNodeHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,13 +51,13 @@ import org.omg.CORBA.portable.OutputStream;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class nodeHelper
+public abstract class TreeNodeHelper
{
/**
- * The node repository id, used to identify the structure.
+ * The TreeNode repository id, used to identify the structure.
*/
private static String _id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/node:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNode:1.0";
/**
* Caches the typecode, allowing to compute it only once.
@@ -66,21 +66,21 @@ public abstract class nodeHelper
/**
* This is used to handle the recursive object references in
- * CORBA - supported way. The tree node definition is recursive,
- * as the node contains the sequence of the nodes as its field.
+ * CORBA - supported way. The tree TreeNode definition is recursive,
+ * as the TreeNode contains the sequence of the nodes as its field.
*/
private static boolean active;
/**
- * Extract the tree node from the unversal CORBA wrapper, Any.
+ * Extract the tree TreeNode from the unversal CORBA wrapper, Any.
*/
- public static node extract(Any a)
+ public static TreeNode extract(Any a)
{
return read(a.create_input_stream());
}
/**
- * Get the node string identifer.
+ * Get the TreeNode string identifer.
*/
public static String id()
{
@@ -88,9 +88,9 @@ public abstract class nodeHelper
}
/**
- * Insert the node into the universal CORBA wrapper, Any.
+ * Insert the TreeNode into the universal CORBA wrapper, Any.
*/
- public static void insert(Any a, node that)
+ public static void insert(Any a, TreeNode that)
{
OutputStream out = a.create_output_stream();
a.type(type());
@@ -99,22 +99,22 @@ public abstract class nodeHelper
}
/**
- * Read the node from the common data reprentation (CDR) stream.
+ * Read the TreeNode from the common data reprentation (CDR) stream.
*/
- public static node read(InputStream istream)
+ public static TreeNode read(InputStream istream)
{
- node value = new node();
+ TreeNode value = new TreeNode();
value.name = istream.read_string();
int _len0 = istream.read_long();
- value.children = new node[ _len0 ];
+ value.children = new TreeNode[ _len0 ];
for (int i = 0; i < value.children.length; ++i)
- value.children [ i ] = nodeHelper.read(istream);
+ value.children [ i ] = TreeNodeHelper.read(istream);
return value;
}
/**
- * Get the node type code definition.
+ * Get the TreeNode type code definition.
*/
public static synchronized TypeCode type()
{
@@ -131,7 +131,7 @@ public abstract class nodeHelper
return ORB.init().create_recursive_tc(_id);
active = true;
- // List all memebers of the node structure.
+ // List all memebers of the TreeNode structure.
StructMember[] members = new StructMember[ 2 ];
TypeCode memberType;
memberType = ORB.init().create_string_tc(0);
@@ -139,7 +139,7 @@ public abstract class nodeHelper
memberType = ORB.init().create_recursive_tc("");
members [ 1 ] = new StructMember("children", memberType, null);
typeCode =
- ORB.init().create_struct_tc(nodeHelper.id(), "node", members);
+ ORB.init().create_struct_tc(TreeNodeHelper.id(), "TreeNode", members);
active = false;
}
}
@@ -148,13 +148,13 @@ public abstract class nodeHelper
}
/**
- * Write the node into the common data reprentation (CDR) stream.
+ * Write the TreeNode into the common data reprentation (CDR) stream.
*/
- public static void write(OutputStream ostream, node value)
+ public static void write(OutputStream ostream, TreeNode value)
{
ostream.write_string(value.name);
ostream.write_long(value.children.length);
for (int i = 0; i < value.children.length; ++i)
- nodeHelper.write(ostream, value.children [ i ]);
+ TreeNodeHelper.write(ostream, value.children [ i ]);
}
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java
index 8e4913912..ec180ce57 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/nodeHolder.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/TreeNodeHolder.java
@@ -1,4 +1,4 @@
-/* nodeHolder.java --
+/* TreeNodeHolder.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,57 +44,57 @@ import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
/**
- * The node holder is a wrapper about the node data structure. It
- * can be used where the node must be passed both to and from
+ * The TreeNode holder is a wrapper about the TreeNode data structure. It
+ * can be used where the TreeNode must be passed both to and from
* the method being called. The same structure holds the tree,
- * as it can be represented as a root node with children.
+ * as it can be represented as a root TreeNode with children.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class nodeHolder
+public class TreeNodeHolder
implements Streamable
{
/**
- * Stores the node value.
+ * Stores the TreeNode value.
*/
- public node value;
+ public TreeNode value;
/**
- * Creates the node holder with the null initial value.
+ * Creates the TreeNode holder with the null initial value.
*/
- public nodeHolder()
+ public TreeNodeHolder()
{
}
/**
- * Creates the node holder with the given initial value.
+ * Creates the TreeNode holder with the given initial value.
*/
- public nodeHolder(node initialValue)
+ public TreeNodeHolder(TreeNode initialValue)
{
value = initialValue;
}
/**
- * Reads the node value from the common data representation (CDR)
+ * Reads the TreeNode value from the common data representation (CDR)
* stream.
*/
public void _read(InputStream in)
{
- value = nodeHelper.read(in);
+ value = TreeNodeHelper.read(in);
}
/**
- * Writes the node value into common data representation (CDR)
+ * Writes the TreeNode value into common data representation (CDR)
* stream.
* @return
*/
public TypeCode _type()
{
- return nodeHelper.type();
+ return TreeNodeHelper.type();
}
public void _write(OutputStream out)
{
- nodeHelper.write(out, value);
+ TreeNodeHelper.write(out, value);
}
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java
index 51ea5f2d6..cf20d61ec 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException.java
@@ -1,4 +1,4 @@
-/* ourUserException.java --
+/* WeThrowThisException.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -49,10 +49,15 @@ import org.omg.CORBA.portable.IDLEntity;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class ourUserException
+public class WeThrowThisException
extends UserException
implements IDLEntity
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* Our specific field, transferred to client.
*/
@@ -63,7 +68,7 @@ public class ourUserException
*
* @param _ourField the value of our specific field.
*/
- public ourUserException(int _ourField)
+ public WeThrowThisException(int _ourField)
{
ourField = _ourField;
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
index 8c499df64..4d5eee74b 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisExceptionHelper.java
@@ -1,4 +1,4 @@
-/* ourUserExceptionHelper.java --
+/* WeThrowThisExceptionHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,14 +50,14 @@ import org.omg.CORBA.TypeCode;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class ourUserExceptionHelper
+public abstract class WeThrowThisExceptionHelper
{
/**
* The exception repository id. This name is also used to find the
* mapping local CORBA class.
*/
private static String _id =
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException:1.0";
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException:1.0";
/**
* Get the exception repository id.
@@ -71,7 +71,7 @@ public abstract class ourUserExceptionHelper
* Extract the exception from the given Any where it might be
* wrapped.
*/
- public static ourUserException extract(Any a)
+ public static WeThrowThisException extract(Any a)
{
return read(a.create_input_stream());
}
@@ -79,9 +79,9 @@ public abstract class ourUserExceptionHelper
/**
* Read the exception from the CDR stream.
*/
- public static ourUserException read(org.omg.CORBA.portable.InputStream istream)
+ public static WeThrowThisException read(org.omg.CORBA.portable.InputStream istream)
{
- ourUserException value = new ourUserException(0);
+ WeThrowThisException value = new WeThrowThisException(0);
// The repository ID is not used
istream.read_string();
@@ -98,8 +98,8 @@ public abstract class ourUserExceptionHelper
TypeCode member = null;
member = ORB.init().get_primitive_tc(TCKind.tk_long);
members [ 0 ] = new StructMember("ourField", member, null);
- return ORB.init().create_struct_tc(ourUserExceptionHelper.id(),
- "ourUserException", members
+ return ORB.init().create_struct_tc(WeThrowThisExceptionHelper.id(),
+ "WeThrowThisException", members
);
}
@@ -107,7 +107,7 @@ public abstract class ourUserExceptionHelper
* Write the exception into the CDR stream.
*/
public static void write(org.omg.CORBA.portable.OutputStream ostream,
- ourUserException value
+ WeThrowThisException value
)
{
ostream.write_string(id());
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java
index 4c8f5b94c..237c23086 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterImplBase.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterImplBase.java
@@ -1,4 +1,4 @@
-/* _comTesterImplBase.java --
+/* _DemoTesterImplBase.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,13 +53,16 @@ import org.omg.CORBA.portable.ResponseHandler;
/**
* The base for the class that is actually implementing the functionality
- * of the object on the server side ({@link comServant} of our case).
+ * of the object on the server side ({@link DemoServant} of our case).
+ *
+ * Following CORBA standards, the name of this class must start from
+ * underscore and end by the "ImplBase".
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class _comTesterImplBase
+public abstract class _DemoTesterImplBase
extends ObjectImpl
- implements comTester, InvokeHandler
+ implements DemoTester, InvokeHandler
{
/**
* When the server receives the request message from client, it
@@ -138,7 +141,7 @@ public abstract class _comTesterImplBase
}
else
/*
- Throws either 'ourUserException' with the 'ourField' field
+ Throws either 'WeThrowThisException' with the 'ourField' field
initialised to the passed positive value
or system exception (if the parameter is zero or negative).
*/
@@ -150,21 +153,21 @@ public abstract class _comTesterImplBase
throwException(parameter);
out = rh.createReply();
}
- catch (ourUserException exception)
+ catch (WeThrowThisException exception)
{
out = rh.createExceptionReply();
- ourUserExceptionHelper.write(out, exception);
+ WeThrowThisExceptionHelper.write(out, exception);
}
}
else
/* Passes and returns the structures. */
if (a_method.equals("passStructure"))
{
- passThis in_structure = passThisHelper.read(in);
- returnThis result = null;
+ StructureToPass in_structure = StructureToPassHelper.read(in);
+ StructureToReturn result = null;
result = passStructure(in_structure);
out = rh.createReply();
- returnThisHelper.write(out, result);
+ StructureToReturnHelper.write(out, result);
}
else
/* Passes and returns the string sequence. */
@@ -180,11 +183,11 @@ public abstract class _comTesterImplBase
/** Pass and return the tree structure */
if (a_method.equals("passTree"))
{
- nodeHolder tree = new nodeHolder();
- tree.value = nodeHelper.read(in);
+ TreeNodeHolder tree = new TreeNodeHolder();
+ tree.value = TreeNodeHelper.read(in);
passTree(tree);
out = rh.createReply();
- nodeHelper.write(out, tree.value);
+ TreeNodeHelper.write(out, tree.value);
}
else
@@ -201,6 +204,6 @@ public abstract class _comTesterImplBase
public String[] _ids()
{
// They are the same as for the stub.
- return _comTesterStub._ids;
+ return _DemoTesterStub._ids;
}
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java
index b71cd8e86..c8e0ccd6d 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_comTesterStub.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/_DemoTesterStub.java
@@ -1,4 +1,4 @@
-/* _comTesterStub.java --
+/* _DemoTesterStub.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,23 +55,26 @@ import org.omg.CORBA.portable.RemarshalException;
* side. It has all the same methods as the actual implementation
* on the server side. These methods contain the code for remote
* invocation.
+ *
+ * Following CORBA standards, the name of this class must start from
+ * underscore and end by the "Stub".
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class _comTesterStub
+public class _DemoTesterStub
extends ObjectImpl
- implements comTester
+ implements DemoTester
{
/**
- * A string array of comTester repository ids.
+ * A string array of DemoTester repository ids.
*/
public static String[] _ids =
{
- "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/comTester:1.0"
+ "IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/DemoTester:1.0"
};
/**
- * Return an array of comTester repository ids.
+ * Return an array of DemoTester repository ids.
*/
public String[] _ids()
{
@@ -217,7 +220,7 @@ public class _comTesterStub
/**
Passes and returns the structures.
*/
- public returnThis passStructure(passThis in_structure)
+ public StructureToReturn passStructure(StructureToPass in_structure)
{
InputStream in = null;
try
@@ -226,13 +229,13 @@ public class _comTesterStub
OutputStream out = _request("passStructure", true);
// Write the structure, using its helper.
- passThisHelper.write(out, in_structure);
+ StructureToPassHelper.write(out, in_structure);
// Invoke the method.
in = _invoke(out);
// Read the returned structer, using another helper.
- returnThis result = returnThisHelper.read(in);
+ StructureToReturn result = StructureToReturnHelper.read(in);
return result;
}
catch (ApplicationException ex)
@@ -253,7 +256,7 @@ public class _comTesterStub
/**
* Pass and return the tree structure
*/
- public void passTree(nodeHolder tree)
+ public void passTree(TreeNodeHolder tree)
{
InputStream in = null;
try
@@ -261,15 +264,15 @@ public class _comTesterStub
// Get the stream where the parameters must be written.
OutputStream out = _request("passTree", true);
- // Write the tree (node with its chilred, grandchildren and so on),
+ // Write the tree (TreeNode with its chilred, grandchildren and so on),
// using the appropriate helper.
- nodeHelper.write(out, tree.value);
+ TreeNodeHelper.write(out, tree.value);
// Call the method.
in = _invoke(out);
// Read the returned tree.
- tree.value = nodeHelper.read(in);
+ tree.value = TreeNodeHelper.read(in);
}
catch (ApplicationException ex)
{
@@ -382,10 +385,10 @@ public class _comTesterStub
* of the positive value of this argument, and system
* exception otherwise.
*
- * @throws ourUserException
+ * @throws WeThrowThisException
*/
public void throwException(int parameter)
- throws ourUserException
+ throws WeThrowThisException
{
InputStream in = null;
try
@@ -408,9 +411,9 @@ public class _comTesterStub
// If this is the user exception we expect to catch, read and throw
// it here. The system exception, if thrown, is handled by _invoke.
- if (id.equals("IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserException:1.0")
+ if (id.equals("IDL:gnu/classpath/examples/CORBA/SimpleCommunication/communication/WeThrowThisException:1.0")
)
- throw ourUserExceptionHelper.read(in);
+ throw WeThrowThisExceptionHelper.read(in);
else
throw new MARSHAL(id);
}
diff --git a/examples/gnu/classpath/examples/midi/Demo.java b/examples/gnu/classpath/examples/midi/Demo.java
new file mode 100644
index 000000000..7e403d8d6
--- /dev/null
+++ b/examples/gnu/classpath/examples/midi/Demo.java
@@ -0,0 +1,137 @@
+/* Demo.java -- And example of MIDI support
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA. */
+
+package gnu.classpath.examples.midi;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import javax.sound.midi.*;
+
+/**
+ * An example how javax.sound.midi facilities work.
+ */
+public class Demo extends Frame implements ItemListener
+{
+ Choice midiInChoice = new Choice();
+ Choice midiOutChoice = new Choice();
+
+ MidiDevice inDevice = null;
+ MidiDevice outDevice = null;
+
+ ArrayList inDevices = new ArrayList();
+ ArrayList outDevices = new ArrayList();
+
+ public Demo () throws Exception
+ {
+ MenuBar mb = new MenuBar ();
+ Menu menu = new Menu ("File");
+ MenuItem quit = new MenuItem("Quit", new MenuShortcut('Q'));
+ quit.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ System.exit(0);
+ }
+ });
+ menu.add (quit);
+ mb.add(menu);
+
+ setTitle("synthcity: the GNU Classpath MIDI Demo");
+ setLayout(new FlowLayout());
+
+ MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
+
+ for (int i = 0; i < infos.length; i++)
+ {
+ MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
+ if (device.getMaxReceivers() > 0)
+ {
+ midiOutChoice.addItem(infos[i].getDescription());
+ outDevices.add(device);
+ }
+ if (device.getMaxTransmitters() > 0)
+ {
+ midiInChoice.addItem(infos[i].getDescription());
+ inDevices.add(device);
+ }
+ }
+
+ setMenuBar (mb);
+ add(new Label("MIDI IN: "));
+ add(midiInChoice);
+ add(new Label(" MIDI OUT: "));
+ add(midiOutChoice);
+
+ midiInChoice.addItemListener(this);
+ midiOutChoice.addItemListener(this);
+
+ pack();
+ show();
+ }
+
+ public void itemStateChanged (ItemEvent e)
+ {
+ try
+ {
+ if (e.getItemSelectable() == midiInChoice)
+ {
+ if (inDevice != null)
+ inDevice.close();
+ inDevice = (MidiDevice)
+ inDevices.get(midiInChoice.getSelectedIndex());
+ }
+
+ if (e.getItemSelectable() == midiOutChoice)
+ {
+ if (outDevice != null)
+ outDevice.close();
+ outDevice = (MidiDevice)
+ outDevices.get(midiOutChoice.getSelectedIndex());
+ }
+
+ if (inDevice != null && outDevice != null)
+ {
+ if (! inDevice.isOpen())
+ inDevice.open();
+ if (! outDevice.isOpen())
+ outDevice.open();
+ Transmitter t = inDevice.getTransmitter();
+ if (t == null)
+ System.err.println (inDevice + ".getTransmitter() == null");
+ Receiver r = outDevice.getReceiver();
+ if (r == null)
+ System.err.println (outDevice + ".getReceiver() == null");
+
+ if (t != null && r != null)
+ t.setReceiver (r);
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public static void main (String args[]) throws Exception
+ {
+ new Demo();
+ }
+}
diff --git a/examples/gnu/classpath/examples/swing/ButtonDemo.java b/examples/gnu/classpath/examples/swing/ButtonDemo.java
index ee59f8341..b53ba3b5c 100644
--- a/examples/gnu/classpath/examples/swing/ButtonDemo.java
+++ b/examples/gnu/classpath/examples/swing/ButtonDemo.java
@@ -76,17 +76,33 @@ public class ButtonDemo
public ButtonDemo(String title)
{
super(title);
- getContentPane().add(createContent());
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
}
-
- private JPanel createContent()
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
{
+ JPanel content = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(4, 1));
panel.add(createButtonPanel());
panel.add(createTogglePanel());
panel.add(createCheckBoxPanel());
panel.add(createRadioPanel());
- return panel;
+ content.add(panel);
+ return content;
}
private JPanel createButtonPanel()
@@ -252,6 +268,10 @@ public class ButtonDemo
radio2.setEnabled(radioState.isSelected());
radio3.setEnabled(radioState.isSelected());
}
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
}
public static void main(String[] args)
diff --git a/examples/gnu/classpath/examples/swing/ComboBoxDemo.java b/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
new file mode 100644
index 000000000..52431cb5d
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
@@ -0,0 +1,360 @@
+/* ComboBoxDemo.java -- An example showing various combo boxes in Swing.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalIconFactory;
+
+/**
+ * A simple demo showing various combo boxes in different states.
+ */
+public class ComboBoxDemo
+ extends JFrame
+ implements ActionListener
+{
+
+ class CustomCellRenderer extends DefaultListCellRenderer
+ {
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ DefaultListCellRenderer result = (DefaultListCellRenderer)
+ super.getListCellRendererComponent(list, value, index, isSelected,
+ cellHasFocus);
+ Icon icon = (Icon) value;
+ result.setIcon(icon);
+ result.setText("Index = " + index);
+ return result;
+ }
+ }
+
+ private JCheckBox comboState1;
+ private JComboBox combo1;
+ private JComboBox combo2;
+
+ private JCheckBox comboState2;
+ private JComboBox combo3;
+ private JComboBox combo4;
+
+ private JCheckBox comboState3;
+ private JComboBox combo5;
+ private JComboBox combo6;
+
+ private JCheckBox comboState4;
+ private JComboBox combo7;
+ private JComboBox combo8;
+
+ private JCheckBox comboState5;
+ private JComboBox combo9;
+ private JComboBox combo10;
+
+ private JCheckBox comboState6;
+ private JComboBox combo11;
+ private JComboBox combo12;
+
+ /**
+ * Creates a new demo instance.
+ *
+ * @param title the frame title.
+ */
+ public ComboBoxDemo(String title)
+ {
+ super(title);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(6, 1));
+ panel.add(createPanel1());
+ panel.add(createPanel2());
+ panel.add(createPanel3());
+ panel.add(createPanel4());
+ panel.add(createPanel5());
+ panel.add(createPanel6());
+ content.add(panel);
+ return content;
+ }
+
+ private JPanel createPanel1()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState1 = new JCheckBox("Enabled", true);
+ this.comboState1.setActionCommand("COMBO_STATE1");
+ this.comboState1.addActionListener(this);
+ panel.add(this.comboState1, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Regular: "));
+ this.combo1 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+
+ this.combo2 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo2.setEditable(true);
+
+ controlPanel.add(combo1);
+ controlPanel.add(combo2);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel2()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState2 = new JCheckBox("Enabled", true);
+ this.comboState2.setActionCommand("COMBO_STATE2");
+ this.comboState2.addActionListener(this);
+ panel.add(this.comboState2, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Large Font: "));
+ this.combo3 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo3.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ this.combo4 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo4.setEditable(true);
+ this.combo4.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ controlPanel.add(combo3);
+ controlPanel.add(combo4);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel3()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState3 = new JCheckBox("Enabled", true);
+ this.comboState3.setActionCommand("COMBO_STATE3");
+ this.comboState3.addActionListener(this);
+ panel.add(this.comboState3, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Colored Background: "));
+ this.combo5 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo5.setBackground(Color.yellow);
+
+ this.combo6 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo6.setEditable(true);
+ this.combo6.setBackground(Color.yellow);
+
+ controlPanel.add(combo5);
+ controlPanel.add(combo6);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes that are empty.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel4()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState4 = new JCheckBox("Enabled", true);
+ this.comboState4.setActionCommand("COMBO_STATE4");
+ this.comboState4.addActionListener(this);
+ panel.add(this.comboState4, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Empty: "));
+ this.combo7 = new JComboBox();
+ this.combo8 = new JComboBox();
+ this.combo8.setEditable(true);
+
+ controlPanel.add(combo7);
+ controlPanel.add(combo8);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes that are narrow but contain long text
+ * items.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel5()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState5 = new JCheckBox("Enabled", true);
+ this.comboState5.setActionCommand("COMBO_STATE5");
+ this.comboState5.addActionListener(this);
+ panel.add(this.comboState5, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Narrow: "));
+ this.combo9 = new JComboBox(new Object[] {
+ "A really long item that will be truncated when displayed"});
+ this.combo9.setPreferredSize(new Dimension(100, 30));
+ this.combo10 = new JComboBox(new Object[] {
+ "A really long item that will be truncated when displayed"});
+ this.combo10.setPreferredSize(new Dimension(100, 30));
+ this.combo10.setEditable(true);
+
+ controlPanel.add(combo9);
+ controlPanel.add(combo10);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes with a custom renderer.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel6()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState6 = new JCheckBox("Enabled", true);
+ this.comboState6.setActionCommand("COMBO_STATE6");
+ this.comboState6.addActionListener(this);
+ panel.add(this.comboState6, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Custom Renderer: "));
+ this.combo11 = new JComboBox(new Object[] {
+ MetalIconFactory.getFileChooserHomeFolderIcon(),
+ MetalIconFactory.getFileChooserNewFolderIcon()});
+ this.combo11.setPreferredSize(new Dimension(100, 30));
+ this.combo11.setRenderer(new CustomCellRenderer());
+ this.combo12 = new JComboBox(new Object[] {
+ MetalIconFactory.getFileChooserHomeFolderIcon(),
+ MetalIconFactory.getFileChooserNewFolderIcon()});
+ this.combo12.setPreferredSize(new Dimension(100, 30));
+ this.combo12.setRenderer(new CustomCellRenderer());
+ this.combo12.setEditable(true);
+
+ controlPanel.add(combo11);
+ controlPanel.add(combo12);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("COMBO_STATE1"))
+ {
+ combo1.setEnabled(comboState1.isSelected());
+ combo2.setEnabled(comboState1.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE2"))
+ {
+ combo3.setEnabled(comboState2.isSelected());
+ combo4.setEnabled(comboState2.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE3"))
+ {
+ combo5.setEnabled(comboState3.isSelected());
+ combo6.setEnabled(comboState3.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE4"))
+ {
+ combo7.setEnabled(comboState4.isSelected());
+ combo8.setEnabled(comboState4.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE5"))
+ {
+ combo9.setEnabled(comboState5.isSelected());
+ combo10.setEnabled(comboState5.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE6"))
+ {
+ combo11.setEnabled(comboState6.isSelected());
+ combo12.setEnabled(comboState6.isSelected());
+ }
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ ComboBoxDemo app = new ComboBoxDemo("ComboBox Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/examples/gnu/classpath/examples/swing/Demo.java b/examples/gnu/classpath/examples/swing/Demo.java
index cba46a79a..6eec946a6 100644
--- a/examples/gnu/classpath/examples/swing/Demo.java
+++ b/examples/gnu/classpath/examples/swing/Demo.java
@@ -24,20 +24,12 @@ package gnu.classpath.examples.swing;
import java.awt.*;
import java.awt.event.*;
-import java.awt.font.*;
-import java.awt.geom.*;
-import java.awt.image.*;
import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
-import javax.swing.plaf.basic.*;
-import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.tree.*;
import javax.swing.border.*;
import java.net.URL;
-import java.util.*;
public class Demo
{
@@ -50,17 +42,23 @@ public class Demo
{
if (System.getProperty("swing.defaultlaf") == null)
{
+ UIManager.setLookAndFeel(new GNULookAndFeel());
+
StringBuffer text = new StringBuffer();
- text.append("\tYou may change the Look and Feel of this\n");
- text.append("\tDemo by setting the system property\n");
- text.append("\t-Dswing.defaultlaf=<LAFClassName>\n\n");
- text.append("\tPossible values for <LAFClassName> are:\n");
- text.append("\t * javax.swing.plaf.metal.MetalLookAndFeel\n");
- text.append("\t\tthe default Java L&F\n");
- text.append("\t * gnu.classpath.examples.swing.GNULookAndFeel\n");
- text.append("\tthe GNU Look and Feel\n");
- text.append("\t(derived from javax.swing.plaf.basic.BasicLookAndFeel\n\n");
- text.append("\tthe default is gnu.classpath.examples.swing.GNULookAndFeel\n");
+ text.append("You may change the Look and Feel of this\n");
+ text.append("Demo by setting the system property\n");
+ text.append("-Dswing.defaultlaf=<LAFClassName>\n");
+ text.append("\n");
+ text.append("Possible values for <LAFClassName> are:\n");
+ text.append("\n");
+ text.append("* javax.swing.plaf.metal.MetalLookAndFeel\n");
+ text.append(" the default GNU Classpath L&F\n");
+ text.append("\n");
+ text.append("* gnu.classpath.examples.swing.GNULookAndFeel\n");
+ text.append(" the GNU Look and Feel\n");
+ text.append(" (derived from javax.swing.plaf.basic.BasicLookAndFeel)\n");
+ text.append("\n");
+ text.append("the default is gnu.classpath.examples.swing.GNULookAndFeel\n");
JEditorPane textPane = new JEditorPane();
// temporary hack, preferred size should be computed by the
// component
@@ -69,8 +67,6 @@ public class Demo
JOptionPane.showMessageDialog(null, textPane,
"Look and Feel notice",
JOptionPane.INFORMATION_MESSAGE);
-
- UIManager.setLookAndFeel(new GNULookAndFeel());
}
}
catch (UnsupportedLookAndFeelException e)
@@ -147,10 +143,7 @@ public class Demo
JMenu examples = new JMenu("Examples");
new PopUpAction("Buttons",
- mkPanel(new JComponent[]
- {mkBigButton("mango"),
- mkBigButton("guava"),
- mkBigButton("lemon")}),
+ (new ButtonDemo("Button Demo")).createContent(),
examples);
new PopUpAction("Toggles",
@@ -181,7 +174,7 @@ public class Demo
examples);
new PopUpAction("Scrollbar",
- mkScrollBar(),
+ (new ScrollBarDemo("ScrollBarDemo")).createContent(),
examples);
new PopUpAction("Viewport",
@@ -189,8 +182,8 @@ public class Demo
examples);
new PopUpAction("ScrollPane",
- mkScrollPane(mkBigButton("Scroll Me!")),
- examples);
+ mkScrollPane(mkBigButton("Scroll Me!")),
+ examples);
new PopUpAction("TabPane",
mkTabs(new String[] {"happy",
@@ -211,11 +204,7 @@ public class Demo
examples);
new PopUpAction("ComboBox",
- mkComboBox(new String[] {"Stop",
- "Software",
- "Hoarders",
- "Support",
- "GNU!"}),
+ (new ComboBoxDemo("ComboBox Demo")).createContent(),
examples);
new PopUpAction("Editor",
@@ -317,6 +306,7 @@ public class Demo
else
b = new JButton(title, icon);
+ b.setToolTipText(title);
if (hAlign != -1) b.setHorizontalAlignment(hAlign);
if (vAlign != -1) b.setVerticalAlignment(vAlign);
if (hPos != -1) b.setHorizontalTextPosition(hPos);
@@ -743,11 +733,17 @@ public class Demo
return c;
}
- public static JRadioButton mkRadio(String label)
+ public static JPanel mkRadio(String label)
{
+ JPanel p = new JPanel();
JRadioButton c = new JRadioButton(label);
- c.setFont(new Font("Luxi", Font.PLAIN, 14));
- return c;
+ JRadioButton d = new JRadioButton("not " + label);
+ ButtonGroup bg = new ButtonGroup();
+ bg.add(c);
+ bg.add(d);
+ p.add(c);
+ p.add(d);
+ return p;
}
public static JList mkList(Object[] elts)
@@ -1014,10 +1010,7 @@ public class Demo
panel.setLayout(new FlowLayout());
new PopUpAction("Buttons",
- mkPanel(new JComponent[]
- {mkBigButton("mango"),
- mkBigButton("guava"),
- mkBigButton("lemon")}),
+ (new ButtonDemo("Button Demo")).createContent(),
panel);
new PopUpAction("Toggles",
@@ -1033,7 +1026,7 @@ public class Demo
panel);
new PopUpAction("Slider",
- mkSliders(),
+ (new SliderDemo("Slider Demo")).createContent(),
panel);
new PopUpAction("List",
@@ -1048,7 +1041,7 @@ public class Demo
panel);
new PopUpAction("Scrollbar",
- mkScrollBar(),
+ (new ScrollBarDemo("ScrollBar Demo")).createContent(),
panel);
new PopUpAction("Viewport",
@@ -1078,11 +1071,7 @@ public class Demo
panel);
new PopUpAction("ComboBox",
- mkComboBox(new String[] {"Stop",
- "Software",
- "Hoarders",
- "Support",
- "GNU!"}),
+ (new ComboBoxDemo("ComboBox Demo")).createContent(),
panel);
new PopUpAction("Editor",
diff --git a/examples/gnu/classpath/examples/swing/ScrollBarDemo.java b/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
new file mode 100644
index 000000000..fce137301
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
@@ -0,0 +1,141 @@
+/* ScrollBarDemo.java -- An example showing scroll bars in Swing.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollBar;
+
+/**
+ * A simple scroll bar demo showing various scroll bars in different states.
+ */
+public class ScrollBarDemo
+ extends JFrame
+ implements ActionListener
+{
+
+ /**
+ * Creates a new demo instance.
+ *
+ * @param title the frame title.
+ */
+ public ScrollBarDemo(String title)
+ {
+ super(title);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = createScrollBarPanel();
+ content.add(panel);
+ return content;
+ }
+
+ private JPanel createScrollBarPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ JPanel horizontalPanel = new JPanel();
+
+ JScrollBar scroll1a = new JScrollBar(JScrollBar.HORIZONTAL);
+ JScrollBar scroll1b = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1b.setEnabled(false);
+ JScrollBar scroll1c = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1c.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ JScrollBar scroll1d = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1d.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ scroll1d.setEnabled(false);
+ horizontalPanel.add(scroll1a);
+ horizontalPanel.add(scroll1b);
+ horizontalPanel.add(scroll1c);
+ horizontalPanel.add(scroll1d);
+
+ panel.add(horizontalPanel, BorderLayout.NORTH);
+
+ JPanel verticalPanel = new JPanel();
+ verticalPanel.setLayout(new GridLayout(1, 7));
+
+ JScrollBar scroll2a = new JScrollBar(JScrollBar.VERTICAL);
+ JScrollBar scroll2b = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2b.setEnabled(false);
+ JScrollBar scroll2c = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2c.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ JScrollBar scroll2d = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2d.setEnabled(false);
+ scroll2d.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+
+ verticalPanel.add(scroll2a);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2b);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2c);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2d);
+
+ panel.add(verticalPanel, BorderLayout.EAST);
+
+ JPanel centerPanel = new JPanel(new GridLayout(1, 2));
+ centerPanel.add(new JScrollBar(JScrollBar.HORIZONTAL));
+ centerPanel.add(new JScrollBar(JScrollBar.VERTICAL));
+ panel.add(centerPanel);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ ScrollBarDemo app = new ScrollBarDemo("ScrollBar Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/examples/gnu/classpath/examples/swing/SliderDemo.java b/examples/gnu/classpath/examples/swing/SliderDemo.java
new file mode 100644
index 000000000..736024c48
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/SliderDemo.java
@@ -0,0 +1,249 @@
+/* SliderDemo.java -- An example showing JSlider in various configurations.
+ Copyright (C) 2005, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+
+public class SliderDemo extends JFrame implements ActionListener
+{
+
+ JSlider hslider1;
+ JSlider hslider2;
+ JSlider hslider3;
+ JSlider hslider4;
+ JSlider hslider5;
+ JSlider hslider6;
+ JSlider hslider7;
+ JSlider hslider8;
+
+ JSlider vslider1;
+ JSlider vslider2;
+ JSlider vslider3;
+ JSlider vslider4;
+ JSlider vslider5;
+ JSlider vslider6;
+ JSlider vslider7;
+ JSlider vslider8;
+
+ JCheckBox enabledCheckBox;
+
+ public SliderDemo(String frameTitle)
+ {
+ super(frameTitle);
+ JPanel content = createContent();
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ content.add(closePanel, BorderLayout.SOUTH);
+ getContentPane().add(content);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ JPanel createContent()
+ {
+ JPanel content = new JPanel(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(1, 2));
+ panel.add(createHorizontalPanel());
+ panel.add(createVerticalPanel());
+ enabledCheckBox = new JCheckBox("Enabled");
+ enabledCheckBox.setSelected(true);
+ enabledCheckBox.setActionCommand("TOGGLE_ENABLED");
+ enabledCheckBox.addActionListener(this);
+ JPanel checkBoxPanel = new JPanel();
+ checkBoxPanel.add(enabledCheckBox);
+ JPanel panel2 = new JPanel(new BorderLayout());
+ panel2.add(panel);
+ panel2.add(checkBoxPanel, BorderLayout.SOUTH);
+ content.add(panel2);
+ return content;
+ }
+
+ private JPanel createHorizontalPanel()
+ {
+ JPanel panel = new JPanel(new GridLayout(8, 1));
+
+ hslider1 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ panel.add(hslider1);
+
+ hslider2 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider2.setMajorTickSpacing(20);
+ hslider2.setMinorTickSpacing(5);
+ hslider2.setPaintTicks(true);
+ panel.add(hslider2);
+
+ hslider3 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider3.setMajorTickSpacing(20);
+ hslider3.setMinorTickSpacing(5);
+ hslider3.setPaintLabels(true);
+ hslider3.setPaintTicks(true);
+ panel.add(hslider3);
+
+ hslider4 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider4.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ hslider4.setMajorTickSpacing(20);
+ hslider4.setMinorTickSpacing(5);
+ hslider4.setPaintLabels(true);
+ hslider4.setPaintTicks(true);
+ panel.add(hslider4);
+
+ hslider5 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider5.setInverted(true);
+ panel.add(hslider5);
+
+ hslider6 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider6.setInverted(true);
+ hslider6.setMajorTickSpacing(20);
+ hslider6.setMinorTickSpacing(5);
+ hslider6.setPaintTicks(true);
+ panel.add(hslider6);
+
+ hslider7 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider7.setInverted(true);
+ hslider7.setMajorTickSpacing(20);
+ hslider7.setMinorTickSpacing(5);
+ hslider7.setPaintLabels(true);
+ hslider7.setPaintTicks(true);
+ panel.add(hslider7);
+
+ hslider8 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider8.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ hslider8.setInverted(true);
+ hslider8.setMajorTickSpacing(20);
+ hslider8.setMinorTickSpacing(5);
+ hslider8.setPaintLabels(true);
+ hslider8.setPaintTicks(true);
+ panel.add(hslider8);
+
+ return panel;
+ }
+
+ private JPanel createVerticalPanel()
+ {
+ JPanel panel = new JPanel(new GridLayout(1, 8));
+
+ vslider1 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ panel.add(vslider1);
+
+ vslider2 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider2.setMajorTickSpacing(20);
+ vslider2.setMinorTickSpacing(5);
+ vslider2.setPaintTicks(true);
+ panel.add(vslider2);
+
+ vslider3 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider3.setMajorTickSpacing(20);
+ vslider3.setMinorTickSpacing(5);
+ vslider3.setPaintLabels(true);
+ vslider3.setPaintTicks(true);
+ panel.add(vslider3);
+
+ vslider4 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider4.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ vslider4.setMajorTickSpacing(20);
+ vslider4.setMinorTickSpacing(5);
+ vslider4.setPaintLabels(true);
+ vslider4.setPaintTicks(true);
+ panel.add(vslider4);
+
+ vslider5 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider5.setInverted(true);
+ panel.add(vslider5);
+
+ vslider6 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider6.setInverted(true);
+ vslider6.setMajorTickSpacing(20);
+ vslider6.setMinorTickSpacing(5);
+ vslider6.setPaintTicks(true);
+ panel.add(vslider6);
+
+ vslider7 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider7.setInverted(true);
+ vslider7.setMajorTickSpacing(20);
+ vslider7.setMinorTickSpacing(5);
+ vslider7.setPaintLabels(true);
+ vslider7.setPaintTicks(true);
+ panel.add(vslider7);
+
+ vslider8 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider8.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ vslider8.setInverted(true);
+ vslider8.setMajorTickSpacing(20);
+ vslider8.setMinorTickSpacing(5);
+ vslider8.setPaintLabels(true);
+ vslider8.setPaintTicks(true);
+ panel.add(vslider8);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("TOGGLE_ENABLED"))
+ {
+ boolean enabled = enabledCheckBox.isSelected();
+ hslider1.setEnabled(enabled);
+ hslider2.setEnabled(enabled);
+ hslider3.setEnabled(enabled);
+ hslider4.setEnabled(enabled);
+ hslider5.setEnabled(enabled);
+ hslider6.setEnabled(enabled);
+ hslider7.setEnabled(enabled);
+ hslider8.setEnabled(enabled);
+ vslider1.setEnabled(enabled);
+ vslider2.setEnabled(enabled);
+ vslider3.setEnabled(enabled);
+ vslider4.setEnabled(enabled);
+ vslider5.setEnabled(enabled);
+ vslider6.setEnabled(enabled);
+ vslider7.setEnabled(enabled);
+ vslider8.setEnabled(enabled);
+ }
+ }
+ public static void main(String[] args)
+ {
+ SliderDemo app = new SliderDemo("Slider Demo");
+ app.pack();
+ app.setVisible(true);
+ }
+
+}
diff --git a/gnu/CORBA/CDR/cdrInput.java b/gnu/CORBA/CDR/AbstractCdrInput.java
index 69f9c8c58..866ec2cc9 100644
--- a/gnu/CORBA/CDR/cdrInput.java
+++ b/gnu/CORBA/CDR/AbstractCdrInput.java
@@ -1,4 +1,4 @@
-/* cdrInput.java --
+/* AbstractCdrInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,16 +39,17 @@ exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.BigDecimalHelper;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.GIOP.CharSets_OSF;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import gnu.CORBA.IOR;
-import gnu.CORBA.IOR_Delegate;
+import gnu.CORBA.IorDelegate;
+import gnu.CORBA.Minor;
import gnu.CORBA.TypeCodeHelper;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
import gnu.CORBA.gnuAny;
-import gnu.CORBA.stubFinder;
+import gnu.CORBA.StubLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnySeqHolder;
@@ -81,38 +82,44 @@ import java.io.Serializable;
import java.math.BigDecimal;
/**
- * A simple CORBA CDR (common data representation)
- * input stream, reading data from the
- * given {@link java.io.InputStream}. The primitive types
- * are aligned on they natural boundaries by implementing the
- * abstract method {@link #align(int boundary)}.
- *
- * The same class also implements {@link org.omg.CORBA.DataInputStream} to
- * read the object content in a user defined way.
- *
+ * A simple CORBA CDR (common data representation) input stream, reading data
+ * from the given {@link java.io.InputStream}. The primitive types are aligned
+ * on they natural boundaries by implementing the abstract method
+ * {@link #align(int boundary)}.
+ *
+ * The same class also implements {@link org.omg.CORBA.DataInputStream} to read
+ * the object content in a user defined way.
+ *
+ * TODO This class uses 16 bits per Unicode character only, as it was until jdk
+ * 1.4 inclusive.
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public abstract class cdrInput
+public abstract class AbstractCdrInput
extends org.omg.CORBA_2_3.portable.InputStream
implements org.omg.CORBA.DataInputStream
{
/**
- * The message, explaining that the exception has been thrown due
- * unexpected end of the input stream. This usually happens the
- * server and client disagree on communication or data representation
- * rules.
+ * The runtime, associated with this stream. This field is only used when
+ * reading and writing value types and filled-in in gnu.CORBA.CDR.Vio.
+ */
+ public transient gnuRuntime runtime;
+
+ /**
+ * The message, explaining that the exception has been thrown due unexpected
+ * end of the input stream. This usually happens the server and client
+ * disagree on communication or data representation rules.
*/
protected static final String UNEXP_EOF = "Unexpected end of stream";
/**
- * This instance is used to convert primitive data types into the
- * byte sequences.
+ * This instance is used to convert primitive data types into the byte
+ * sequences.
*/
- protected abstractDataInputStream b;
+ protected AbstractDataInput b;
/**
- * The input stream, from where the data are actually
- * being read.
+ * The input stream, from where the data are actually being read.
*/
protected java.io.InputStream actual_stream;
@@ -129,71 +136,68 @@ public abstract class cdrInput
/**
* The code set information.
*/
- protected cxCodeSet codeset = cxCodeSet.STANDARD;
+ protected CodeSetServiceContext codeset = CodeSetServiceContext.STANDARD;
/**
- * The name of the currently used narrow charset, null if
- * the native narrow charset is used.
+ * The name of the currently used narrow charset, null if the native narrow
+ * charset is used.
*/
private String narrow_charset = null;
/**
- * The name of the currently used wide charset, null if
- * the native wide charset is used.
+ * The name of the currently used wide charset, null if the native wide
+ * charset is used.
*/
private String wide_charset = null;
/**
- * True if the native code set is used for narrow characters.
- * If the set is native, no the intermediate Reader object
- * is instantiated when writing characters.
+ * True if the native code set is used for narrow characters. If the set is
+ * native, no the intermediate Reader object is instantiated when writing
+ * characters.
*/
private boolean narrow_native;
/**
- * True if the native code set is used for wide characters.
- * If the set is native, no the intermediate Reader object
- * is instantiated when writing characters.
+ * True if the native code set is used for wide characters. If the set is
+ * native, no the intermediate Reader object is instantiated when writing
+ * characters.
*/
private boolean wide_native;
/**
- * If true, the stream expect
- * the multi-byte data in the form "less significant byte
- * first" (Little Endian). This is the opposite to the
- * java standard (Big Endian).
+ * If true, the stream expect the multi-byte data in the form "less
+ * significant byte first" (Little Endian). This is the opposite to the java
+ * standard (Big Endian).
*/
private boolean little_endian;
/**
- * Creates the stream. The stream reads Big Endian by
- * default.
- *
+ * Creates the stream. The stream reads Big Endian by default.
+ *
* @param readFrom a stream to read CORBA input from.
*/
- public cdrInput(java.io.InputStream readFrom)
+ public AbstractCdrInput(java.io.InputStream readFrom)
{
setInputStream(readFrom);
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
- * Creates the stream, requiring the subsequent call
- * of {@link #setInputStream(java.io.InputStream)}.
+ * Creates the stream, requiring the subsequent call of
+ * {@link #setInputStream(java.io.InputStream)}.
*/
- public cdrInput()
+ public AbstractCdrInput()
{
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
- * Set the Big Endian or Little Endian encoding.
- * The stream reads Big Endian by default.
- *
- * @param use_little_endian if true, the stream expect
- * the multi-byte data in the form "less significant byte
- * first" (Little Endian). This is the opposite to the
- * java standard (Big Endian).
+ * Set the Big Endian or Little Endian encoding. The stream reads Big Endian
+ * by default.
+ *
+ * @param use_little_endian if true, the stream expect the multi-byte data in
+ * the form "less significant byte first" (Little Endian). This is the
+ * opposite to the java standard (Big Endian).
*/
public void setBigEndian(boolean use_big_endian)
{
@@ -202,8 +206,29 @@ public abstract class cdrInput
}
/**
+ * Get the used encoding.
+ *
+ * @param true for Big Endian, false for Little Endian.
+ */
+ public boolean isBigEndian()
+ {
+ return !little_endian;
+ }
+
+ /**
+ * Clone all important settings to another stream.
+ */
+ public void cloneSettings(AbstractCdrInput stream)
+ {
+ stream.setBigEndian(isBigEndian());
+ stream.setCodeSet(getCodeSet());
+ stream.setVersion(giop);
+ stream.setOrb(orb);
+ }
+
+ /**
* Set the input stream that receives the CORBA input.
- *
+ *
* @param readFrom the stream.
*/
public void setInputStream(java.io.InputStream readFrom)
@@ -217,13 +242,14 @@ public abstract class cdrInput
}
/**
- * Set the alignment offset, if the index of the first byte in the
- * stream is different from 0.
+ * Set the alignment offset, if the index of the first byte in the stream is
+ * different from 0.
*/
public abstract void setOffset(int offset);
/**
* Set the orb, associated with this stream.
+ *
* @param an_orb
*/
public void setOrb(ORB an_orb)
@@ -232,8 +258,8 @@ public abstract class cdrInput
}
/**
- * Set the GIOP version. Some data types are written differently
- * for the different versions. The default version is 1.0 .
+ * Set the GIOP version. Some data types are written differently for the
+ * different versions. The default version is 1.0 .
*/
public void setVersion(Version giop_version)
{
@@ -246,8 +272,8 @@ public abstract class cdrInput
public abstract void align(int boundary);
/**
- * Reads the CORBA unsigned long (java int), returning the
- * value in the sufficiently large java long.
+ * Reads the CORBA unsigned long (java int), returning the value in the
+ * sufficiently large java long.
*/
public long gnu_read_ulong()
{
@@ -260,6 +286,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -270,8 +297,8 @@ public abstract class cdrInput
}
/**
- * Read the unsigned short integer value and return it as java
- * int, sufficiently large to hold all values.
+ * Read the unsigned short integer value and return it as java int,
+ * sufficiently large to hold all values.
*/
public int gnu_read_ushort()
{
@@ -283,6 +310,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -295,6 +323,7 @@ public abstract class cdrInput
/**
* Return the associated {@link ORB}.
+ *
* @return the associated {@link ORB} or null is no such is set.
*/
public ORB orb()
@@ -306,7 +335,7 @@ public abstract class cdrInput
* Read a single byte directly from the buffer.
*/
public int read()
- throws java.io.IOException
+ throws java.io.IOException
{
try
{
@@ -315,6 +344,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -324,7 +354,7 @@ public abstract class cdrInput
* Read bytes directly from the buffer.
*/
public int read(byte[] x, int ofs, int len)
- throws java.io.IOException
+ throws java.io.IOException
{
try
{
@@ -333,6 +363,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -342,7 +373,7 @@ public abstract class cdrInput
* Read bytes directly from the buffer.
*/
public int read(byte[] x)
- throws java.io.IOException
+ throws java.io.IOException
{
try
{
@@ -351,24 +382,25 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
}
/**
- * Read the CORBA object. The object to read is represented in the
- * form of the plain (not a string-encoded) IOR profile without the
- * heading endian indicator. The responsible method for reading such
- * data is {@link IOR.read_no_endian}.
- *
- * The returned object is usually casted into the given type using
- * the .narrow method of its helper, despite in some cases the direct
- * cast would also work.
- *
- * The null objects are recognised from the empty profile set.
- * For such objects, null is returned.
- *
+ * Read the CORBA object. The object to read is represented in the form of the
+ * plain (not a string-encoded) IOR profile without the heading endian
+ * indicator. The responsible method for reading such data is
+ * {@link IOR.read_no_endian}.
+ *
+ * The returned object is usually casted into the given type using the .narrow
+ * method of its helper, despite in some cases the direct cast would also
+ * work.
+ *
+ * The null objects are recognised from the empty profile set. For such
+ * objects, null is returned.
+ *
* @return the loaded and constructed object.
*/
public org.omg.CORBA.Object read_Object()
@@ -384,41 +416,42 @@ public abstract class cdrInput
// Check maybe this is a remote reference to the local object.
// This is only possible if we access the repository of the
// connected object.
- if (orb instanceof Functional_ORB)
+ if (orb instanceof OrbFunctional)
{
- Functional_ORB forb = (Functional_ORB) orb;
+ OrbFunctional forb = (OrbFunctional) orb;
org.omg.CORBA.Object local = forb.find_local_object(ior);
if (local != null)
return local;
}
// Search for the available stubs.
- ObjectImpl impl = stubFinder.search(orb, ior);
+ ObjectImpl impl = StubLocator.search(orb, ior);
try
{
if (impl._get_delegate() == null)
- impl._set_delegate(new IOR_Delegate(orb, ior));
+ impl._set_delegate(new IorDelegate(orb, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception
// in response to the attempt to get the unset delegate.
- impl._set_delegate(new IOR_Delegate(orb, ior));
+ impl._set_delegate(new IorDelegate(orb, ior));
}
return impl;
}
catch (IOException ex)
{
- BAD_OPERATION bad = new BAD_OPERATION();
+ MARSHAL bad = new MARSHAL();
+ bad.minor = Minor.IOR;
bad.initCause(ex);
throw bad;
}
}
/**
- * Read the type code. The type code format is defined in the
- * CORBA documenation.
+ * Read the type code. The type code format is defined in the CORBA
+ * documenation.
*/
public TypeCode read_TypeCode()
{
@@ -438,9 +471,8 @@ public abstract class cdrInput
}
/**
- * Read the CORBA {@link Any}. This method first reads the
- * type code, then delegates the functionality
- * to {@link Any#read_value}.
+ * Read the CORBA {@link Any}. This method first reads the type code, then
+ * delegates the functionality to {@link Any#read_value}.
*/
public Any read_any()
{
@@ -451,8 +483,7 @@ public abstract class cdrInput
}
/**
- * Read the boolean, treating any non zero byte as true,
- * zero byte as false.
+ * Read the boolean, treating any non zero byte as true, zero byte as false.
*/
public boolean read_boolean()
{
@@ -463,6 +494,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -481,12 +513,13 @@ public abstract class cdrInput
{
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.read() == 0 ? false : true;
+ x[i] = b.read() == 0 ? false : true;
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -498,8 +531,8 @@ public abstract class cdrInput
}
/**
- * Read a character using narrow charset encoding. Depending form
- * which encoding is set, this still can be Unicode or ever wider.
+ * Read a character using narrow charset encoding. Depending form which
+ * encoding is set, this still can be Unicode or ever wider.
*/
public char read_char()
{
@@ -513,6 +546,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -533,18 +567,19 @@ public abstract class cdrInput
if (narrow_native)
{
for (int i = offset; i < offset + length; i++)
- x [ i ] = (char) b.read();
+ x[i] = (char) b.read();
}
else
{
- InputStreamReader reader =
- new InputStreamReader((InputStream) b, narrow_charset);
+ InputStreamReader reader = new InputStreamReader((InputStream) b,
+ narrow_charset);
reader.read(x, offset, length);
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -568,6 +603,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -588,12 +624,13 @@ public abstract class cdrInput
align(8);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readDouble();
+ x[i] = b.readDouble();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -605,26 +642,24 @@ public abstract class cdrInput
}
/**
- * Read the encapsulated stream.
- * If the encapsulated sequence appears to be in the
- * Little endian format, the flag of the returned stream
- * is set to read Little endian.
+ * Read the encapsulated stream. If the encapsulated sequence appears to be in
+ * the Little endian format, the flag of the returned stream is set to read
+ * Little endian.
*/
- public cdrBufInput read_encapsulation()
+ public BufferredCdrInput read_encapsulation()
{
try
{
int l = read_long();
- byte[] r = new byte[ l ];
+ byte[] r = new byte[l];
int n = 0;
- reading:
- while (n < r.length)
+ reading: while (n < r.length)
{
n += read(r, n, r.length - n);
}
- cdrBufInput capsule = new cdrBufInput(r);
+ BufferredCdrInput capsule = new BufferredCdrInput(r);
capsule.setOrb(orb);
int endian = capsule.read_octet();
@@ -639,6 +674,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -650,9 +686,8 @@ public abstract class cdrInput
}
/**
- * Read the CORBA fixed (the end of the <code>fixed</code>
- * can be determined by its last byte). The scale is always
- * assumed to be zero.
+ * Read the CORBA fixed (the end of the <code>fixed</code> can be determined
+ * by its last byte). The scale is always assumed to be zero.
*/
public BigDecimal read_fixed()
{
@@ -663,6 +698,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -686,6 +722,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -706,12 +743,13 @@ public abstract class cdrInput
align(4);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readFloat();
+ x[i] = b.readFloat();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -735,6 +773,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -755,12 +794,13 @@ public abstract class cdrInput
align(4);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readInt();
+ x[i] = b.readInt();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -783,7 +823,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
+ throw t;
}
catch (IOException ex)
@@ -802,12 +844,13 @@ public abstract class cdrInput
align(8);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readLong();
+ x[i] = b.readLong();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -830,6 +873,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -852,6 +896,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -863,24 +908,24 @@ public abstract class cdrInput
}
/**
- * Read the length of the byte array as CORBA long and then
- * the array itseld.
+ * Read the length of the byte array as CORBA long and then the array itseld.
*/
public byte[] read_sequence()
{
try
{
int l = read_long();
- byte[] b = new byte[ l ];
+ byte[] buf = new byte[l];
if (l > 0)
{
- read(b);
+ b.readFully(buf);
}
- return b;
+ return buf;
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -904,6 +949,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -924,12 +970,13 @@ public abstract class cdrInput
align(2);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readShort();
+ x[i] = b.readShort();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -941,21 +988,21 @@ public abstract class cdrInput
}
/**
- * Read a singe byte string. The method firs reads the
- * byte array and then calls a constructor to create a
- * string from this array. The character encoding, if
- * previously set, is taken into consideration.
- *
+ * Read a singe byte string. The method firs reads the byte array and then
+ * calls a constructor to create a string from this array. The character
+ * encoding, if previously set, is taken into consideration.
+ *
* @return a loaded string.
*/
public String read_string()
{
+ int n = 0;
try
{
align(4);
- int n = b.readInt();
- byte[] s = new byte[ n ];
+ n = b.readInt();
+ byte[] s = new byte[n];
b.read(s);
// Discard the null terminator.
@@ -967,19 +1014,26 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
-
catch (IOException ex)
{
throw new Unexpected();
}
+ catch (NegativeArraySizeException nex)
+ {
+ MARSHAL m = new MARSHAL("Input stream broken, got " + n + "(0x"
+ + Integer.toHexString(n) + ") as a string size");
+ m.minor = Minor.Negative;
+ throw m;
+ }
}
/**
- * Reads the CORBA unsigned long (java int), delegating
- * functionality to {@link #read_long}.
+ * Reads the CORBA unsigned long (java int), delegating functionality to
+ * {@link #read_long}.
*/
public int read_ulong()
{
@@ -987,9 +1041,8 @@ public abstract class cdrInput
}
/**
- * Reads the array of CORBA unsigned long (java integer) values,
- * delegating functionality to
- * {@link #real_long_array}.
+ * Reads the array of CORBA unsigned long (java integer) values, delegating
+ * functionality to {@link #real_long_array}.
*/
public void read_ulong_array(int[] x, int offs, int len)
{
@@ -997,11 +1050,9 @@ public abstract class cdrInput
}
/**
- * Read the CORBA unsigned long long value,
- * delegating functionality to {@link #read_longlong}.
- * There is no way to return values over the limit of
- * the java signed long in other way than returning
- * the negative value.
+ * Read the CORBA unsigned long long value, delegating functionality to
+ * {@link #read_longlong}. There is no way to return values over the limit of
+ * the java signed long in other way than returning the negative value.
*/
public long read_ulonglong()
{
@@ -1009,9 +1060,8 @@ public abstract class cdrInput
}
/**
- * Reads the array of CORBA long long (java long) values,
- * delegating functionality to
- * {@link #real_longlong_array}.
+ * Reads the array of CORBA long long (java long) values, delegating
+ * functionality to {@link #real_longlong_array}.
*/
public void read_ulonglong_array(long[] x, int offs, int len)
{
@@ -1019,10 +1069,9 @@ public abstract class cdrInput
}
/**
- * Read the unsigned short integer value. Due strange specification,
- * the returned value must be the short type as well, so the
- * the best solution seems just to delegete functionality to
- * read_short.
+ * Read the unsigned short integer value. Due strange specification, the
+ * returned value must be the short type as well, so the the best solution
+ * seems just to delegete functionality to read_short.
*/
public short read_ushort()
{
@@ -1030,8 +1079,8 @@ public abstract class cdrInput
}
/**
- * Read an array of unsigned short values, delegating the
- * functionality to {@link read_short_array}.
+ * Read an array of unsigned short values, delegating the functionality to
+ * {@link read_short_array}.
*/
public void read_ushort_array(short[] x, int offs, int len)
{
@@ -1039,24 +1088,64 @@ public abstract class cdrInput
}
/**
- * Reads the wide character using the encoding, specified in the
- * wide_charset.
+ * Reads the wide character using the encoding, specified in the wide_charset.
*/
public char read_wchar()
{
try
{
if (giop.until_inclusive(1, 1))
- align(2);
+ {
+ align(2);
- if (wide_native)
- return (char) b.readShort();
+ if (wide_native)
+ return (char) b.readShort();
+ else
+ return (char) new InputStreamReader((InputStream) b, wide_charset).read();
+ }
else
- return (char) new InputStreamReader((InputStream) b, wide_charset).read();
+ {
+ int l = b.read();
+ if (l == 2 && wide_native)
+ return b.readChar();
+ else if (l <= 0)
+ {
+ MARSHAL m = new MARSHAL("wchar size " + l);
+ m.minor = Minor.Negative;
+ throw m;
+ }
+ else
+ {
+ byte[] bytes = new byte[l];
+ b.readFully(bytes);
+ String cs;
+
+ if (bytes.length > 2 && bytes[0] == 0xFE && bytes[1] == 0xFF)
+ cs = new String(bytes, 2, bytes.length - 2, wide_charset);
+ else if (bytes.length > 2 && bytes[0] == 0xFF
+ && bytes[1] == 0xFE)
+ {
+ // Litle endian detected - swap bytes.
+ byte t;
+ for (int i = 3; i < bytes.length; i = i + 2)
+ {
+ t = bytes[i];
+ bytes[i - 1] = bytes[i];
+ bytes[i] = t;
+ }
+ cs = new String(bytes, 2, bytes.length - 2, wide_charset);
+ }
+ else
+ cs = new String(bytes, wide_charset);
+
+ return cs.charAt(0);
+ }
+ }
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1067,8 +1156,8 @@ public abstract class cdrInput
}
/**
- * Read an array of "wide chars", each representing a two byte
- * Unicode character, high byte first.
+ * Read an array of "wide chars", each representing a two byte Unicode
+ * character, high byte first.
*/
public void read_wchar_array(char[] x, int offset, int length)
{
@@ -1080,18 +1169,19 @@ public abstract class cdrInput
if (wide_native)
{
for (int i = offset; i < offset + length; i++)
- x [ i ] = (char) b.readShort();
+ x[i] = (char) b.readShort();
}
else
{
- InputStreamReader reader =
- new InputStreamReader((InputStream) b, wide_charset);
+ InputStreamReader reader = new InputStreamReader((InputStream) b,
+ wide_charset);
reader.read(x, offset, length);
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1103,13 +1193,11 @@ public abstract class cdrInput
}
/**
- * Reads the string in wide character format
- * (ussually UTF-16, Unicode). Takes the currently set charset
- * into consideration.
- *
- * If the native (UTF-16) encoding is used
- * of the GIOP protocol is before 1.2, delegates functionality
- * to "plain" {@link #read_wstring_UTF_16}.
+ * Reads the string in wide character format (ussually UTF-16, Unicode). Takes
+ * the currently set charset into consideration.
+ *
+ * If the native (UTF-16) encoding is used of the GIOP protocol is before 1.2,
+ * delegates functionality to "plain" {@link #read_wstring_UTF_16}.
*/
public String read_wstring()
{
@@ -1121,7 +1209,7 @@ public abstract class cdrInput
align(4);
int n = b.readInt();
- byte[] s = new byte[ n ];
+ byte[] s = new byte[n];
b.read(s);
return new String(s, 0, n, wide_charset);
@@ -1129,6 +1217,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1140,9 +1229,9 @@ public abstract class cdrInput
}
/**
- * Reads first length of the string and the all characters as an
- * Unicode (UTF-16) characters. Mind that GIOP 1.1 has the extra
- * null character at the end that must be discarded.
+ * Reads first length of the string and the all characters as an Unicode
+ * (UTF-16) characters. Mind that GIOP 1.1 has the extra null character at the
+ * end that must be discarded.
*/
public String read_wstring_UTF_16()
{
@@ -1150,6 +1239,13 @@ public abstract class cdrInput
{
int p = 0;
int n = read_long();
+
+ if (n<0)
+ {
+ MARSHAL m = new MARSHAL("Negative string size");
+ m.minor = Minor.Negative;
+ throw m;
+ }
// The null terminator that is no longer present since 1.2 .
int nt = giop.since_inclusive(1, 2) ? 0 : 1;
@@ -1157,26 +1253,30 @@ public abstract class cdrInput
// Convert bytes to shorts.
n = n / 2;
- char[] s = new char[ n ];
+ // Empty string.
+ if (n == 0)
+ return "";
+
+ char[] s = new char[n];
for (int i = 0; i < s.length; i++)
- s [ i ] = (char) b.readShort();
+ s[i] = (char) b.readShort();
// Check for the byte order marker here.
- if (s [ 0 ] == 0xFEFF)
+ if (s[0] == 0xFEFF)
{
// Big endian encoding - do nothing, but move the pointer
// one position forward.
p = 1;
}
- else if (s [ 0 ] == 0xFFFE)
+ else if (s[0] == 0xFFFE)
{
// Little endian encoding, swap the bytes and move one
// position forward.
p = 1;
for (int i = p; i < s.length; i++)
- s [ i ] = swap(s [ i ]);
+ s[i] = swap(s[i]);
}
// Discard the null terminator and, if needed, the endian marker.
@@ -1186,6 +1286,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1213,7 +1314,7 @@ public abstract class cdrInput
/**
* Set the current code set context.
*/
- public void setCodeSet(cxCodeSet a_codeset)
+ public void setCodeSet(CodeSetServiceContext a_codeset)
{
this.codeset = a_codeset;
narrow_charset = CharSets_OSF.getName(codeset.char_data);
@@ -1226,7 +1327,7 @@ public abstract class cdrInput
/**
* Get the current code set context.
*/
- public cxCodeSet getCodeSet()
+ public CodeSetServiceContext getCodeSet()
{
return codeset;
}
@@ -1235,9 +1336,9 @@ public abstract class cdrInput
* Read the object that is an instance of the given class. The current
* implementation delegates functionality to the parameterless
* {@link readObject()}.
- *
+ *
* @param klass a class of that this object the instance is.
- *
+ *
* @return the returned object.
*/
public org.omg.CORBA.Object read_Object(Class klass)
@@ -1247,11 +1348,11 @@ public abstract class cdrInput
/**
* Read a value type structure from the stream.
- *
- * OMG specification states the writing format is outside the scope
- * of GIOP definition. This implementation uses java serialization
- * mechanism, calling {@link ObjectInputStream#readObject}
- *
+ *
+ * OMG specification states the writing format is outside the scope of GIOP
+ * definition. This implementation uses java serialization mechanism, calling
+ * {@link ObjectInputStream#readObject}
+ *
* @return an value type structure, unmarshaled from the stream
*/
public Serializable read_Value()
@@ -1260,14 +1361,13 @@ public abstract class cdrInput
}
/**
- * Read the abstract interface. An abstract interface can be either
- * CORBA value type or CORBA object and is returned as an abstract
- * java.lang.Object.
- *
- * As specified in OMG specification, this reads a single
- * boolean and then delegates either to {@link #read_Object()} (for false)
- * or to {@link #read_Value()} (for true).
- *
+ * Read the abstract interface. An abstract interface can be either CORBA
+ * value type or CORBA object and is returned as an abstract java.lang.Object.
+ *
+ * As specified in OMG specification, this reads a single boolean and then
+ * delegates either to {@link #read_Object()} (for false) or to
+ * {@link #read_Value()} (for true).
+ *
* @return an abstract interface, unmarshaled from the stream
*/
public java.lang.Object read_Abstract()
@@ -1276,10 +1376,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_char_array(CharSeqHolder holder, int offset, int length)
{
@@ -1288,10 +1388,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
{
@@ -1300,23 +1400,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the char array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the char array to fit the newly read
+ * values.
+ *
* @param holder_value the existing char array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private char[] ensureArray(char[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new char[ offset + length ];
+ return new char[offset + length];
else if (holder_value.length < offset + length)
{
- char[] value = new char[ offset + length ];
+ char[] value = new char[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1325,10 +1425,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
{
@@ -1337,10 +1437,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_long_array(LongSeqHolder holder, int offset, int length)
{
@@ -1349,23 +1449,22 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the int array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the int array to fit the newly read values.
+ *
* @param holder_value the existing int array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private int[] ensureArray(int[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new int[ offset + length ];
+ return new int[offset + length];
else if (holder_value.length < offset + length)
{
- int[] value = new int[ offset + length ];
+ int[] value = new int[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1374,10 +1473,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_float_array(FloatSeqHolder holder, int offset, int length)
{
@@ -1386,23 +1485,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the float array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the float array to fit the newly read
+ * values.
+ *
* @param holder_value the existing float array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private float[] ensureArray(float[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new float[ offset + length ];
+ return new float[offset + length];
else if (holder_value.length < offset + length)
{
- float[] value = new float[ offset + length ];
+ float[] value = new float[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1411,10 +1510,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_double_array(DoubleSeqHolder holder, int offset, int length)
{
@@ -1423,23 +1522,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the double array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the double array to fit the newly read
+ * values.
+ *
* @param holder_value the existing double array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private double[] ensureArray(double[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new double[ offset + length ];
+ return new double[offset + length];
else if (holder_value.length < offset + length)
{
- double[] value = new double[ offset + length ];
+ double[] value = new double[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1448,10 +1547,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_short_array(ShortSeqHolder holder, int offset, int length)
{
@@ -1467,23 +1566,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the short array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the short array to fit the newly read
+ * values.
+ *
* @param holder_value the existing short array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private short[] ensureArray(short[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new short[ offset + length ];
+ return new short[offset + length];
else if (holder_value.length < offset + length)
{
- short[] value = new short[ offset + length ];
+ short[] value = new short[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1492,10 +1591,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_octet_array(OctetSeqHolder holder, int offset, int length)
{
@@ -1504,23 +1603,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the byte array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the byte array to fit the newly read
+ * values.
+ *
* @param holder_value the existing byte array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private byte[] ensureArray(byte[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new byte[ offset + length ];
+ return new byte[offset + length];
else if (holder_value.length < offset + length)
{
- byte[] value = new byte[ offset + length ];
+ byte[] value = new byte[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1529,51 +1628,49 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_longlong_array(LongLongSeqHolder holder, int offset,
- int length
- )
+ int length)
{
holder.value = ensureArray(holder.value, offset, length);
read_longlong_array(holder.value, offset, length);
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
- int length
- )
+ int length)
{
holder.value = ensureArray(holder.value, offset, length);
read_ulonglong_array(holder.value, offset, length);
}
/**
- * If required, allocate or resize the array of longs to fit the newly
- * read values.
- *
+ * If required, allocate or resize the array of longs to fit the newly read
+ * values.
+ *
* @param holder_value the existing array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private long[] ensureArray(long[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new long[ offset + length ];
+ return new long[offset + length];
else if (holder_value.length < offset + length)
{
- long[] value = new long[ offset + length ];
+ long[] value = new long[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1582,10 +1679,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
{
@@ -1594,23 +1691,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the array of booleans to fit the newly
- * read values.
- *
+ * If required, allocate or resize the array of booleans to fit the newly read
+ * values.
+ *
* @param holder_value the existing array of booleans, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private boolean[] ensureArray(boolean[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new boolean[ offset + length ];
+ return new boolean[offset + length];
else if (holder_value.length < offset + length)
{
- boolean[] value = new boolean[ offset + length ];
+ boolean[] value = new boolean[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1619,38 +1716,38 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_any_array(AnySeqHolder holder, int offset, int length)
{
holder.value = ensureArray(holder.value, offset, length);
for (int i = offset; i < offset + length; i++)
{
- holder.value [ i ] = read_any();
+ holder.value[i] = read_any();
}
}
/**
- * If required, allocate or resize the array of Anys to fit the newly
- * read values.
- *
+ * If required, allocate or resize the array of Anys to fit the newly read
+ * values.
+ *
* @param holder_value the existing array of Anys, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private Any[] ensureArray(Any[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new Any[ offset + length ];
+ return new Any[offset + length];
else if (holder_value.length < offset + length)
{
- Any[] value = new Any[ offset + length ];
+ Any[] value = new Any[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1659,11 +1756,10 @@ public abstract class cdrInput
}
/**
- * This method is required to represent the DataInputStream as a value
- * type object.
- *
- * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0",
- * always.
+ * This method is required to represent the DataInputStream as a value type
+ * object.
+ *
+ * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0", always.
*/
public String[] _truncatable_ids()
{
diff --git a/gnu/CORBA/CDR/cdrOutput.java b/gnu/CORBA/CDR/AbstractCdrOutput.java
index 85f341c91..7b4d5ec58 100644
--- a/gnu/CORBA/CDR/cdrOutput.java
+++ b/gnu/CORBA/CDR/AbstractCdrOutput.java
@@ -1,4 +1,4 @@
-/* cdrOutput.java --
+/* AbstractCdrOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,27 +39,28 @@ exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.BigDecimalHelper;
-import gnu.CORBA.GIOP.CharSets_OSF;
-import gnu.CORBA.GIOP.cxCodeSet;
-import gnu.CORBA.Poa.gnuServantObject;
import gnu.CORBA.IOR;
-import gnu.CORBA.Simple_delegate;
+import gnu.CORBA.IorProvider;
+import gnu.CORBA.Minor;
import gnu.CORBA.TypeCodeHelper;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.GIOP.CharSets_OSF;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
+import org.omg.CORBA.DataInputStream;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.UserException;
+import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.OutputStream;
@@ -68,7 +69,6 @@ import org.omg.CORBA.portable.Streamable;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Serializable;
-
import java.math.BigDecimal;
/**
@@ -79,18 +79,27 @@ import java.math.BigDecimal;
* The same class also implements the {@link DataInputStream},
* providing support for writing the value type objects
* in a user defined way.
+ *
+ * TODO This class uses 16 bits per Unicode character only, as it was until
+ * jdk 1.4 inclusive.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public abstract class cdrOutput
+public abstract class AbstractCdrOutput
extends org.omg.CORBA_2_3.portable.OutputStream
implements org.omg.CORBA.DataOutputStream
{
/**
+ * The runtime, associated with this stream. This field is only used when
+ * reading and writing value types and filled-in in gnu.CORBA.CDR.Vio.
+ */
+ public transient gnuRuntime runtime;
+
+ /**
* This instance is used to convert primitive data types into the
* byte sequences.
*/
- protected abstractDataOutputStream b;
+ protected AbstractDataOutput b;
/**
* The associated orb, if any.
@@ -105,7 +114,7 @@ public abstract class cdrOutput
/**
* The code set information.
*/
- protected cxCodeSet codeset;
+ protected CodeSetServiceContext codeset;
/**
* The name of the currently used narrow charset.
@@ -148,19 +157,19 @@ public abstract class cdrOutput
*
* @param writeTo a stream to write CORBA output to.
*/
- public cdrOutput(java.io.OutputStream writeTo)
+ public AbstractCdrOutput(java.io.OutputStream writeTo)
{
setOutputStream(writeTo);
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
* Creates the stream, requiring the subsequent call
* of {@link #setOutputStream(java.io.OutputStream)}.
*/
- public cdrOutput()
+ public AbstractCdrOutput()
{
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
@@ -168,11 +177,22 @@ public abstract class cdrOutput
* stream is different from 0.
*/
public abstract void setOffset(int an_offset);
+
+ /**
+ * Clone all important settings to another stream.
+ */
+ public void cloneSettings(AbstractCdrOutput stream)
+ {
+ stream.setBigEndian(!little_endian);
+ stream.setCodeSet(getCodeSet());
+ stream.setVersion(giop);
+ stream.setOrb(orb);
+ }
/**
* Set the current code set context.
*/
- public void setCodeSet(cxCodeSet a_codeset)
+ public void setCodeSet(CodeSetServiceContext a_codeset)
{
this.codeset = a_codeset;
narrow_charset = CharSets_OSF.getName(codeset.char_data);
@@ -185,7 +205,7 @@ public abstract class cdrOutput
/**
* Get the current code set context.
*/
- public cxCodeSet getCodeSet()
+ public CodeSetServiceContext getCodeSet()
{
return codeset;
}
@@ -255,9 +275,9 @@ public abstract class cdrOutput
*
* @return the encapsulated stream.
*/
- public cdrOutput createEncapsulation()
+ public AbstractCdrOutput createEncapsulation()
{
- return new encapsulatedOutput(this, !little_endian);
+ return new EncapsulationStream(this, !little_endian);
}
/**
@@ -313,53 +333,56 @@ public abstract class cdrOutput
}
/**
- * Read the CORBA object. The object is written
- * form of the plain (not a string-encoded) IOR profile without the
- * heading endian indicator. The responsible method for reading such
- * data is {@link IOR.write_no_endian}.
- *
- * The null value is written as defined in OMG specification
- * (zero length string, followed by an empty set of profiles).
- */
+ * Read the CORBA object. The object is written form of the plain (not a
+ * string-encoded) IOR profile without the heading endian indicator. The
+ * responsible method for reading such data is {@link IOR.write_no_endian}.
+ *
+ * The null value is written as defined in OMG specification (zero length
+ * string, followed by an empty set of profiles).
+ */
public void write_Object(org.omg.CORBA.Object x)
{
- if (x == null)
+ ORB w_orb = orb;
+ if (x instanceof IorProvider)
{
- IOR.write_null(this);
+ ((IorProvider) x).getIor()._write_no_endian(this);
return;
}
- else if (x instanceof gnuServantObject)
+ else if (x == null)
{
- // The ORB may be different if several ORBs coexist
- // in the same machine.
- gnuServantObject g = (gnuServantObject) x;
- IOR ior = g.orb.getLocalIor(x);
- ior._write_no_endian(this);
+ IOR.write_null(this);
return;
}
else if (x instanceof ObjectImpl)
{
Delegate d = ((ObjectImpl) x)._get_delegate();
- if (d instanceof Simple_delegate)
+ if (d instanceof IorProvider)
{
- Simple_delegate ido = (Simple_delegate) d;
- ido.getIor()._write_no_endian(this);
+ ((IorProvider) d).getIor()._write_no_endian(this);
return;
}
+ else
+ {
+ ORB d_orb = d.orb(x);
+ if (d_orb != null)
+ w_orb = d_orb;
+ }
}
// Either this is not an ObjectImpl or it has the
// unexpected delegate. Try to convert via ORBs
// object_to_string().
- if (orb != null)
+ if (w_orb != null)
{
- IOR ior = IOR.parse(orb.object_to_string(x));
+ IOR ior = IOR.parse(w_orb.object_to_string(x));
ior._write_no_endian(this);
return;
}
else
- throw new BAD_OPERATION("Please set the ORB for this stream.");
+ throw new BAD_OPERATION(
+ "Please set the ORB for this stream, cannot write "
+ + x.getClass().getName());
}
/**
@@ -399,7 +422,7 @@ public abstract class cdrOutput
}
else
{
- primitiveTypeCode p = new primitiveTypeCode(TCKind.tk_null);
+ PrimitiveTypeCode p = new PrimitiveTypeCode(TCKind.tk_null);
write_TypeCode(p);
}
}
@@ -726,6 +749,7 @@ public abstract class cdrOutput
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.CDR;
t.initCause(ex);
throw t;
}
@@ -737,7 +761,7 @@ public abstract class cdrOutput
* representing the stream buffer length (the number of
* bytes being subsequently written).
*/
- public void write_sequence(cdrBufOutput from)
+ public void write_sequence(BufferedCdrOutput from)
{
try
{
@@ -747,6 +771,7 @@ public abstract class cdrOutput
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.CDR;
t.initCause(ex);
throw t;
}
@@ -874,28 +899,41 @@ public abstract class cdrOutput
}
/**
- * Writes the character as two byte short integer (Unicode value),
- * high byte first. Writes in Big Endian, but never writes the
- * endian indicator.
- *
- * The character is always written using the native UTF-16BE charset
- * because its size under arbitrary encoding is not evident.
+ * Writes the character as two byte short integer (Unicode value), high byte
+ * first. Writes in Big Endian, but never writes the endian indicator.
+ *
+ * The character is always written using the native UTF-16BE charset because
+ * its size under arbitrary encoding is not evident.
*/
public void write_wchar(char x)
{
try
{
if (giop.until_inclusive(1, 1))
- align(2);
+ {
+ align(2);
- if (wide_native)
- b.writeShort(x);
+ if (wide_native)
+ b.writeShort(x);
+ else
+ {
+ OutputStreamWriter ow = new OutputStreamWriter(
+ (OutputStream) b, wide_charset);
+ ow.write(x);
+ ow.flush();
+ }
+ }
+ else if (wide_native)
+ {
+ b.writeByte(2);
+ b.writeChar(x);
+ }
else
{
- OutputStreamWriter ow =
- new OutputStreamWriter((OutputStream) b, wide_charset);
- ow.write(x);
- ow.flush();
+ String encoded = new String(new char[] { x });
+ byte[] bytes = encoded.getBytes(wide_charset);
+ b.write(bytes.length + 2);
+ b.write(bytes);
}
}
catch (IOException ex)
@@ -906,13 +944,13 @@ public abstract class cdrOutput
/**
* Write the array of wide chars.
- *
+ *
* @param chars the array of wide chars
* @param offset offset
* @param length length
- *
- * The char array is always written using the native UTF-16BE charset
- * because the character size under arbitrary encoding is not evident.
+ *
+ * The char array is always written using the native UTF-16BE charset because
+ * the character size under arbitrary encoding is not evident.
*/
public void write_wchar_array(char[] chars, int offset, int length)
{
@@ -998,12 +1036,12 @@ public abstract class cdrOutput
/** {@inheritDoc} */
public void write_Abstract(java.lang.Object value)
{
- write_Abstract(value);
+ write_abstract_interface(value);
}
/** {@inheritDoc} */
public void write_Value(Serializable value)
{
- write_Value(value);
+ write_value(value);
}
} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/abstractDataInputStream.java b/gnu/CORBA/CDR/AbstractDataInput.java
index be926254d..4d120fa2c 100644
--- a/gnu/CORBA/CDR/abstractDataInputStream.java
+++ b/gnu/CORBA/CDR/AbstractDataInput.java
@@ -1,4 +1,4 @@
-/* abstractDataInputStream.java --
+/* AbstractDataInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.io.IOException;
* @author Warren Levy (warrenl@cygnus.com)
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
-public interface abstractDataInputStream
+public interface AbstractDataInput
{
/**
* This method reads bytes from the underlying stream into the specified
diff --git a/gnu/CORBA/CDR/abstractDataOutputStream.java b/gnu/CORBA/CDR/AbstractDataOutput.java
index 2f9b8c419..e37c0cb7d 100644
--- a/gnu/CORBA/CDR/abstractDataOutputStream.java
+++ b/gnu/CORBA/CDR/AbstractDataOutput.java
@@ -1,4 +1,4 @@
-/* abstractDataOutputStream.java --
+/* AbstractDataOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.io.IOException;
* @author Warren Levy (warrenl@cygnus.com)
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
-public interface abstractDataOutputStream
+public interface AbstractDataOutput
{
/**
* This method flushes any unwritten bytes to the underlying stream.
diff --git a/gnu/CORBA/CDR/aligningInputStream.java b/gnu/CORBA/CDR/AligningInput.java
index a719b32ee..e2710628a 100644
--- a/gnu/CORBA/CDR/aligningInputStream.java
+++ b/gnu/CORBA/CDR/AligningInput.java
@@ -1,4 +1,4 @@
-/* aligningInputStream.java --
+/* AligningInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,7 +48,7 @@ import org.omg.CORBA.BAD_PARAM;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class aligningInputStream
+public class AligningInput
extends ByteArrayInputStream
{
/**
@@ -61,24 +61,12 @@ public class aligningInputStream
*
* @param a_buffer a buffer to read from.
*/
- public aligningInputStream(byte[] a_buffer)
+ public AligningInput(byte[] a_buffer)
{
super(a_buffer);
}
/**
- * Create a stream, reading from the given buffer region.
- *
- * @param a_buffer a buffer to read from.
- * @param offset the offset of the region.
- * @param length thr length of the region.
- */
- public aligningInputStream(byte[] a_buffer, int offset, int length)
- {
- super(a_buffer, offset, length);
- }
-
- /**
* Set the alignment offset, if the index of the first byte in the
* stream is different from 0.
*/
@@ -119,4 +107,25 @@ public class aligningInputStream
{
return buf;
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return pos + offset;
+ }
+
+ /**
+ * Jump to the given position, taking offset into consideration.
+ */
+ public void seek(int position)
+ {
+ if (position < offset || position > (count+offset))
+ throw new ArrayIndexOutOfBoundsException(position
+ + " is out of valid ["+offset+".." + (count+offset) + "[ range");
+ pos = position - offset;
+ }
}
diff --git a/gnu/CORBA/CDR/aligningOutputStream.java b/gnu/CORBA/CDR/AligningOutput.java
index 8a682c1fd..135f75af6 100644
--- a/gnu/CORBA/CDR/aligningOutputStream.java
+++ b/gnu/CORBA/CDR/AligningOutput.java
@@ -1,4 +1,4 @@
-/* aligningOutputStream.java --
+/* AligningOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.CORBA.CDR;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.omg.CORBA.BAD_PARAM;
@@ -49,7 +48,7 @@ import org.omg.CORBA.BAD_PARAM;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class aligningOutputStream
+public class AligningOutput
extends ByteArrayOutputStream
{
/**
@@ -60,14 +59,14 @@ public class aligningOutputStream
/**
* Create a stream with the default intial buffer size.
*/
- public aligningOutputStream()
+ public AligningOutput()
{
}
/**
* Create a stream with the given intial buffer size.
*/
- public aligningOutputStream(int initial_size)
+ public AligningOutput(int initial_size)
{
super(initial_size);
}
@@ -118,4 +117,32 @@ public class aligningOutputStream
write(0);
}
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return size()+offset;
+ }
+
+ /**
+ * Seek to the given position (not in use).
+ */
+ public void seek(int position)
+ {
+ count = position - offset;
+ }
+
+ /**
+ * Get the buffer without copying it. Use with care.
+ */
+ public byte[] getBuffer()
+ {
+ return buf;
+ }
+
+
}
diff --git a/gnu/CORBA/CDR/ArrayValueHelper.java b/gnu/CORBA/CDR/ArrayValueHelper.java
new file mode 100644
index 000000000..7a4d9c5aa
--- /dev/null
+++ b/gnu/CORBA/CDR/ArrayValueHelper.java
@@ -0,0 +1,254 @@
+/* ArrayValueHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.ObjectCreator;
+
+import org.omg.CORBA.BooleanSeqHelper;
+import org.omg.CORBA.CharSeqHelper;
+import org.omg.CORBA.DoubleSeqHelper;
+import org.omg.CORBA.FloatSeqHelper;
+import org.omg.CORBA.LongLongSeqHelper;
+import org.omg.CORBA.LongSeqHelper;
+import org.omg.CORBA.OctetSeqHelper;
+import org.omg.CORBA.ShortSeqHelper;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.rmi.Remote;
+
+import javax.rmi.CORBA.Util;
+import javax.rmi.CORBA.ValueHandler;
+
+/**
+ * Writes arrays as a boxed value types. A single instance is used to write a
+ * single array. This class is only used with RMI/IIOP, to handle array boxed
+ * values.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+class ArrayValueHelper
+ implements BoxedValueHelper
+{
+ /**
+ * The value handler (one for all instances).
+ */
+ static ValueHandler handler = Util.createValueHandler();
+
+ /**
+ * A class of the array being written.
+ */
+ Class arrayClass;
+
+ /**
+ * The array component class.
+ */
+ Class component;
+
+ /**
+ * The array component repository Id.
+ */
+ String componentId;
+
+ /**
+ * If true, the array members are written as objects rather than as values.
+ * True for Remotes and CORBA objects.
+ */
+ boolean written_as_object()
+ {
+ return org.omg.CORBA.Object.class.isAssignableFrom(component)
+ || Remote.class.isAssignableFrom(component);
+ }
+
+ /**
+ * Creates the instance of the helper to write this specific array class.
+ */
+ ArrayValueHelper(Class an_arrayClass)
+ {
+ arrayClass = an_arrayClass;
+ }
+
+ /**
+ * Get the array repository Id that will be the RMI repository id.
+ */
+ public String get_id()
+ {
+ return ObjectCreator.getRepositoryId(arrayClass);
+ }
+
+ /**
+ * Read the array from the input stream.
+ */
+ public Serializable read_value(InputStream input)
+ {
+ if (input instanceof HeadlessInput)
+ {
+ ((HeadlessInput) input).subsequentCalls = true;
+ }
+
+ component = arrayClass.getComponentType();
+
+ if (component.equals(byte.class))
+ return OctetSeqHelper.read(input);
+ else if (component.equals(String.class))
+ {
+ // String array is optimized because this may be frequent.
+ String[] s = new String[input.read_long()];
+
+ for (int i = 0; i < s.length; i++)
+ s[i] = (String) Vio.read(input, Vio.m_StringValueHelper);
+ return s;
+ }
+ else if (component.equals(int.class))
+ return LongSeqHelper.read(input);
+ else if (component.equals(long.class))
+ return LongLongSeqHelper.read(input);
+ else if (component.equals(double.class))
+ return DoubleSeqHelper.read(input);
+ else if (component.equals(float.class))
+ return FloatSeqHelper.read(input);
+ else if (component.equals(boolean.class))
+ return BooleanSeqHelper.read(input);
+ else if (component.equals(short.class))
+ return ShortSeqHelper.read(input);
+ else if (component.equals(char.class))
+ return CharSeqHelper.read(input);
+ else
+ {
+ // Read others, use reflection.
+ int n = input.read_long();
+
+ gnuValueStream s = null;
+
+ Serializable array = (Serializable) Array.newInstance(component, n);
+ if (written_as_object())
+ for (int i = 0; i < n; i++)
+ {
+ gnuRuntime g;
+ int position;
+ if (input instanceof gnuValueStream)
+ {
+ s = (gnuValueStream) input;
+ g = s.getRunTime();
+ position = s.getPosition();
+ }
+ else
+ {
+ g = null;
+ position = -1;
+ }
+
+ if (input instanceof HeadlessInput)
+ ((HeadlessInput) input).subsequentCalls = true;
+
+ Object o = handler.readValue(input, position, component, null, g);
+ Array.set(array, i, o);
+ }
+ else
+ for (int i = 0; i < n; i++)
+ Array.set(array, i, Vio.read(input, component));
+ return array;
+ }
+ }
+
+ /**
+ * Write the array to the input stream.
+ */
+ public void write_value(OutputStream output, Serializable value)
+ {
+ if (output instanceof gnuValueStream)
+ {
+ gnuRuntime r = ((gnuValueStream) output).getRunTime();
+ if (r != null)
+ r.target = null;
+ }
+
+ if (value instanceof byte[])
+ OctetSeqHelper.write(output, (byte[]) value);
+ else if (value instanceof String[])
+ {
+ String[] s = (String[]) value;
+ output.write_long(s.length);
+ for (int i = 0; i < s.length; i++)
+ Vio.write(output, s[i], Vio.m_StringValueHelper);
+ }
+ else if (value instanceof int[])
+ LongSeqHelper.write(output, (int[]) value);
+ else if (value instanceof long[])
+ LongLongSeqHelper.write(output, (long[]) value);
+ else if (value instanceof double[])
+ DoubleSeqHelper.write(output, (double[]) value);
+ else if (value instanceof float[])
+ FloatSeqHelper.write(output, (float[]) value);
+ else if (value instanceof boolean[])
+ BooleanSeqHelper.write(output, (boolean[]) value);
+ else if (value instanceof short[])
+ ShortSeqHelper.write(output, (short[]) value);
+ else if (value instanceof char[])
+ CharSeqHelper.write(output, (char[]) value);
+ else
+ {
+ // Write others, use reflection.
+ component = arrayClass.getComponentType();
+
+ int n = Array.getLength(value);
+ output.write_long(n);
+ if (written_as_object())
+ for (int i = 0; i < n; i++)
+ {
+ Object o = Array.get(value, i);
+ if (o == null)
+ output.write_Object(null);
+ else
+ // CORBA objects have another notation.
+ handler.writeValue(output, (Serializable) o);
+ }
+ else
+ {
+ for (int i = 0; i < n; i++)
+ Vio.write(output, (Serializable) Array.get(value, i),
+ component);
+ }
+
+ }
+ }
+}
diff --git a/gnu/CORBA/CDR/BigEndianInputStream.java b/gnu/CORBA/CDR/BigEndianInputStream.java
index bc019396a..1559d75a4 100644
--- a/gnu/CORBA/CDR/BigEndianInputStream.java
+++ b/gnu/CORBA/CDR/BigEndianInputStream.java
@@ -49,7 +49,7 @@ import java.io.InputStream;
*/
public class BigEndianInputStream
extends DataInputStream
- implements abstractDataInputStream
+ implements AbstractDataInput
{
/**
* Delegates to the parent constructor.
diff --git a/gnu/CORBA/CDR/BigEndianOutputStream.java b/gnu/CORBA/CDR/BigEndianOutputStream.java
index e0aa7da77..7d3b02ec9 100644
--- a/gnu/CORBA/CDR/BigEndianOutputStream.java
+++ b/gnu/CORBA/CDR/BigEndianOutputStream.java
@@ -50,7 +50,7 @@ import java.io.OutputStream;
*/
public class BigEndianOutputStream
extends DataOutputStream
- implements abstractDataOutputStream
+ implements AbstractDataOutput
{
/**
* Delegate functionality to the parent constructor.
diff --git a/gnu/CORBA/CDR/cdrBufOutput.java b/gnu/CORBA/CDR/BufferedCdrOutput.java
index 47f5f176b..69bf95beb 100644
--- a/gnu/CORBA/CDR/cdrBufOutput.java
+++ b/gnu/CORBA/CDR/BufferedCdrOutput.java
@@ -1,4 +1,4 @@
-/* cdrBufOutput.java --
+/* BufferedCdrOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,41 +41,47 @@ package gnu.CORBA.CDR;
import java.io.ByteArrayOutputStream;
/**
- * A CORBA output stream, writing data into the internal
- * buffer ({@link ByteArrayOutputStream}).
- *
+ * A CORBA output stream, writing data into the internal buffer ({@link ByteArrayOutputStream}).
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class cdrBufOutput
- extends cdrOutput
+public class BufferedCdrOutput
+ extends AbstractCdrOutput
+ implements gnuValueStream
{
/**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
* The byte buffer.
*/
- public final aligningOutputStream buffer;
+ public final AligningOutput buffer;
/**
* Creates the instance with the given initial buffer size.
+ *
* @param bufSize the buffer size.
*/
- public cdrBufOutput(int bufSize)
+ public BufferedCdrOutput(int bufSize)
{
- buffer = new aligningOutputStream(bufSize);
+ buffer = new AligningOutput(bufSize);
setOutputStream(buffer);
}
/**
* Creates the instance with the default buffer size.
*/
- public cdrBufOutput()
+ public BufferedCdrOutput()
{
- buffer = new aligningOutputStream();
+ buffer = new AligningOutput();
setOutputStream(buffer);
}
/**
- * Set the alignment offset, if the index of the first byte in the
- * stream is different from 0.
+ * Set the alignment offset, if the index of the first byte in the stream is
+ * different from 0.
*/
public void setOffset(int an_offset)
{
@@ -95,7 +101,7 @@ public class cdrBufOutput
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
- cdrBufInput in = new cdrBufInput(buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(buffer.toByteArray());
in.setOrb(orb);
in.setVersion(giop);
@@ -112,4 +118,39 @@ public class cdrBufOutput
buffer.reset();
setOutputStream(buffer);
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return buffer.getPosition();
+ }
+
+ /**
+ * Get the associated RunTime.
+ */
+ public gnuRuntime getRunTime()
+ {
+ return runtime;
+ }
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime)
+ {
+ runtime = a_runtime;
+ }
+
+ /**
+ * Seek to the given position.
+ */
+ public void seek(int position)
+ {
+ buffer.seek(position);
+ }
+
}
diff --git a/gnu/CORBA/CDR/cdrBufInput.java b/gnu/CORBA/CDR/BufferredCdrInput.java
index 3cab7216c..f0159a88d 100644
--- a/gnu/CORBA/CDR/cdrBufInput.java
+++ b/gnu/CORBA/CDR/BufferredCdrInput.java
@@ -1,4 +1,4 @@
-/* cdrBufInput.java --
+/* BufferredCdrInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,18 +43,20 @@ package gnu.CORBA.CDR;
* The CDR input stream that reads data from the byte buffer.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- *
- * TODO character encoding. Now the encoding can be set, but it is ignored.
- * If you take this task, scan 'TODO character encoding' for
- * relevant places.
*/
-public class cdrBufInput
- extends cdrInput
+public class BufferredCdrInput
+ extends AbstractCdrInput
+ implements gnuValueStream
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The byte array input stream to read data from.
*/
- public final aligningInputStream buffer;
+ public final AligningInput buffer;
/**
* Creates the CDR input stream that reads from the given buffer
@@ -62,9 +64,9 @@ public class cdrBufInput
*
* @param a_buffer an array to read from.
*/
- public cdrBufInput(byte[] a_buffer)
+ public BufferredCdrInput(byte[] a_buffer)
{
- buffer = new aligningInputStream(a_buffer);
+ buffer = new AligningInput(a_buffer);
setInputStream(buffer);
}
@@ -112,4 +114,40 @@ public class cdrBufInput
buffer.reset();
setInputStream(buffer);
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return buffer.getPosition();
+ }
+
+ /**
+ * Jump to the given position, taking offset into consideration.
+ */
+ public void seek(int position)
+ {
+ buffer.seek(position);
+ setInputStream(buffer);
+ }
+
+ /**
+ * Get the associated RunTime.
+ */
+ public gnuRuntime getRunTime()
+ {
+ return runtime;
+ }
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime)
+ {
+ runtime = a_runtime;
+ }
+
}
diff --git a/gnu/CORBA/CDR/encapsulatedOutput.java b/gnu/CORBA/CDR/EncapsulationStream.java
index 3350291bc..4945d9c90 100644
--- a/gnu/CORBA/CDR/encapsulatedOutput.java
+++ b/gnu/CORBA/CDR/EncapsulationStream.java
@@ -48,8 +48,8 @@ import java.io.IOException;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class encapsulatedOutput
- extends cdrOutput
+public class EncapsulationStream
+ extends AbstractCdrOutput
{
/**
* The Big Endian (most siginificant byte first flag).
@@ -64,7 +64,7 @@ public class encapsulatedOutput
/**
* The byte buffer.
*/
- public final aligningOutputStream buffer;
+ public final AligningOutput buffer;
/**
* The stream, where the data are being encapsulated.
@@ -75,11 +75,11 @@ public class encapsulatedOutput
* Create the EncapsulationOutput with the given parent stream
* and the specified encoding.
*/
- public encapsulatedOutput(org.omg.CORBA.portable.OutputStream _parent,
+ public EncapsulationStream(org.omg.CORBA.portable.OutputStream _parent,
boolean use_big_endian)
{
super();
- buffer = new aligningOutputStream();
+ buffer = new AligningOutput();
setOutputStream(buffer);
parent = _parent;
write(use_big_endian?BIG_ENDIAN:LITTLE_ENDIAN);
@@ -126,7 +126,7 @@ public class encapsulatedOutput
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
- cdrBufInput in = new cdrBufInput(buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(buffer.toByteArray());
in.setOrb(orb);
in.setVersion(giop);
diff --git a/gnu/CORBA/CDR/HeadlessInput.java b/gnu/CORBA/CDR/HeadlessInput.java
new file mode 100644
index 000000000..0c18dafb1
--- /dev/null
+++ b/gnu/CORBA/CDR/HeadlessInput.java
@@ -0,0 +1,749 @@
+/* HeadlessInput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.AnySeqHolder;
+import org.omg.CORBA.BooleanSeqHolder;
+import org.omg.CORBA.CharSeqHolder;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.DataInputStream;
+import org.omg.CORBA.DoubleSeqHolder;
+import org.omg.CORBA.FloatSeqHolder;
+import org.omg.CORBA.LongLongSeqHolder;
+import org.omg.CORBA.LongSeqHolder;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.OctetSeqHolder;
+import org.omg.CORBA.Principal;
+import org.omg.CORBA.ShortSeqHolder;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ULongLongSeqHolder;
+import org.omg.CORBA.ULongSeqHolder;
+import org.omg.CORBA.UShortSeqHolder;
+import org.omg.CORBA.WCharSeqHolder;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Substitutes the main stream in factories when the header is already behind.
+ * Overrides methods that may be invoked from the factory, forcing not to read
+ * the header if called first time on this stream.
+ *
+ * This stream reverts to default behavior if one or more call are made (reading
+ * value types that are nested fields of the value type).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class HeadlessInput
+ extends org.omg.CORBA_2_3.portable.InputStream
+ implements DataInputStream, gnuValueStream
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Indicates that no positional information is available.
+ */
+ static final int NONE = -1;
+
+ /**
+ * If true, this is not the first call.
+ */
+ public boolean subsequentCalls;
+
+ /**
+ * The enclosed stream.
+ */
+ final BufferredCdrInput stream;
+
+ /**
+ * Create an instance, reading from the given buffer.
+ *
+ * @param a_stram a stream from where the data will be read.
+ * @param inheritSettings a stream from that endian and other settings are
+ * inherited.
+ */
+ public HeadlessInput(BufferredCdrInput a_stream, InputStream inheritSettings)
+ {
+ stream = a_stream;
+
+ if (inheritSettings instanceof AbstractCdrInput)
+ {
+ AbstractCdrInput t = (AbstractCdrInput) inheritSettings;
+ t.cloneSettings(stream);
+ }
+ else if (stream.orb() == null)
+ stream.setOrb(inheritSettings.orb());
+
+ if (inheritSettings instanceof gnuValueStream
+ && stream.getRunTime() == null)
+ {
+ stream.setRunTime(((gnuValueStream) inheritSettings).getRunTime());
+ }
+ }
+
+ /**
+ * Tries to read using boxed value helper.
+ */
+ public Serializable read_value(BoxedValueHelper helper)
+ {
+ if (subsequentCalls)
+ return stream.read_value(helper);
+ else
+ {
+ subsequentCalls = true;
+ return helper.read_value(this);
+ }
+ }
+
+ /**
+ * Tries to locate a factory using repository id.
+ */
+ public Serializable read_value(String repository_id)
+ {
+ if (subsequentCalls)
+ return stream.read_value(repository_id);
+ else
+ {
+ subsequentCalls = true;
+ Serializable value = (Serializable) Vio.readValue(this, NONE, null,
+ null, repository_id, null, null);
+ return value;
+ }
+ }
+
+ /**
+ * Try to read when having an unitialised value.
+ */
+ public Serializable read_value(Serializable value)
+ {
+ if (subsequentCalls)
+ return stream.read_value(value);
+ else
+ {
+ subsequentCalls = true;
+ value = (Serializable) Vio.readValue(this, NONE, value, null, null,
+ null, null);
+ return value;
+ }
+ }
+
+ /**
+ * Try to read when having an unitialised value.
+ */
+ public Serializable read_value(Class clz)
+ {
+ if (subsequentCalls)
+ return stream.read_value(clz);
+ else
+ {
+ try
+ {
+ subsequentCalls = true;
+ Serializable value = (Serializable) Vio.instantiateAnyWay(clz);
+ value = (Serializable) Vio.readValue(this, NONE, value, null, null,
+ null, null);
+ return value;
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Can't read an instance of "
+ + clz.getName());
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int available()
+ throws IOException
+ {
+ return stream.available();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void close()
+ throws IOException
+ {
+ stream.close();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void mark(int readlimit)
+ {
+ stream.mark(readlimit);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public boolean markSupported()
+ {
+ return stream.markSupported();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public ORB orb()
+ {
+ return stream.orb();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Object read_abstract_interface()
+ {
+ return stream.read_abstract_interface();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Object read_abstract_interface(Class clz)
+ {
+ return stream.read_abstract_interface(clz);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Any read_any()
+ {
+ return stream.read_any();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_boolean_array(boolean[] value, int offset, int length)
+ {
+ stream.read_boolean_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public boolean read_boolean()
+ {
+ return stream.read_boolean();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_char_array(char[] value, int offset, int length)
+ {
+ stream.read_char_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public char read_char()
+ {
+ return stream.read_char();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Context read_Context()
+ {
+ return stream.read_Context();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_double_array(double[] value, int offset, int length)
+ {
+ stream.read_double_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public double read_double()
+ {
+ return stream.read_double();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public BigDecimal read_fixed()
+ {
+ return stream.read_fixed();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_float_array(float[] value, int offset, int length)
+ {
+ stream.read_float_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public float read_float()
+ {
+ return stream.read_float();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_long_array(int[] value, int offset, int length)
+ {
+ stream.read_long_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read_long()
+ {
+ return stream.read_long();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_longlong_array(long[] value, int offset, int length)
+ {
+ stream.read_longlong_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public long read_longlong()
+ {
+ return stream.read_longlong();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public org.omg.CORBA.Object read_Object()
+ {
+ return stream.read_Object();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public org.omg.CORBA.Object read_Object(Class klass)
+ {
+ return stream.read_Object(klass);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_octet_array(byte[] value, int offset, int length)
+ {
+ stream.read_octet_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public byte read_octet()
+ {
+ return stream.read_octet();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Principal read_Principal()
+ {
+ return stream.read_Principal();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_short_array(short[] value, int offset, int length)
+ {
+ stream.read_short_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public short read_short()
+ {
+ return stream.read_short();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public String read_string()
+ {
+ return stream.read_string();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public TypeCode read_TypeCode()
+ {
+ return stream.read_TypeCode();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulong_array(int[] value, int offset, int length)
+ {
+ stream.read_ulong_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read_ulong()
+ {
+ return stream.read_ulong();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulonglong_array(long[] value, int offset, int length)
+ {
+ stream.read_ulonglong_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public long read_ulonglong()
+ {
+ return stream.read_ulonglong();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ushort_array(short[] value, int offset, int length)
+ {
+ stream.read_ushort_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public short read_ushort()
+ {
+ return stream.read_ushort();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Serializable read_value()
+ {
+ return read_value((Serializable) null);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_wchar_array(char[] value, int offset, int length)
+ {
+ stream.read_wchar_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public char read_wchar()
+ {
+ return stream.read_wchar();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public String read_wstring()
+ {
+ return stream.read_wstring();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read()
+ throws IOException
+ {
+ return stream.read();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read(byte[] b, int off, int len)
+ throws IOException
+ {
+ return stream.read(b, off, len);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read(byte[] b)
+ throws IOException
+ {
+ return stream.read(b);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void reset()
+ throws IOException
+ {
+ stream.reset();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public long skip(long n)
+ throws IOException
+ {
+ return stream.skip(n);
+ }
+
+ /**
+ * Get a string representation.
+ */
+ public String toString()
+ {
+ return "HeadlessInput+" + stream.toString();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public String[] _truncatable_ids()
+ {
+ return stream._truncatable_ids();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Object read_Abstract()
+ {
+ return stream.read_Abstract();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_any_array(AnySeqHolder holder, int offset, int length)
+ {
+ stream.read_any_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
+ {
+ stream.read_boolean_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_char_array(CharSeqHolder holder, int offset, int length)
+ {
+ stream.read_char_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_double_array(DoubleSeqHolder holder, int offset, int length)
+ {
+ stream.read_double_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_float_array(FloatSeqHolder holder, int offset, int length)
+ {
+ stream.read_float_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_long_array(LongSeqHolder holder, int offset, int length)
+ {
+ stream.read_long_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_longlong_array(LongLongSeqHolder holder, int offset,
+ int length)
+ {
+ stream.read_longlong_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_octet_array(OctetSeqHolder holder, int offset, int length)
+ {
+ stream.read_octet_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_short_array(ShortSeqHolder holder, int offset, int length)
+ {
+ stream.read_short_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
+ {
+ stream.read_ulong_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
+ int length)
+ {
+ stream.read_ulonglong_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ushort_array(UShortSeqHolder holder, int offset, int length)
+ {
+ stream.read_ushort_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to read_value.
+ */
+ public Serializable read_Value()
+ {
+ return read_value();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
+ {
+ stream.read_wchar_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int getPosition()
+ {
+ return stream.getPosition();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public gnuRuntime getRunTime()
+ {
+ return stream.runtime;
+ }
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime)
+ {
+ stream.runtime = a_runtime;
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void seek(int position)
+ {
+ stream.seek(position);
+ }
+
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/IDLTypeHelper.java b/gnu/CORBA/CDR/IDLTypeHelper.java
new file mode 100644
index 000000000..3259a4877
--- /dev/null
+++ b/gnu/CORBA/CDR/IDLTypeHelper.java
@@ -0,0 +1,169 @@
+/* IDLTypeHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * Handles case when the CORBA IDL type with the known helper is wrapped into
+ * Value type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class IDLTypeHelper
+ implements BoxedValueHelper
+{
+ /**
+ * A helper class.
+ */
+ protected Class helper;
+
+ /**
+ * Argument values for Helper.id().
+ */
+ static final Object[] ARGS_ID_V = new Object[0];
+
+ /**
+ * Argument types for Helper.id()).
+ */
+ static final Class[] ARGS_ID = new Class[0];
+
+ /**
+ * Argument types for Helper.read.
+ */
+ static final Class[] ARGS_READ = new Class[] { org.omg.CORBA.portable.InputStream.class };
+
+ /**
+ * Create an IDLTypeHelper that works via given helper class.
+ */
+ public IDLTypeHelper(Class a_helperClass)
+ {
+ helper = a_helperClass;
+ }
+
+ /**
+ * Get the Id, returned by this helper (use reflection).
+ */
+ public String get_id()
+ {
+ try
+ {
+ Method m = helper.getMethod("id", ARGS_ID);
+ return (String) m.invoke(null, ARGS_ID_V);
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL(msg() + " id()");
+ m.minor = Minor.Boxed;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Read an instance from the stream.
+ */
+ public Serializable read_value(InputStream input)
+ {
+ try
+ {
+ Method m = helper.getMethod("read", ARGS_READ);
+ return (Serializable) m.invoke(null, new Object[] { input });
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL(msg() + " read(..)");
+ m.minor = Minor.Boxed;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Write the instance to the stream.
+ */
+ public void write_value(OutputStream output, Serializable value)
+ {
+ try
+ {
+ Method[] m = helper.getMethods();
+
+ for (int i = 0; i < m.length; i++)
+ {
+ if (m[i].getName().equals("write")
+ && ((m[i].getModifiers() & Modifier.STATIC) != 0))
+ {
+ Class[] p = m[i].getParameterTypes();
+
+ if (p.length == 2 && OutputStream.class.isAssignableFrom(p[0])
+ && p[1].isAssignableFrom(value.getClass()))
+ {
+ m[i].invoke(null, new Object[] { output, value });
+ return;
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL(msg() + " write(..)");
+ m.minor = Minor.Boxed;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Create the start of message for exceptions.
+ */
+ String msg()
+ {
+ return "Failed calling " + helper.getName() + " method: ";
+ }
+
+}
diff --git a/gnu/CORBA/CDR/LittleEndianInputStream.java b/gnu/CORBA/CDR/LittleEndianInputStream.java
index b71a9a4f6..02cfa08ae 100644
--- a/gnu/CORBA/CDR/LittleEndianInputStream.java
+++ b/gnu/CORBA/CDR/LittleEndianInputStream.java
@@ -55,7 +55,7 @@ import java.io.PushbackInputStream;
*/
public class LittleEndianInputStream
extends FilterInputStream
- implements abstractDataInputStream
+ implements AbstractDataInput
{
// Byte buffer, used to make primitive read calls more efficient.
byte[] buf = new byte[ 8 ];
diff --git a/gnu/CORBA/CDR/LittleEndianOutputStream.java b/gnu/CORBA/CDR/LittleEndianOutputStream.java
index a6d56cfa6..6791a82e7 100644
--- a/gnu/CORBA/CDR/LittleEndianOutputStream.java
+++ b/gnu/CORBA/CDR/LittleEndianOutputStream.java
@@ -55,7 +55,7 @@ import java.io.OutputStream;
*/
public class LittleEndianOutputStream
extends FilterOutputStream
- implements abstractDataOutputStream
+ implements AbstractDataOutput
{
/**
* This method initializes an instance of <code>DataOutputStream</code> to
diff --git a/gnu/CORBA/CDR/UnknownExceptionCtxHandler.java b/gnu/CORBA/CDR/UnknownExceptionCtxHandler.java
new file mode 100644
index 000000000..314dd8eb9
--- /dev/null
+++ b/gnu/CORBA/CDR/UnknownExceptionCtxHandler.java
@@ -0,0 +1,292 @@
+/* UnknownExceptionCtxHandler.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.GIOP.ServiceContext;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.StringValueHelper;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.lang.reflect.Constructor;
+import java.util.StringTokenizer;
+
+import javax.rmi.CORBA.Util;
+
+/**
+ * Reads the data about an unknown exception from the UnknownExceptionInfo.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class UnknownExceptionCtxHandler
+ extends Vio
+{
+ /**
+ * Encode exception and add its recored to the message service contexts.
+ */
+ public static ServiceContext[] addExceptionContext(ServiceContext[] current,
+ Throwable exception, Object details)
+ {
+ try
+ {
+ ServiceContext[] c = new ServiceContext[current.length + 1];
+ if (current.length > 0)
+ System.arraycopy(current, 0, c, 0, current.length);
+
+ BufferedCdrOutput output = new BufferedCdrOutput();
+
+ if (details instanceof OutputStream)
+ output.setOrb(((OutputStream) output).orb());
+
+ if (details instanceof AbstractCdrOutput)
+ ((AbstractCdrOutput) details).cloneSettings(output);
+
+ write(output, exception);
+
+ ServiceContext xc = new ServiceContext();
+ xc.context_id = ServiceContext.UnknownExceptionInfo;
+ xc.context_data = output.buffer.toByteArray();
+ c[current.length] = xc;
+ return c;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return current;
+ }
+ }
+
+ /**
+ * Write data about unknown exception.
+ */
+ public static void write(BufferedCdrOutput output, Throwable t)
+ {
+ t.fillInStackTrace();
+ output.write_Value(t);
+ }
+
+ /**
+ * Read the data about an unknown exception from the UnknownExceptionInfo.
+ * Following the documentation, this must be just value type, but it seems
+ * that in Sun's implementation is is not, as starts from 0x0. For value type,
+ * this would be null.
+ *
+ * TODO Implement reading and writing in Sun format, making Classpath IIOP
+ * interoperable with Sun's implementation. Current inmplementation reads and
+ * reproduces the exception class type only.
+ *
+ * @param input the input stream to read the context (orb and other settings
+ * are inherited from the main stream that received the message).
+ *
+ * @param contexts all service contexts that were present in the message.
+ *
+ * @return the Throwable, extracted from context, on null, if this has failed.
+ */
+ public static Throwable read(BufferredCdrInput input, ServiceContext[] contexts)
+ {
+ input.mark(Integer.MAX_VALUE);
+
+ int h = input.read_long();
+ if (h == 0)
+ {
+ // This block reads exception info in the Sun specific format.
+ // (currently we read the exception name only).
+ try
+ {
+ // We may need to jump back if the value is read via value
+ // factory.
+ input.mark(512);
+
+ int value_tag = input.read_long();
+ checkTag(value_tag);
+
+ String codebase = null;
+ String[] ids = null;
+ String id = null;
+
+ // Check for the agreed null value.
+ if (value_tag == vt_NULL)
+ return null;
+ else if (value_tag == vt_INDIRECTION)
+ return (Throwable) readIndirection(input);
+ else
+ {
+ // Read the value.
+ if ((value_tag & vf_CODEBASE) != 0)
+ {
+ // The codebase is present. The codebase is a space
+ // separated list of URLs from where the implementing
+ // code can be downloaded.
+ codebase = read_string(input);
+ }
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0)
+ {
+ // Multiple supported repository ids are present.
+ ids = read_string_array(input);
+ }
+ else if ((value_tag & vf_ID) != 0)
+ {
+ // Single supported repository id is present.
+ id = read_string(input);
+ }
+ }
+
+ java.lang.Object ox = createInstance(id, ids, codebase);
+
+ return (Throwable) ox;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+ else
+ {
+ input.reset();
+ // Read as defined in OMG documentation.
+ return (Throwable) input.read_Value();
+ }
+ }
+
+ /**
+ * Load exception by name and create the instance. The reason why this is
+ * different from Vio is because some exceptions have no parameterless
+ * constructor, but have a constructor with the string parameter instead.
+ */
+ static Object createInstance(String id, String[] ids, String codebase)
+ {
+ Object o = _createInstance(id, codebase);
+
+ if (ids != null)
+ for (int i = 0; i < ids.length && o == null; i++)
+ o = _createInstance(ids[i], codebase);
+ return o;
+ }
+
+ static Object _createInstance(String id, String codebase)
+ {
+ if (id == null)
+ return null;
+ if (id.equals(StringValueHelper.id()))
+ return "";
+ StringTokenizer st = new StringTokenizer(id, ":");
+
+ String prefix = st.nextToken();
+ if (prefix.equalsIgnoreCase("IDL"))
+ return ObjectCreator.Idl2Object(id);
+ else if (prefix.equalsIgnoreCase("RMI"))
+ {
+ String className = st.nextToken();
+ String hashCode = st.nextToken();
+ String sid = null;
+ if (st.hasMoreElements())
+ sid = st.nextToken();
+
+ try
+ {
+ Class objectClass = Util.loadClass(className, codebase,
+ Vio.class.getClassLoader());
+
+ String rid = ObjectCreator.getRepositoryId(objectClass);
+
+ if (!rid.equals(id))
+ {
+ // If direct string comparison fails, compare by meaning.
+ StringTokenizer st2 = new StringTokenizer(rid, ":");
+ if (!st2.nextToken().equals("RMI"))
+ throw new InternalError("RMI format expected: '" + rid + "'");
+ if (!st2.nextToken().equals(className))
+ throwIt("Class name mismatch", id, rid, null);
+
+ try
+ {
+ long h1 = Long.parseLong(hashCode, 16);
+ long h2 = Long.parseLong(st2.nextToken(), 16);
+ if (h1 != h2)
+ throwIt("Hashcode mismatch", id, rid, null);
+
+ if (sid != null && st2.hasMoreTokens())
+ {
+ long s1 = Long.parseLong(hashCode, 16);
+ long s2 = Long.parseLong(st2.nextToken(), 16);
+ if (s1 != s2)
+ throwIt("serialVersionUID mismatch", id, rid, null);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throwIt("Invalid hashcode or svuid format: ", id, rid, e);
+ }
+ }
+
+ // Some RemoteExceptions have no public parameterless constructor,
+ // but they have constructor taking string as parameter.
+ try
+ {
+ return objectClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ // Try instantiate passing string as parameter.
+ Constructor c = objectClass.getConstructor(new Class[] { String.class });
+ return c.newInstance(new Object[] { "<message unavailable>" });
+ }
+ }
+ catch (MARSHAL m)
+ {
+ m.minor = Minor.Instantiation;
+ throw m;
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Unable to instantiate " + id);
+ m.minor = Minor.Instantiation;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ else
+ throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
+ }
+}
diff --git a/gnu/CORBA/CDR/VMVio.java b/gnu/CORBA/CDR/VMVio.java
new file mode 100644
index 000000000..9b719fd7c
--- /dev/null
+++ b/gnu/CORBA/CDR/VMVio.java
@@ -0,0 +1,101 @@
+/* VMVio.java -- Native operations, required by value IO.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+/**
+ * This is a temporary replacement for the native call that would allocate
+ * objects without public constructors. The replacement only allocates
+ * objects with public parameterless constructor and objects with public
+ * constructor taking string (like some Throwables).
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ *
+ * TODO FIXME replace by native call like in VMObjectInputStream.
+ * Required modification of Classpath the build system.
+ */
+
+
+package gnu.CORBA.CDR;
+
+import java.lang.reflect.Constructor;
+
+public class VMVio
+{
+ /**
+ * Allocates a new Object of type clazz but without running the default
+ * constructor on it. It then calls the given constructor on it. The given
+ * constructor method comes from the constr_clazz which is a super class of
+ * the given clazz.
+ */
+ public static Object allocateObject(Class clazz, Class constr_clazz,
+ Constructor constructor)
+ throws InstantiationException
+ {
+ try
+ {
+ Constructor c = clazz.getConstructor(new Class[0]);
+ c.setAccessible(true);
+ return c.newInstance(new Object[0]);
+ }
+ catch (Exception ex)
+ {
+ try
+ {
+ Constructor c = clazz.getConstructor(new Class[] { String.class });
+ return c.newInstance(new Object[] { "" });
+ }
+ catch (Exception ex2)
+ {
+ Constructor c[] = clazz.getConstructors();
+
+ for (int i = 0; i < c.length; i++)
+ {
+ try
+ {
+ c[i].setAccessible(true);
+ Class[] args = c[i].getParameterTypes();
+ return c[i].newInstance(new Object[args.length]);
+ }
+ catch (Exception ex3)
+ {
+ // Try another one.
+ }
+ }
+ }
+ throw new InstantiationException(clazz.getName());
+ }
+ }
+}
diff --git a/gnu/CORBA/CDR/Vio.java b/gnu/CORBA/CDR/Vio.java
index 0a37132b2..fd878cb35 100644
--- a/gnu/CORBA/CDR/Vio.java
+++ b/gnu/CORBA/CDR/Vio.java
@@ -1,4 +1,4 @@
-/* gnuValueBaseHelper.java --
+/* Vio.java -- Value type IO operations.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.CORBA.CDR;
+import gnu.CORBA.Minor;
import gnu.CORBA.ObjectCreator;
import org.omg.CORBA.CustomMarshal;
@@ -46,106 +47,144 @@ import org.omg.CORBA.DataOutputStream;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.StringSeqHelper;
+import org.omg.CORBA.StringValueHelper;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.WStringValueHelper;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
import org.omg.CORBA.portable.ValueFactory;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.StringTokenizer;
-import java.lang.reflect.Method;
+import javax.rmi.CORBA.Util;
+import javax.rmi.CORBA.ValueHandler;
/**
* A specialised class for reading and writing the value types.
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class Vio
{
/**
- * If true, wrap value type data into chunks. This decrease the
- * performance, but is required for the interoperability with
- * Sun's CORBA implementation. Chunking may increase the security,
- * as there is more control on the number of bytes being transferred.
- *
+ * If true, wrap value type data into chunks. This decrease the performance,
+ * and is not required for interoperability with jdk 1.5, but is left in the
+ * implementation as the optional mode for solving possible interoperability
+ * problems with non-Sun CORBA implementations.
+ *
* The current implementation would accept both single chunk or multiple
- * chunks, but will always send a single chunk.
+ * chunks, but will always send a single chunk (if true) or unchunked data (if
+ * false).
*/
- public static boolean USE_CHUNKING = true;
+ public static boolean USE_CHUNKING = false;
/**
- * The first field in the value record. The last octet may contain
- * additional flags (vf_CODEBASE, vf_ID and vf_MULTIPLE_IDS). The tag
- * value is different for the indirections (vt_INDIRECTION) and
- * nulls (vt_NULL).
+ * The first field in the value record. The last octet may contain additional
+ * flags (vf_CODEBASE, vf_ID and vf_MULTIPLE_IDS). The tag value is different
+ * for the indirections (vt_INDIRECTION) and nulls (vt_NULL).
*/
public static final int vt_VALUE_TAG = 0x7fffff00;
/**
- * The value tag flag, indicating that the codebase URL is present
- * in the value tag record.
+ * The value tag flag, indicating that the codebase URL is present in the
+ * value tag record.
*/
public static final int vf_CODEBASE = 0x1;
/**
- * The value tag flag, indicating that a single repository id is present
- * in the value tag record.
+ * The value tag flag, indicating that a single repository id is present in
+ * the value tag record.
*/
public static final int vf_ID = 0x2;
/**
- * The value tag flag, indicating, that there are multiple repository
- * ids present in the record. If this flag is set, the flag vf_ID must
- * also be set, resulting the value of the least significant byte 0x6.
+ * The value tag flag, indicating, that there are multiple repository ids
+ * present in the record. If this flag is set, the flag vf_ID must also be
+ * set, resulting the value of the least significant byte 0x6.
*/
public static final int vf_MULTIPLE_IDS = 0x4;
/**
* The value tag flag, indicating the presence of chunking. Each chunk is
- * preceeded by a positive int, indicating the number of bytes in the chunk.
- * A sequence of chunks is terminated by a non positive int.
+ * preceeded by a positive int, indicating the number of bytes in the chunk. A
+ * sequence of chunks is terminated by a non positive int.
*/
public static final int vf_CHUNKING = 0x8;
/**
* The indirection tag value. Such tag must be followed by the CORBA long,
* indicating the offset in the CORBA message, where the indirected
- * information is present. This offset is assumed zero at the position
- * where the mentioned CORBA long starts and can refer both forward
- * (positive values) and backward (negative values).
+ * information is present. This offset is assumed zero at the position where
+ * the mentioned CORBA long starts and can refer both forward (positive
+ * values) and backward (negative values).
*/
public static final int vt_INDIRECTION = 0xffffffff;
/**
- * This tag value means that the value object being transferred is equal
- * to null.
+ * This tag value means that the value object being transferred is equal to
+ * null.
*/
public static final int vt_NULL = 0x0;
/**
- * Read the value base from the given input stream. Determines the
- * required class from the repository id. This includes operations
- * that are not required when an unitialised instance or at least
- * class of the value type is known. Hence it may be faster to use
- * the alternative methods, read(InputStream, Class) or
- * read(InputStream, Serializable).
- *
+ * The size of CORBA long (java int).
+ */
+ static final int INT_SIZE = 4;
+
+ /**
+ * The String value helper (one instance is sufficient).
+ */
+ public static final WStringValueHelper m_StringValueHelper = new WStringValueHelper();
+
+ /**
+ * An instance of the value handler.
+ */
+ static ValueHandler handler = Util.createValueHandler();
+
+ /**
+ * Read the value base from the given input stream. Determines the required
+ * class from the repository id. This includes operations that are not
+ * required when an unitialised instance or at least class of the value type
+ * is known. Hence it may be faster to use the alternative methods,
+ * read(InputStream, Class) or read(InputStream, Serializable).
+ *
* @param input a stream to read from.
- *
+ * @param repository_id a repository id of the object being read, may be null.
+ *
* @return the loaded value.
- *
+ *
* @throws MARSHAL if the reading has failed due any reason.
*/
public static Serializable read(InputStream input)
{
- // Explicitly prevent the stream from closing as we may need
- // to read the subsequent bytes as well. Stream may be auto-closed
- // in its finalizer.
+ return read(input, (String) null);
+ }
+
+ /**
+ * Read the value base from the given input stream. Determines the required
+ * class from the repository id. This includes operations that are not
+ * required when an unitialised instance or at least class of the value type
+ * is known. Hence it may be faster to use the alternative methods,
+ * read(InputStream, Class) or read(InputStream, Serializable).
+ *
+ * @param an_input a stream to read from.
+ * @param repository_id a repository id of the object being read, may be null.
+ *
+ * @return the loaded value.
+ *
+ * @throws MARSHAL if the reading has failed due any reason.
+ */
+ public static Serializable read(InputStream input, String repository_id)
+ {
try
{
+ final int position = getCurrentPosition(input);
// We may need to jump back if the value is read via value factory.
input.mark(512);
@@ -154,18 +193,13 @@ public abstract class Vio
String codebase = null;
String[] ids = null;
- String id = null;
-
- // The existing implementing object.
- java.lang.Object ox = null;
+ String id = repository_id;
// Check for the agreed null value.
if (value_tag == vt_NULL)
return null;
else if (value_tag == vt_INDIRECTION)
-
- // TODO FIXME Implement support for indirections.
- throw new NO_IMPLEMENT("Indirections unsupported");
+ return readIndirection(input);
else
{
// Read the value.
@@ -174,152 +208,173 @@ public abstract class Vio
// The codebase is present. The codebase is a space
// separated list of URLs from where the implementing
// code can be downloaded.
- codebase = input.read_string();
+ codebase = read_string(input);
}
if ((value_tag & vf_MULTIPLE_IDS) != 0)
{
// Multiple supported repository ids are present.
- ids = StringSeqHelper.read(input);
- for (int i = 0; (i < ids.length) && (ox == null); i++)
- {
- ox = ObjectCreator.Idl2Object(ids [ i ]);
-
- if (ox == null)
- {
- // Try to find the value factory.
- ValueFactory f =
- ((org.omg.CORBA_2_3.ORB) input.orb()).lookup_value_factory(ids [ i ]);
-
- if (f != null)
- {
- // Reset, as the value factory reads from beginning.
- input.reset();
- return f.read_value((org.omg.CORBA_2_3.portable.InputStream) input);
- }
- }
- }
+ ids = read_string_array(input);
}
else if ((value_tag & vf_ID) != 0)
{
// Single supported repository id is present.
- id = input.read_string();
- ox = ObjectCreator.Idl2Object(id);
-
- if (ox == null)
- {
- // Try to find the value factory.
- ValueFactory f =
- ((org.omg.CORBA_2_3.ORB) input.orb()).lookup_value_factory(id);
-
- if (f != null)
- {
- input.reset();
- return f.read_value((org.omg.CORBA_2_3.portable.InputStream) input);
- }
- }
+ id = read_string(input);
}
}
- if (ox == null)
- throw new MARSHAL("Unable to instantiate the value type");
+ BoxedValueHelper helper = getHelper(null, id);
+ // The existing implementing object.
+ java.lang.Object ox = null;
+
+ if (helper != null)
+ ox = null; // Helper will care about the instantiating.
+ else if (id.equals(WStringValueHelper.id()))
+ helper = m_StringValueHelper;
else
- {
- read_instance(input, ox, value_tag, null);
- return (Serializable) ox;
- }
+ ox = createInstance(id, ids, codebase);
+ return (Serializable) read_instance(input, position, ox, value_tag,
+ helper, id, ids, codebase);
}
catch (Exception ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL();
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
}
}
/**
- * Read the value base from the given input stream when
- * the value base class is available. Hence there is no need
- * to guess it from the repository id.
- *
+ * Read the value base from the given input stream when the value base class
+ * is available. Hence there is no need to guess it from the repository id.
+ *
* @param input a stream to read from.
* @param value_class the class of the value being read.
- *
+ *
* @return the loaded value.
- *
+ *
* @throws MARSHAL if the reading has failed due any reason.
*/
public static Serializable read(InputStream input, Class value_class)
{
- // Explicitly prevent the stream from closing as we may need
- // to read the subsequent bytes as well. Stream may be auto-closed
- // in its finalizer.
+ final int position = getCurrentPosition(input);
+
+ String id = null;
+ String[] ids = null;
+ String codebase = null;
+
try
{
int value_tag = input.read_long();
checkTag(value_tag);
- // The existing implementing object.
- java.lang.Object ox = value_class.newInstance();
-
// Check for the agreed null value.
if (value_tag == vt_NULL)
return null;
else if (value_tag == vt_INDIRECTION)
-
- // TODO FIXME Implement support for indirections.
- throw new NO_IMPLEMENT("Indirections unsupported");
+ return readIndirection(input);
else
{
// Read the value.
if ((value_tag & vf_CODEBASE) != 0)
{
- // The codebase is present, but skip it.
- input.read_string();
+ // The codebase is present.
+ codebase = read_string(input);
}
if ((value_tag & vf_MULTIPLE_IDS) != 0)
{
- // Multiple supported repository ids are present, but skip them.
- StringSeqHelper.read(input);
+ // Multiple supported repository ids are present.
+ ids = read_string_array(input);
}
else if ((value_tag & vf_ID) != 0)
{
- // Single supported repository id is present, but skip it.
- input.read_string();
+ // Single supported repository id is present.
+ id = read_string(input);
}
}
- read_instance(input, ox, value_tag, null);
+ BoxedValueHelper vHelper = id != null ? getHelper(value_class, id)
+ : getHelper(value_class, ids);
+
+ java.lang.Object ox;
+
+ if (vHelper == null)
+ {
+ try
+ {
+ ox = createInstance(id, ids, codebase);
+ }
+ catch (Exception e)
+ {
+ ox = null;
+ }
+
+ if (ox != null)
+ {
+ if (value_class != null
+ && !value_class.isAssignableFrom(ox.getClass()))
+ {
+ MARSHAL m = new MARSHAL(ox.getClass() + " is not a "
+ + value_class.getName());
+ m.minor = Minor.ClassCast;
+ throw m;
+ }
+ }
+ }
+ else
+ ox = null;
+
+ ox = read_instance(input, position, ox, value_tag, vHelper, id, ids,
+ codebase);
return (Serializable) ox;
}
+ catch (MARSHAL m)
+ {
+ throw m;
+ }
+ catch (SystemException sysEx)
+ {
+ // OK.
+ throw sysEx;
+ }
catch (Exception ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL("Cant read " + value_class);
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
}
}
/**
- * Read the value base from the given input stream when
- * the unitialised instance is available. Hence there is no need
- * to guess the class from the repository id and then to instantiate
- * an instance.
- *
+ * Read the value base from the given input stream when the unitialised
+ * instance is available. Hence there is no need to guess the class from the
+ * repository id and then to instantiate an instance.
+ *
* @param input a stream to read from.
- *
- * @param value_instance an pre-created instance of the value. If the
- * helper is not null, this parameter is ignored an should be null.
- *
- * @param helper a helper to create an instance and read the object-
- * specific part of the record. If the value_instance is used instead,
- * this parameter should be null.
- *
+ *
+ * @param value_instance an pre-created instance of the value. If the helper
+ * is not null, this parameter is ignored an should be null.
+ *
+ * @param helper a helper to create an instance and read the object- specific
+ * part of the record. If the value_instance is used instead, this parameter
+ * should be null.
+ *
* @return the loaded value.
- *
+ *
* @throws MARSHAL if the reading has failed due any reason.
*/
public static Object read(InputStream input, Object value_instance,
- Object helper
- )
+ BoxedValueHelper helper)
{
+ final int position = getCurrentPosition(input);
+
+ String id = null;
+ String[] ids = null;
+ String codebase = null;
+
try
{
int value_tag = input.read_long();
@@ -329,207 +384,396 @@ public abstract class Vio
if (value_tag == vt_NULL)
return null;
else if (value_tag == vt_INDIRECTION)
-
- // TODO FIXME Implement support for indirections.
- throw new NO_IMPLEMENT("Indirections unsupported");
+ return readIndirection(input);
else
{
// Read the value.
if ((value_tag & vf_CODEBASE) != 0)
{
- // The codebase is present, but skip it.
- input.read_string();
+ // The codebase is present.
+ codebase = read_string(input);
}
if ((value_tag & vf_MULTIPLE_IDS) != 0)
{
- // Multiple supported repository ids are present, but skip them.
- StringSeqHelper.read(input);
+ // Multiple supported repository ids are present.
+ ids = read_string_array(input);
}
else if ((value_tag & vf_ID) != 0)
{
- // Single supported repository id is present, but skip it.
- input.read_string();
+ // Single supported repository id is present.
+ id = read_string(input);
}
}
- value_instance =
- read_instance(input, value_instance, value_tag, helper);
+ Class value_class = value_instance == null ? null
+ : value_instance.getClass();
+
+ if (helper == null)
+ helper = id != null ? getHelper(value_class, id) : getHelper(
+ value_class, ids);
+
+ value_instance = read_instance(input, position, value_instance,
+ value_tag, helper, id, ids, codebase);
return value_instance;
}
catch (Exception ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL();
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
}
}
/**
- * Read using provided boxed value helper. This method expects
- * the full value type header, followed by contents, that are
- * delegated to the provided helper. It handles null.
- *
+ * Read using provided boxed value helper. This method expects the full value
+ * type header, followed by contents, that are delegated to the provided
+ * helper. It handles null.
+ *
* @param input the stream to read from.
- * @param helper the helper that reads the type-specific part of
- * the content.
- *
- * @return the value, created by the helper, or null if the
- * header indicates that null was previously written.
+ * @param helper the helper that reads the type-specific part of the content.
+ *
+ * @return the value, created by the helper, or null if the header indicates
+ * that null was previously written.
*/
- public static Serializable read(InputStream input, Object helper)
+ public static Serializable read(InputStream input, BoxedValueHelper helper)
{
return (Serializable) read(input, null, helper);
}
/**
- * Fill in the instance fields by the data from the input stream.
- * The method assumes that the value header, if any, is already
- * behind. The information from the stream is stored into the
- * passed ox parameter.
- *
+ * Fill in the instance fields by the data from the input stream. The method
+ * assumes that the value header, if any, is already behind. The information
+ * from the stream is stored into the passed ox parameter.
+ *
* @param input an input stream to read from.
- *
+ *
* @param value a pre-instantiated value type object, must be either
- * Streamable or CustomMarshal. If the helper is used, this parameter
- * is ignored and should be null.
- *
+ * Streamable or CustomMarshal. If the helper is used, this parameter is
+ * ignored and should be null.
+ *
* @param value_tag the tag that must be read previously.
- * @param helper the helper for read object specific part; may be
- * null to read in using other methods.
- *
+ * @param helper the helper for read object specific part; may be null to read
+ * in using other methods.
+ *
* @return the value that was read.
*/
- private static Object read_instance(InputStream input, Object value,
- int value_tag, Object helper
- )
+ static Object read_instance(InputStream input, final int position,
+ Object value, int value_tag, BoxedValueHelper helper, String id,
+ String[] ids, String codebase)
{
+ if (helper != m_StringValueHelper && id != null)
+ if (id.equals(StringValueHelper.id()))
+ {
+ value = null;
+ helper = m_StringValueHelper;
+ }
+
try
{
if ((value_tag & vf_CHUNKING) != 0)
{
- ByteArrayOutputStream bout = null;
- int n = -1;
-
- // Read all chunks.
- int chunk_size = input.read_long();
- if (chunk_size < 0)
- throw new MARSHAL("Invalid first chunk size " + chunk_size);
-
- byte[] r = new byte[ chunk_size ];
-
- while (chunk_size > 0)
- {
- if (r.length < chunk_size)
- r = new byte[ chunk_size + 256 ];
-
- n = 0;
- reading:
- while (n < chunk_size)
- n += input.read(r, n, r.length - n);
-
- // Read the size of the next chunk.
- chunk_size = input.read_long();
-
- // If the value is non negative, there is more than one chunk.
- // Accumulate chunks in the buffer.
- // The last chunk (or the only chunk, if only one chunk is
- // present) is not written in the buffer. It is stored in the
- // array r, avoiding unnecessary buffer operations.
- if (chunk_size > 0)
- {
- bout = new ByteArrayOutputStream(2 * chunk_size);
- bout.write(r, 0, chunk_size);
- }
- }
+ BufferedCdrOutput output = createBuffer(input, 1024);
+ // Read the current (not a nested one) value in this spec case.
+ readNestedValue(value_tag, input, output, -1);
+ BufferredCdrInput ci = new BufferredCdrInput(output.buffer.getBuffer());
+ ci.setRunTime(output.getRunTime());
- if (bout != null)
- {
- // More than one chunk was present.
- // Add the last chunk.
- bout.write(r, 0, n);
- input = new noHeaderInput(bout.toByteArray());
- }
- else
- {
- // Only one chunk was present.
- input = new noHeaderInput(r);
- }
+ input = new HeadlessInput(ci, input);
}
else
{
- if (input instanceof cdrBufInput)
+ if (input instanceof BufferredCdrInput)
{
// Highly probable case.
- input =
- new noHeaderInput(((cdrBufInput) input).buffer.getBuffer());
+ input = new HeadlessInput((BufferredCdrInput) input, null);
+ }
+ else if (input instanceof HeadlessInput)
+ {
+ // There is no need to instantiate one more HeadlessInput
+ // as we can just reset.
+ ((HeadlessInput) input).subsequentCalls = false;
}
else
{
- cdrBufOutput bout = new cdrBufOutput();
+ BufferedCdrOutput bout = new BufferedCdrOutput();
int c;
while ((c = input.read()) >= 0)
bout.write((byte) c);
- input = new noHeaderInput(bout.buffer.toByteArray());
+ input = new HeadlessInput(
+ (BufferredCdrInput) bout.create_input_stream(), input);
}
}
}
catch (IOException ex)
{
MARSHAL m = new MARSHAL("Unable to read chunks");
+ m.minor = Minor.Value;
m.initCause(ex);
throw m;
}
- // The user-defines io operations are implemented.
- if (value instanceof CustomMarshal)
+ return readValue(input, position, value, helper, id, ids, codebase);
+ }
+
+ /**
+ * Create a buffer, inheriting critical settings from the passed input stream.
+ */
+ private static BufferedCdrOutput createBuffer(InputStream input, int proposed_size)
+ {
+ BufferedCdrOutput bout;
+ bout = new BufferedCdrOutput(2 * proposed_size + 256);
+
+ if (input instanceof BufferredCdrInput)
{
- CustomMarshal marsh = (CustomMarshal) value;
- try
+ BufferredCdrInput in = (BufferredCdrInput) input;
+ bout.setBigEndian(in.isBigEndian());
+ }
+
+ if (input instanceof gnuValueStream)
+ bout.setRunTime(((gnuValueStream) input).getRunTime());
+ else
+ bout.setRunTime(new gnuRuntime(null, null));
+ return bout;
+ }
+
+ /**
+ * Read the chunked nested value from the given input stream, transferring the
+ * contents to the given output stream.
+ *
+ * @param value_tag the value tag of the value being read.
+ * @param input the input stream from where the remainder of the nested value
+ * must be read.
+ * @param output the output stream where the unchunked nested value must be
+ * copied.
+ *
+ * @return the tag that ended the nested value.
+ */
+ public static int readNestedValue(int value_tag, InputStream input,
+ BufferedCdrOutput output, int level)
+ throws IOException
+ {
+ String id = null;
+ if (level < -1)
+ {
+ // For the first level, this information is already behind.
+ output.write_long(value_tag - vf_CHUNKING);
+
+ // The nested value should be aways chunked.
+ if ((value_tag & vf_CHUNKING) == 0)
+ {
+ MARSHAL m = new MARSHAL("readNestedValue: must be chunked");
+ m.minor = Minor.Chunks;
+ throw m;
+ }
+ else if (value_tag == vt_NULL)
+ {
+ MARSHAL m = new MARSHAL("readNestedValue: nul");
+ m.minor = Minor.Chunks;
+ throw m;
+ }
+ else if (value_tag == vt_INDIRECTION)
{
- marsh.unmarshal((DataInputStream) input);
+ MARSHAL m = new MARSHAL("readNestedValue: indirection");
+ m.minor = Minor.Chunks;
+ throw m;
}
- catch (ClassCastException ex)
+ else
{
- incorrect_plug_in(ex);
+ // Read the value.
+ if ((value_tag & vf_CODEBASE) != 0)
+ {
+ String codebase = read_string(input);
+ write_string(output, codebase);
+ }
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0)
+ {
+ // Multiple supported repository ids are present.
+ String[] ids = read_string_array(input);
+ id = ids[0];
+ write_string_array(output, ids);
+ }
+ else if ((value_tag & vf_ID) != 0)
+ {
+ id = read_string(input);
+ write_string(output, id);
+ }
}
}
+
+ int n = -1;
+
+ // Read all chunks.
+ int chunk_size;
+
+ byte[] r = null;
+
+ while (true)
+ {
+ // Read the size of the next chunk or it may also be the
+ // header of the nested value.
+ chunk_size = input.read_long();
+
+ // End of chunk terminator.
+ if (chunk_size < 0 && chunk_size >= level)
+ return chunk_size;
+ else if (chunk_size >= 0x7FFFFF00)
+ {
+ int onInput = getCurrentPosition(input) - 4;
+ int onOutput = output.getPosition();
+ output.getRunTime().redirect(onInput, onOutput);
+ // Value over 0x7FFFFF00 indicates that the nested value
+ // starts here. Read the nested value, storing it into the output.
+ // First parameter is actually the value tag.
+ chunk_size = readNestedValue(chunk_size, input, output, level - 1);
+ if (chunk_size < 0 && chunk_size >= level)
+ return chunk_size;
+ }
+ else
+ {
+ // The chunk follows.
+ if (r == null || r.length < chunk_size)
+ r = new byte[chunk_size + 256];
+
+ n = 0;
+ reading: while (n < chunk_size)
+ n += input.read(r, n, chunk_size - n);
+ output.write(r, 0, n);
+ }
+ }
+ }
+
+ /**
+ * Read the value (the header must be behind).
+ */
+ public static Serializable readValue(InputStream input, final int position,
+ Object value, BoxedValueHelper helper, String id, String[] ids,
+ String codebase)
+ {
+ gnuRuntime g;
+ gnuValueStream c = ((gnuValueStream) input);
+ if (c.getRunTime() == null)
+ {
+ g = new gnuRuntime(codebase, value);
+ c.setRunTime(g);
+ }
+ else
+ {
+ g = c.getRunTime();
+ g.addCodeBase(codebase);
+ g.target = (Serializable) value;
+ }
+ if (value != null)
+ g.objectWritten(value, position);
+
+ if (input instanceof HeadlessInput)
+ ((HeadlessInput) input).subsequentCalls = false;
+
+ boolean ok = true;
+
+ // The user-defined io operations are implemented.
+ if (value instanceof CustomMarshal)
+ {
+ CustomMarshal marsh = (CustomMarshal) value;
+ marsh.unmarshal((DataInputStream) input);
+ }
else
// The IDL-generated io operations are implemented.
if (value instanceof Streamable)
{
((Streamable) value)._read(input);
}
- else if (helper instanceof BoxedValueHelper)
- value = ((BoxedValueHelper) helper).read_value(input);
- else if (helper instanceof ValueFactory)
- value =
- ((ValueFactory) helper).read_value((org.omg.CORBA_2_3.portable.InputStream) input);
+ else if (helper != null)
+ {
+ // If helper is non-null the value should normally be null.
+ value = helper.read_value(input);
+ g.objectWritten(value, position);
+ }
else
+ {
+ ok = false;
+ ValueFactory factory = null;
+ org.omg.CORBA_2_3.ORB orb = (org.omg.CORBA_2_3.ORB) input.orb();
- // Stating the interfaces that the USER should use.
- throw new MARSHAL("The " + value.getClass().getName() +
- " must implement either StreamableValue or CustomValue."
- );
+ if (id != null)
+ factory = orb.lookup_value_factory(id);
- // The negative end of state marker is expected from OMG standard.
- // If the chunking is used, this marker is already extracted.
- if ((value_tag & vf_CHUNKING) == 0)
+ if (factory == null && ids != null)
+ {
+ for (int i = 0; i < ids.length && factory == null; i++)
+ {
+ factory = orb.lookup_value_factory(ids[i]);
+ }
+ }
+
+ if (factory != null)
+ {
+ value = factory.read_value((org.omg.CORBA_2_3.portable.InputStream) input);
+ ok = true;
+ }
+ }
+
+ if (!ok && value instanceof Serializable)
+ // Delegate to ValueHandler
{
- int eor = input.read_long();
- if (eor >= 0)
- throw new MARSHAL("End of state marker has an invalid value " + eor);
+ if (ids != null && ids.length > 0)
+ id = ids[0];
+
+ value = handler.readValue(input, position, value.getClass(), id, g);
+ ok = true;
}
- return value;
+ if (!ok)
+ {
+ if (value != null)
+ {
+ MARSHAL m = new MARSHAL(value.getClass().getName()
+ + " must be Streamable, CustomMarshal or Serializable");
+ m.minor = Minor.UnsupportedValue;
+ throw m;
+ }
+ else
+ {
+ MARSHAL m = new MARSHAL("Unable to instantiate " + id + ":" + list(ids)
+ + " helper " + helper);
+ m.minor = Minor.UnsupportedValue;
+ throw m;
+ }
+ }
+ else
+ return (Serializable) value;
+ }
+
+ /**
+ * Conveniency method to list ids in exception reports.
+ */
+ static String list(String[] s)
+ {
+ if (s == null)
+ return "null";
+ else
+ {
+ StringBuffer b = new StringBuffer("{");
+ for (int i = 0; i < s.length; i++)
+ {
+ b.append(s[i]);
+ b.append(" ");
+ }
+ b.append("}");
+ return b.toString();
+ }
}
/**
* Write the value base into the given stream.
- *
+ *
* @param output a stream to write to.
- *
+ *
* @param value a value type object, must be either Streamable or
* CustomMarshal.
- *
+ *
* @throws MARSHAL if the writing failed due any reason.
*/
public static void write(OutputStream output, Serializable value)
@@ -537,45 +781,82 @@ public abstract class Vio
// Write null if this is a null value.
if (value == null)
output.write_long(vt_NULL);
+ else if (value instanceof String)
+ write(output, value, m_StringValueHelper);
else
- write(output, value, ObjectCreator.toIDL(value.getClass().getName()));
- }
-
- /**
- * Write the value base into the given stream, stating that it is an
- * instance of the given class. The written record has no repository
- * id and requires to supply a class or initialised instance for reading
- * rather than an actual class it is.
- *
- * This results writing a different repository id.
- *
- * If the passed value implements the {@link CustomMarshal},
- * the helper uses {@link CustomMarshal#marshal}
- * to write the content in a user defined way. Otherwise,
- * this implementation initialises the {@link ObjectOutputStream}
- * and writes through it.
- *
+ write(output, value, value.getClass());
+ }
+
+ /**
+ * Write the value base into the given stream, stating that it is an instance
+ * of the given class.
+ *
* @param output a stream to write to.
- *
+ *
* @param value a value to write.
- *
+ *
* @throws MARSHAL if the writing failed due any reason.
*/
public static void write(OutputStream output, Serializable value,
- Class substitute
- )
+ Class substitute)
{
// Write null if this is a null value.
if (value == null)
output.write_long(vt_NULL);
+ else if (value instanceof String || substitute == String.class)
+ writeString(output, value);
+ else
+ {
+ String vId = ObjectCreator.getRepositoryId(value.getClass());
+ if (substitute == null || value.getClass().equals(substitute))
+ write_instance(output, value, vId, getHelper(value.getClass(), vId));
+ else
+ {
+ String vC = ObjectCreator.getRepositoryId(substitute);
+ String[] ids = new String[] { vId, vC };
+ BoxedValueHelper h = getHelper(substitute.getClass(), ids);
+ // If the helper is available, it is also responsible for
+ // providing the repository Id. Otherwise, write both
+ // ids.
+ if (h == null)
+ write_instance(output, value, ids, null);
+ else
+ write_instance(output, value, h.get_id(), null);
+ }
+ }
+ }
+ /**
+ * Write the value base into the given stream, supplementing it with an array
+ * of the provided repository ids plus the repository id, derived from the
+ * passed value.
+ *
+ * @param output a stream to write to.
+ *
+ * @param value a value to write.
+ *
+ * @throws MARSHAL if the writing failed due any reason.
+ */
+ public static void write(OutputStream output, Serializable value,
+ String[] multiple_ids)
+ {
+ // Write null if this is a null value.
+ if (value == null)
+ output.write_long(vt_NULL);
else
- write(output, value, ObjectCreator.toIDL(substitute.getName()));
+ {
+ String[] ids = new String[multiple_ids.length + 1];
+ ids[0] = ObjectCreator.getRepositoryId(value.getClass());
+ System.arraycopy(multiple_ids, 0, ids, 1, multiple_ids.length);
+ BoxedValueHelper h = getHelper(value.getClass(), ids);
+ write_instance(output, value, ids, h);
+ }
}
/**
- * Write value when its repository Id is explicitly given.
- *
+ * Write value when its repository Id is explicitly given. Only this Id is
+ * written, the type of value is not taken into consideration.
+ *
* @param output an output stream to write into.
* @param value a value to write.
* @param id a value repository id.
@@ -585,172 +866,608 @@ public abstract class Vio
if (value == null)
output.write_long(vt_NULL);
else
- write_instance(output, value, id, null);
+ write_instance(output, value, id, getHelper(value.getClass(), id));
}
/**
- * Write standard value type header, followed by contents, produced
- * by the boxed value helper.
- *
+ * Write standard value type header, followed by contents, produced by the
+ * boxed value helper.
+ *
* @param output the stream to write to.
* @param value the value to write, can be null.
- * @param helper the helper that writes the value content if it is
- * not null.
+ * @param helper the helper that writes the value content if it is not null
+ * (must be provided for this method).
*/
public static void write(OutputStream output, Serializable value,
- Object helper
- )
+ BoxedValueHelper helper)
{
+ if (helper == null)
+ throw new AssertionError("Helper must be provided");
if (value == null)
output.write_long(vt_NULL);
else
+ write_instance(output, value, helper.get_id(), helper);
+ }
+
+ /**
+ * Write the parameter that is surely a string and not null.
+ */
+ private static void writeString(OutputStream output, Serializable string)
+ {
+ write_instance(output, string, m_StringValueHelper.get_id(),
+ m_StringValueHelper);
+ }
+
+ /**
+ * Write value when its repository Id is explicitly given. Does not handle
+ * null.
+ *
+ * @param output an output stream to write into.
+ * @param value a value to write.
+ * @param id a value repository id (can be either single string or string
+ * array).
+ * @param helper a helper, writing object - specifical part. Can be null if
+ * the value should be written using other methods.
+ */
+ static void write_instance(OutputStream output, Serializable value,
+ Object ids, BoxedValueHelper helper)
+ {
+ gnuValueStream rout = null;
+ gnuRuntime runtime = null;
+
+ try
{
- String id;
+ if (output instanceof gnuValueStream)
+ {
+ int position;
+ rout = (gnuValueStream) output;
+ runtime = rout.getRunTime();
+
+ if (runtime == null)
+ {
+ runtime = new gnuRuntime(null, value);
+ rout.setRunTime(runtime);
+ rout.getRunTime().objectWritten(value,
+ position = rout.getPosition());
+ }
+ else if (runtime.target == value)
+ {
+ if (!writeSelf(output, value))
+ throw new InternalError("Recursive helper call for "
+ + value.getClass().getName());
+ return;
+ }
+ else
+ {
+ position = runtime.isWrittenAt(value);
+ if (position >= 0)
+ {
+ // The object was already written.
+ output.write_long(vt_INDIRECTION);
+ output.write_long(position - rout.getPosition());
+ // Replacing object write data by indirection reference.
+ return;
+ }
+ else
+ {
+ runtime.objectWritten(value, position = rout.getPosition());
+ }
+ }
+ }
+
+ int value_tag = vt_VALUE_TAG;
+
+ if (ids instanceof String)
+ value_tag |= vf_ID;
+ else if (ids instanceof String[])
+ // OMG standard requires to set both flags.
+ value_tag |= vf_MULTIPLE_IDS | vf_ID;
- if (helper instanceof BoxedValueHelper)
- id = ((BoxedValueHelper) helper).get_id();
+ int chunkSizeLocation;
+
+ OutputStream outObj;
+
+ if (USE_CHUNKING)
+ {
+ // Wrap the value being written into one chunk (makes sense only for
+ // compatibility reasons).
+ outObj = output;
+ value_tag |= vf_CHUNKING;
+ }
+ else
+ outObj = output;
+
+ output.write_long(value_tag);
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0)
+ write_string_array(output, (String[]) ids);
+ else if ((value_tag & vf_ID) != 0)
+ write_string(output, (String) ids);
+
+ if (USE_CHUNKING)
+ {
+ // So far, write 0x55555555 instead of the chunk size (alignment may
+ // take place).
+ output.write_long(0x55555555);
+ // If the chunking is involved, the chunk size must be written here.
+ chunkSizeLocation = rout.getPosition() - INT_SIZE;
+ }
else
- id = "";
+ // Not in use for this case.
+ chunkSizeLocation = -1;
+
+ writeValue(outObj, value, helper);
- write_instance(output, value, id, helper);
+ if (USE_CHUNKING)
+ {
+ // Write the chunk size where the place for it was reserved.
+ int chunkSize = rout.getPosition() - chunkSizeLocation - INT_SIZE;
+ int current = rout.getPosition();
+ rout.seek(chunkSizeLocation);
+ output.write_long(chunkSize);
+ rout.seek(current);
+
+ // The end of record marker.
+ output.write_long(-1);
+ }
+ }
+ finally
+ {
+ if (runtime != null)
+ runtime.target = null;
}
}
/**
- * Write value when its repository Id is explicitly given.
- * Does not handle null.
- *
- * @param output an output stream to write into.
- * @param value a value to write.
- * @param id a value repository id.
- * @param helper a helper, writing object - specifica part. Can be null
- * if the value should be written unsing other methods.
+ * Write value (after header).
*/
- private static void write_instance(OutputStream output, Serializable value,
- String id, Object helper
- )
+ static void writeValue(OutputStream output, Serializable value,
+ BoxedValueHelper helper)
{
- // This implementation always writes a single repository id.
- // It never writes multiple repository ids and currently does not use
- // a codebase.
- int value_tag = vt_VALUE_TAG | vf_ID;
+ ((gnuValueStream) output).getRunTime().target = value;
+ if (helper != null)
+ helper.write_value(output, value);
+ else if (!writeSelf(output, value))
+ {
+ // Try to find helper via class loader.
+ boolean ok = false;
- OutputStream outObj;
- cdrBufOutput out = null;
+ if (!ok)
+ {
+ if (output instanceof BufferedCdrOutput)
+ {
+ BufferedCdrOutput b = (BufferedCdrOutput) output;
+ if (b.runtime == null)
+ b.runtime = new gnuRuntime(null, value);
+ }
- if (USE_CHUNKING)
+ handler.writeValue(output, value);
+ }
+ }
+ }
+
+ /**
+ * Try to write value supposing that it implements self-streamable interfaces.
+ * Return false if it does not or true on success.
+ */
+ static boolean writeSelf(OutputStream output, Serializable value)
+ {
+ // User defined write method is present.
+ if (value instanceof CustomMarshal)
{
- out = new cdrBufOutput();
- out.setOrb(output.orb());
- outObj = out;
- value_tag |= vf_CHUNKING;
+ ((CustomMarshal) value).marshal((DataOutputStream) output);
+ return true;
}
- else
- outObj = output;
+ else if (value instanceof Streamable)
+ {
+ ((Streamable) value)._write(output);
+ return true;
+ }
+ return false;
+ }
- output.write_long(value_tag);
- output.write_string(id);
+ /**
+ * Read the indirection data and return the object that was already written to
+ * this stream.
+ *
+ * @param an_input the input stream, must be BufferredCdrInput.
+ */
+ static Serializable readIndirection(InputStream an_input)
+ {
+ if (!(an_input instanceof gnuValueStream))
+ throw new NO_IMPLEMENT(gnuValueStream.class.getName()
+ + " expected as parameter");
- if (helper instanceof BoxedValueHelper)
+ gnuValueStream in = (gnuValueStream) an_input;
+
+ int current_pos = in.getPosition();
+
+ int offset = an_input.read_long();
+ if (offset > -INT_SIZE)
{
- ((BoxedValueHelper) helper).write_value(outObj, value);
+ MARSHAL m = new MARSHAL("Indirection tag refers to " + offset
+ + " (must be less than -" + INT_SIZE + ")");
+ m.minor = Minor.Offset;
+ throw m;
}
- else
- // User defince write method is present.
- if (value instanceof CustomMarshal)
+
+ int stored_at = current_pos + offset;
+
+ if (in.getRunTime() == null)
+ {
+ MARSHAL m = new MARSHAL(stored_at + " offset " + offset + ": not written");
+ m.minor = Minor.Value;
+ throw m;
+ }
+
+ return (Serializable) in.getRunTime().isObjectWrittenAt(stored_at, offset);
+ }
+
+ /**
+ * Check the passed value tag for correctness.
+ *
+ * @param value_tag a tag to check, must be between 0x7fffff00 and 0x7fffffff
+ *
+ * @throws MARSHAL if the tag is outside this interval.
+ */
+ static void checkTag(int value_tag)
+ {
+ if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff)
+ && value_tag != vt_NULL && value_tag != vt_INDIRECTION)
+ {
+ MARSHAL m = new MARSHAL("Invalid value record, unsupported header tag: "
+ + value_tag + " (0x" + Integer.toHexString(value_tag) + ")");
+ m.minor = Minor.ValueHeaderTag;
+ throw m;
+ }
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0 && (value_tag & vf_ID) == 0)
{
+ MARSHAL m = new MARSHAL("Invalid value record header flag combination (0x"
+ + Integer.toHexString(value_tag) + ")");
+ m.minor = Minor.ValueHeaderFlags;
+ throw m;
+ }
+ }
+
+ /**
+ * Throw MARSHAL.
+ */
+ static void throwIt(String msg, String id1, String id2, Throwable e)
+ throws MARSHAL
+ {
+ MARSHAL m = new MARSHAL(msg + ":'" + id1 + "' versus '" + id2 + "'");
+ if (e != null)
+ m.initCause(e);
+ m.minor = Minor.Value;
+ throw m;
+ }
+
+ /**
+ * Load class by name and create the instance.
+ */
+ static Object createInstance(String id, String[] ids, String codebase)
+ {
+ Object o = null;
+
+ if (id != null)
+ o = _createInstance(id, codebase);
+
+ if (ids != null)
+ for (int i = 0; i < ids.length && o == null; i++)
+ o = _createInstance(ids[i], codebase);
+ return o;
+ }
+
+ static Object _createInstance(String id, String codebase)
+ {
+ if (id == null)
+ return null;
+ if (id.equals(StringValueHelper.id()))
+ return "";
+ StringTokenizer st = new StringTokenizer(id, ":");
+
+ String prefix = st.nextToken();
+ if (prefix.equalsIgnoreCase("IDL"))
+ return ObjectCreator.Idl2Object(id);
+ else if (prefix.equalsIgnoreCase("RMI"))
+ {
+ String className = st.nextToken();
+ String hashCode = st.nextToken();
+ String sid = null;
+ if (st.hasMoreElements())
+ sid = st.nextToken();
+
try
{
- ((CustomMarshal) value).marshal((DataOutputStream) outObj);
+ Class objectClass = Util.loadClass(className, codebase,
+ Vio.class.getClassLoader());
+
+ String rid = ObjectCreator.getRepositoryId(objectClass);
+
+ if (!rid.equals(id))
+ {
+ // If direct string comparison fails, compare by meaning.
+ StringTokenizer st2 = new StringTokenizer(rid, ":");
+ if (!st2.nextToken().equals("RMI"))
+ throw new InternalError("RMI format expected: '" + rid + "'");
+ if (!st2.nextToken().equals(className))
+ throwIt("Class name mismatch", id, rid, null);
+
+ try
+ {
+ long h1 = Long.parseLong(hashCode, 16);
+ long h2 = Long.parseLong(st2.nextToken(), 16);
+ if (h1 != h2)
+ throwIt("Hashcode mismatch", id, rid, null);
+
+ if (sid != null && st2.hasMoreTokens())
+ {
+ long s1 = Long.parseLong(hashCode, 16);
+ long s2 = Long.parseLong(st2.nextToken(), 16);
+ if (s1 != s2)
+ throwIt("serialVersionUID mismatch", id, rid, null);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throwIt("Invalid hashcode or svuid format: ", id, rid, e);
+ }
+ }
+
+ // Low - level instantiation required here.
+ return instantiateAnyWay(objectClass);
}
- catch (ClassCastException ex)
+ catch (Exception ex)
{
- incorrect_plug_in(ex);
+ MARSHAL m = new MARSHAL("Unable to instantiate " + id);
+ m.minor = Minor.Instantiation;
+ m.initCause(ex);
+ throw m;
}
}
- else if (value instanceof Streamable)
+ else
+ throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
+ }
+
+ /**
+ * Read string, expecting the probable indirection.
+ */
+ static String read_string(InputStream input)
+ {
+ gnuValueStream g = (gnuValueStream) input;
+ int previous = g.getPosition();
+ int l = input.read_long();
+ if (l != vt_INDIRECTION)
{
- ((Streamable) value)._write(outObj);
+ g.seek(previous);
+ String s = input.read_string();
+ if (g.getRunTime() == null)
+ g.setRunTime(new gnuRuntime(null, null));
+ g.getRunTime().singleIdWritten(s, previous);
+ return s;
}
else
{
- // Try to find helper via class loader.
- boolean ok = false;
- try
+ gnuRuntime r = g.getRunTime();
+ int base = g.getPosition();
+ int delta = input.read_long();
+ if (r == null)
{
- Class helperClass = Class.forName(ObjectCreator.toHelperName(id));
-
- // It will be the helper for the encapsulated boxed value, not the
- // for the global boxed value type itself.
- Method write =
- helperClass.getMethod("write",
- new Class[]
- {
- org.omg.CORBA.portable.OutputStream.class, value.getClass()
- }
- );
- write.invoke(null, new Object[] { outObj, value });
- ok = true;
+ previous = g.getPosition();
+ g.seek(base + delta);
+ String indir = input.read_string();
+ g.seek(previous);
+ return indir;
}
- catch (Exception ex)
+ else
{
- ok = false;
+ return (String) r.isObjectWrittenAt(base + delta, delta);
}
+ }
+ }
- // Stating the interfaces that the USER should use.
- if (!ok)
- throw new MARSHAL("The " + value.getClass().getName() +
- " must implement either StreamableValue" + " or CustomValue."
- );
+ /**
+ * Read string array, expecting the probable indirection.
+ */
+ static String[] read_string_array(InputStream input)
+ {
+ gnuValueStream g = (gnuValueStream) input;
+ int previous = g.getPosition();
+ int l = input.read_long();
+ if (l != vt_INDIRECTION)
+ {
+ g.seek(previous);
+ String[] s = StringSeqHelper.read(input);
+ if (g.getRunTime() == null)
+ g.setRunTime(new gnuRuntime(null, null));
+ g.getRunTime().objectWritten(s, previous);
+ return s;
}
+ else
+ {
+ gnuRuntime r = g.getRunTime();
+ int base = g.getPosition();
+ int delta = input.read_long();
+ if (r == null)
+ {
+ previous = g.getPosition();
+ g.seek(base + delta);
+ String[] indir = StringSeqHelper.read(input);
+ g.seek(previous);
+ return indir;
+ }
+ else
+ {
+ return (String[]) r.isObjectWrittenAt(base + delta, delta);
+ }
+ }
+ }
- if (USE_CHUNKING)
+ /**
+ * Write repository Id, probably shared.
+ */
+ static void write_string(OutputStream output, String id)
+ {
+ if (output instanceof gnuValueStream)
{
- output.write_long(out.buffer.size());
- try
+ gnuValueStream b = (gnuValueStream) output;
+ if (b != null)
+ {
+ int written = b.getRunTime().idWrittenAt(id);
+ if (written >= 0)
+ {
+ // Reuse existing id record.
+ output.write_long(vt_INDIRECTION);
+ int p = b.getPosition();
+ output.write_long(written - p);
+ }
+ else
+ {
+ b.getRunTime().singleIdWritten(id, b.getPosition());
+ output.write_string(id);
+ }
+ }
+ }
+ else
+ output.write_string(id);
+ }
+
+ /**
+ * Write repository Id, probably shared.
+ */
+ static void write_string_array(OutputStream output, String[] ids)
+ {
+ if (output instanceof gnuValueStream)
+ {
+ gnuValueStream b = (gnuValueStream) output;
+ if (b != null)
{
- out.buffer.writeTo(output);
+ int written = b.getRunTime().idWrittenAt(ids);
+ if (written >= 0)
+ {
+ // Reuse existing id record.
+ output.write_long(vt_INDIRECTION);
+ int p = b.getPosition();
+ output.write_long(written - p);
+ }
+ else
+ {
+ b.getRunTime().multipleIdsWritten(ids, b.getPosition());
+ StringSeqHelper.write(output, ids);
+ }
}
- catch (IOException ex)
+ }
+ else
+ StringSeqHelper.write(output, ids);
+ }
+
+ /**
+ * Get the helper that could write the given object, or null if no pre-defined
+ * helper available for this object.
+ */
+ public static BoxedValueHelper getHelper(Class x, Object ids)
+ {
+ if (x != null && x.equals(String.class))
+ return m_StringValueHelper;
+ else if (x != null && x.isArray())
+ return new ArrayValueHelper(x);
+ else if (ids instanceof String)
+ return locateHelper((String) ids);
+ else if (ids instanceof String[])
+ {
+ String[] ia = (String[]) ids;
+ BoxedValueHelper h;
+ for (int i = 0; i < ia.length; i++)
{
- MARSHAL m = new MARSHAL();
- m.initCause(ex);
- throw m;
+ h = locateHelper(ia[i]);
+ if (h != null)
+ return h;
}
+ return null;
}
+ else
+ return null;
+ }
- // The end of record marker, required by OMG standard.
- output.write_long(-1);
+ /**
+ * Get the helper that could write the given object, or null if no pre-defined
+ * helper available for this object.
+ */
+ public static BoxedValueHelper getHelper(Class x, String id)
+ {
+ if (x != null && x.equals(String.class))
+ return m_StringValueHelper;
+ else if (x != null && x.isArray())
+ return new ArrayValueHelper(x);
+ else
+ return locateHelper(id);
}
/**
- * This can be called if the alternative CORBA implementation
- * is incorrectly plugged in.
- *
- * @throws NO_IMPLEMENT, always.
+ * Try to locate helper from the repository id.
*/
- static void incorrect_plug_in(Throwable ex) throws NO_IMPLEMENT
+ static BoxedValueHelper locateHelper(String id)
{
- NO_IMPLEMENT no = new NO_IMPLEMENT("Incorrect CORBA plug-in");
- no.initCause(ex);
- throw no;
+ if (id != null)
+ {
+ if (id.equals(m_StringValueHelper.get_id()))
+ return m_StringValueHelper;
+ else
+ // Try to locate helper for IDL type.
+ if (id.startsWith("IDL:"))
+ {
+ try
+ {
+ Class helperClass = ObjectCreator.findHelper(id);
+ if (BoxedValueHelper.class.isAssignableFrom(helperClass))
+ return (BoxedValueHelper) helperClass.newInstance();
+ else if (helperClass != null)
+ return new IDLTypeHelper(helperClass);
+ else
+ return null;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
}
/**
- * Check the passed value tag for correctness.
- *
- * @param value_tag a tag to check, must be between 0x7fffff00 and 0x7fffffff
- *
- * @throws MARSHAL if the tag is outside this interval.
+ * Get the current position.
*/
- private static final void checkTag(int value_tag)
+ static int getCurrentPosition(InputStream x)
{
- if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff) &&
- value_tag != vt_NULL &&
- value_tag != vt_INDIRECTION
- )
- throw new MARSHAL("Invalid value record, unsupported header tag: " +
- value_tag
- );
+ if (x instanceof gnuValueStream)
+ return ((gnuValueStream) x).getPosition();
+ else
+ return 0;
+ }
+
+ /**
+ * Instantiate an instance of this class anyway; also in the case when it has
+ * no parameterless or any other constructor. The fields will be assigned
+ * while reading the class from the stream.
+ *
+ * @param clazz a class for that the instance should be instantiated.
+ */
+ public static Object instantiateAnyWay(Class clazz)
+ throws Exception
+ {
+ Class first_nonserial = clazz;
+
+ while (Serializable.class.isAssignableFrom(first_nonserial)
+ || Modifier.isAbstract(first_nonserial.getModifiers()))
+ first_nonserial = first_nonserial.getSuperclass();
+
+ final Class local_constructor_class = first_nonserial;
+
+ Constructor constructor = local_constructor_class.getDeclaredConstructor(new Class[0]);
+
+ return VMVio.allocateObject(clazz, constructor.getDeclaringClass(),
+ constructor);
}
} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/gnuRuntime.java b/gnu/CORBA/CDR/gnuRuntime.java
new file mode 100644
index 000000000..774c92816
--- /dev/null
+++ b/gnu/CORBA/CDR/gnuRuntime.java
@@ -0,0 +1,336 @@
+/* gnuRuntime.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.MARSHAL;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * Our implementation of the sending context runtime.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuRuntime
+ extends LocalObject
+ implements org.omg.SendingContext.RunTime
+{
+ /**
+ * The data entry about the object that was written.
+ */
+ static class Entry
+ {
+ /**
+ * The stream position, where the object was written.
+ */
+ int at;
+
+ /**
+ * The object that was written.
+ */
+ Object object;
+
+ public String toString()
+ {
+ return object + "[" + at + "] "+object.getClass().getName();
+ }
+ }
+
+ /**
+ * The instruction that the actual object is stored at different location.
+ * Used when processing chunked data where positions shifts due removing the
+ * chunking tags.
+ */
+ static class Redirection
+ extends Entry
+ {
+ public String toString()
+ {
+ return "->" + at;
+ }
+ }
+
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The history of the written objects, maps object to records. The different
+ * objects must be treated as different regardless that .equals returns.
+ */
+ private Map sh_objects = new IdentityHashMap();
+
+ /**
+ * The written repository Ids that can be shared.
+ */
+ private Map sh_ids = new TreeMap(new Comparator()
+ {
+ public int compare(Object a, Object b)
+ {
+ if (a instanceof String && b instanceof String)
+ // Comparing string with string.
+ return ((String) a).compareTo((String) b);
+ else if (a instanceof String[] && b instanceof String[])
+ {
+ // Comparing array with array.
+ String[] sa = (String[]) a;
+ String[] sb = (String[]) b;
+
+ if (sa.length != sb.length)
+ return sa.length - sb.length;
+ else
+ {
+ int c;
+ for (int i = 0; i < sa.length; i++)
+ {
+ c = sa[i].compareTo(sb[i]);
+ if (c != 0)
+ return c;
+ }
+ return 0;
+ }
+ }
+ else
+ // Comparing string with array.
+ return a instanceof String ? 1 : -1;
+ }
+ });
+
+ /**
+ * The history of the written objects, maps positions to records. The
+ * different objects must be treated as different regardless that .equals
+ * returns.
+ */
+ private Map positions = new HashMap();
+
+ /**
+ * The Codebase.
+ */
+ private String codebase;
+
+ /**
+ * The pre-created instance of the object being written (avoid
+ * re-instantiation).
+ */
+ public Serializable target;
+
+ /**
+ * Create Runtime.
+ *
+ * @param a_id a repository Id, if only one Id was specified in the stream.
+ * @param a_ids a repository Ids, if the multiple Ids were specified in te
+ * stream.
+ * @param a_codabase a codebase, if it was specified in the stream.
+ */
+ public gnuRuntime(String a_codebase, Object a_target)
+ {
+ if (a_target instanceof Serializable)
+ target = (Serializable) a_target;
+
+ codebase = a_codebase;
+ }
+
+ /**
+ * Mark the given object as written at the given position.
+ */
+ public void objectWritten(Object object, int at)
+ {
+ if (object == null || at < 0)
+ return; // No positional information provided.
+ if (sh_objects.containsKey(object))
+ throw new AssertionError("Repetetive writing of the same object "
+ + object + " at " + at + dump());
+
+ Entry e = new Entry();
+ e.at = at;
+ e.object = object;
+
+ sh_objects.put(object, e);
+ positions.put(new Integer(at), e);
+ }
+
+ /**
+ * Check if the object is already written.
+ *
+ * @return the position, at that the object is allready written or -1 if it is
+ * not yet written.
+ */
+ public int isWrittenAt(Object x)
+ {
+ Entry e = (Entry) sh_objects.get(x);
+ return e == null ? -1 : e.at;
+ }
+
+ /**
+ * Set redirection, indicating that the object, searched at the p_searched
+ * position can be actually found at the p_present position.
+ */
+ public void redirect(int p_searched, int p_present)
+ {
+ Redirection redirection = new Redirection();
+ redirection.at = p_present;
+ positions.put(new Integer(p_searched), redirection);
+ }
+
+ /**
+ * Get the object, written at the given position. This returs both shared
+ * objects and repository Ids.
+ *
+ * @return the position, at that the object is allready written.
+ *
+ * @throws MARSHAL if there is no object written at that position.
+ */
+ public Object isObjectWrittenAt(int x, int offset)
+ {
+ Entry e = (Entry) positions.get(new Integer(x));
+ if (e instanceof Redirection)
+ return isObjectWrittenAt(e.at, offset);
+ else if (e != null)
+ return e.object;
+ else
+ {
+ MARSHAL m = new MARSHAL("No object was written at " + x +
+ " (offset " + offset + ") r " + this + dump());
+ m.minor = Minor.Graph;
+ throw m;
+ }
+ }
+
+ /**
+ * Mark the given object as written at the given position.
+ */
+ public void singleIdWritten(String id, int at)
+ {
+ if (sh_ids.containsKey(id))
+ throw new InternalError("Repetetive writing of the same string " +
+ id + dump());
+
+ Entry e = new Entry();
+ e.at = at;
+ e.object = id;
+
+ sh_ids.put(id, e);
+ positions.put(new Integer(at), e);
+ }
+
+ /**
+ * Mark the given object as written at the given position.
+ */
+ public void multipleIdsWritten(String[] ids, int at)
+ {
+ if (sh_ids.containsKey(ids))
+ throw new InternalError("Repetetive writing of the same string " +
+ ids + dump());
+
+ Entry e = new Entry();
+ e.at = at;
+ e.object = ids;
+
+ sh_ids.put(ids, e);
+ positions.put(new Integer(at), e);
+ }
+
+ /**
+ * Check if the object is already written.
+ *
+ * @return the position, at that the object is allready written or -1 if it is
+ * not yet written.
+ */
+ public int idWrittenAt(Object x)
+ {
+ Entry e = (Entry) sh_ids.get(x);
+ return e == null ? -1 : e.at;
+ }
+
+ /**
+ * Get the codebase.
+ */
+ public String getCodeBase()
+ {
+ return codebase;
+ }
+
+ /**
+ * Set the codebase, preserving the old value if the passed parameter is null
+ * and forming the space delimited list if both new and old values are not
+ * null.
+ */
+ public void addCodeBase(String base)
+ {
+ if (base != null)
+ {
+ if (codebase == null)
+ codebase = base;
+ else
+ codebase = codebase + " " + base;
+ }
+ }
+
+ /**
+ * Dump all objects that are currently stored.
+ */
+ public String dump()
+ {
+ StringBuffer b = new StringBuffer(" Stream content: \n");
+
+ // Sort by position.
+ TreeSet t = new TreeSet(positions.keySet());
+ Iterator p = t.iterator();
+
+ while (p.hasNext())
+ {
+ Object k = p.next();
+ b.append(" " + k + ": " + ((Entry) positions.get(k)).toString()
+ + "\n");
+ }
+ return b.toString();
+ }
+
+}
diff --git a/gnu/CORBA/CDR/gnuValueStream.java b/gnu/CORBA/CDR/gnuValueStream.java
new file mode 100644
index 000000000..663c99018
--- /dev/null
+++ b/gnu/CORBA/CDR/gnuValueStream.java
@@ -0,0 +1,71 @@
+/* gnuValueStream.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.CDR;
+
+/**
+ * A stream, implementing this interface, provides methods to get/set a position
+ * and get the RunTime.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface gnuValueStream
+{
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition();
+
+ /**
+ * Jump to the given position, taking offset into consideration.
+ */
+ public void seek(int position);
+
+ /**
+ * Get the RunTime information.
+ */
+ public gnuRuntime getRunTime();
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime);
+
+}
diff --git a/gnu/CORBA/CDR/noHeaderInput.java b/gnu/CORBA/CDR/noHeaderInput.java
deleted file mode 100644
index 0c787ddc2..000000000
--- a/gnu/CORBA/CDR/noHeaderInput.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/* noHeaderInput.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.CORBA.CDR;
-
-import org.omg.CORBA.CustomMarshal;
-import org.omg.CORBA.DataInputStream;
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.portable.BoxedValueHelper;
-import org.omg.CORBA.portable.Streamable;
-import org.omg.CORBA.portable.ValueFactory;
-
-import java.io.Serializable;
-
-/**
- * Substitutes the main stream in factories when the header is already
- * behind. Overrides methods that may be invoked from the factory,
- * forcing not to read the header if called first time on this stream.
- *
- * This stream reverts to default behavior if one or more call are
- * made (reading value types that are nested fields of the value type).
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
- */
-class noHeaderInput
- extends cdrBufInput
- implements DataInputStream
-{
- /**
- * If true, this is not the first call.
- */
- boolean notFirst;
-
- /**
- * Create an instance, reading from the given buffer.
- */
- public noHeaderInput(byte[] buffer)
- {
- super(buffer);
- }
-
- /**
- * Read when knowning the class instance.
- */
- public Serializable read_value(Class clz)
- {
- if (notFirst)
- return super.read_value(clz);
- else
- {
- try
- {
- notFirst = true;
- return read_value((Serializable) clz.newInstance());
- }
- catch (Exception ex)
- {
- MARSHAL m = new MARSHAL("Unable to create an instance");
- m.initCause(ex);
- throw m;
- }
- }
- }
-
- /**
- * Tries to read using boxed value helper.
- */
- public Serializable read_value(BoxedValueHelper helper)
- {
- if (notFirst)
- return super.read_value(helper);
- else
- {
- notFirst = true;
- return helper.read_value(this);
- }
- }
-
- /**
- * Tries to locate a factory using repository id.
- */
- public Serializable read_value(String repository_id)
- {
- if (notFirst)
- return super.read_value(repository_id);
- else
- {
- notFirst = true;
-
- ValueFactory factory =
- ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);
- if (factory == null)
- throw new MARSHAL("No factory");
- return factory.read_value(this);
- }
- }
-
- /**
- * Try to read when having an unitialised value.
- */
- public Serializable read_value(Serializable value)
- {
- if (notFirst)
- return super.read_value(value);
- else
- {
- notFirst = true;
-
- // The user-defines io operations are implemented.
- if (value instanceof CustomMarshal)
- {
- CustomMarshal marsh = (CustomMarshal) value;
- try
- {
- marsh.unmarshal((DataInputStream) this);
- }
- catch (ClassCastException ex)
- {
- Vio.incorrect_plug_in(ex);
- }
- }
- else
- // The IDL-generated io operations are implemented.
- if (value instanceof Streamable)
- {
- ((Streamable) value)._read(this);
- }
- return value;
- }
- }
-} \ No newline at end of file
diff --git a/gnu/CORBA/cdrEncapsCodec.java b/gnu/CORBA/CdrEncapsCodecImpl.java
index 699c6f76a..93dd1cdcd 100644
--- a/gnu/CORBA/cdrEncapsCodec.java
+++ b/gnu/CORBA/CdrEncapsCodecImpl.java
@@ -1,4 +1,4 @@
-/* cdrEncapsCodec.java --
+/* CdrEncapsCodecImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,9 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -57,19 +57,19 @@ import org.omg.IOP.CodecPackage.TypeMismatch;
/**
* The local {@link Codec} implementation for ENCODING_CDR_ENCAPS
* encoding. This is a local implementation; the remote side should
- * have its own Codec of this kind.
+ * have its own Codec of this kind.
*
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class cdrEncapsCodec
+public class CdrEncapsCodecImpl
extends LocalObject
implements Codec
{
- /**
- * The default version of encoding, used in parameterless constructor.
+ /**
+ * Use serialVersionUID for interoperability.
*/
- private static final Version DEFAULT_VERSION = new Version(1, 2);
+ private static final long serialVersionUID = 1;
/**
* If set to true, no wide string or wide character is allowed (GIOP 1.0).
@@ -99,7 +99,7 @@ public class cdrEncapsCodec
/**
* Create an instance of this Codec, encoding following the given version.
*/
- public cdrEncapsCodec(ORB _orb, Version _version)
+ public CdrEncapsCodecImpl(ORB _orb, Version _version)
{
orb = _orb;
version = _version;
@@ -125,8 +125,8 @@ public class cdrEncapsCodec
public Any decode(byte[] them)
throws FormatMismatch
{
- cdrBufInput input = createInput(them);
- cdrBufInput encapsulation = createEncapsulation(them, input);
+ BufferredCdrInput input = createInput(them);
+ BufferredCdrInput encapsulation = createEncapsulation(them, input);
TypeCode type = encapsulation.read_TypeCode();
@@ -142,9 +142,9 @@ public class cdrEncapsCodec
return readAny(type, encapsulation);
}
- private cdrBufInput createEncapsulation(byte[] them, cdrBufInput input)
+ private BufferredCdrInput createEncapsulation(byte[] them, BufferredCdrInput input)
{
- cdrBufInput encapsulation;
+ BufferredCdrInput encapsulation;
if ((them [ 0 ] | them [ 1 ] | them [ 2 ] | them [ 3 ]) == 0)
{
@@ -163,10 +163,10 @@ public class cdrEncapsCodec
{
checkTypePossibility("", that.type());
- cdrBufOutput output = createOutput(that);
+ BufferedCdrOutput output = createOutput(that);
- // cdrBufOutput has internal support for this encoding.
- cdrOutput encapsulation = output.createEncapsulation();
+ // BufferedCdrOutput has internal support for this encoding.
+ AbstractCdrOutput encapsulation = output.createEncapsulation();
try
{
@@ -179,6 +179,7 @@ public class cdrEncapsCodec
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Encapsulation;
m.initCause(ex);
throw m;
}
@@ -206,8 +207,8 @@ public class cdrEncapsCodec
throw new TypeMismatch(ex.getMessage());
}
- cdrBufInput input = createInput(them);
- cdrBufInput encapsulation = createEncapsulation(them, input);
+ BufferredCdrInput input = createInput(them);
+ BufferredCdrInput encapsulation = createEncapsulation(them, input);
return readAny(type, encapsulation);
}
@@ -217,13 +218,13 @@ public class cdrEncapsCodec
* @param type a type of the Any to read.
* @param input the encapsulation stream.
*/
- private Any readAny(TypeCode type, cdrBufInput encapsulation)
+ private Any readAny(TypeCode type, BufferredCdrInput encapsulation)
throws MARSHAL
{
gnuAny a = new gnuAny();
a.setOrb(orb);
- // cdrBufInput has internal support for this encoding.
+ // BufferredCdrInput has internal support for this encoding.
a.read_value(encapsulation, type);
return a;
}
@@ -234,9 +235,9 @@ public class cdrEncapsCodec
{
checkTypePossibility("", that.type());
- cdrBufOutput output = createOutput(that);
+ BufferedCdrOutput output = createOutput(that);
- cdrOutput encapsulation = output.createEncapsulation();
+ AbstractCdrOutput encapsulation = output.createEncapsulation();
try
{
@@ -248,6 +249,7 @@ public class cdrEncapsCodec
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Encapsulation;
m.initCause(ex);
throw m;
}
@@ -256,7 +258,7 @@ public class cdrEncapsCodec
/**
* Create the CDR output stream for writing the given Any.
- * The cdrBufOutput has internal support for encapsulation encodings.
+ * The BufferedCdrOutput has internal support for encapsulation encodings.
*
* @param that the Any that will be written.
*
@@ -265,10 +267,10 @@ public class cdrEncapsCodec
* @throws InvalidTypeForEncoding if that Any cannot be written under the
* given version.
*/
- private cdrBufOutput createOutput(Any that)
+ private BufferedCdrOutput createOutput(Any that)
throws InvalidTypeForEncoding
{
- cdrBufOutput output = new cdrBufOutput();
+ BufferedCdrOutput output = new BufferedCdrOutput();
output.setOrb(orb);
output.setVersion(version);
return output;
@@ -325,9 +327,9 @@ public class cdrEncapsCodec
*
* @return the stream.
*/
- private cdrBufInput createInput(byte[] them)
+ private BufferredCdrInput createInput(byte[] them)
{
- cdrBufInput input = new cdrBufInput(them);
+ BufferredCdrInput input = new BufferredCdrInput(them);
input.setOrb(orb);
input.setVersion(version);
return input;
diff --git a/gnu/CORBA/corbaArrayList.java b/gnu/CORBA/CorbaList.java
index 1690f0583..25bea9230 100644
--- a/gnu/CORBA/corbaArrayList.java
+++ b/gnu/CORBA/CorbaList.java
@@ -1,4 +1,4 @@
-/* corbaArrayList.java --
+/* CorbaList.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import org.omg.CORBA.Bounds;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class corbaArrayList
+public class CorbaList
extends ArrayList
implements Serializable
{
@@ -64,7 +64,7 @@ public class corbaArrayList
/**
* Creates the list with the given initial size.
*/
- public corbaArrayList(int initial_size)
+ public CorbaList(int initial_size)
{
super(initial_size);
}
@@ -72,7 +72,7 @@ public class corbaArrayList
/**
* Creates the list with the default size.
*/
- public corbaArrayList()
+ public CorbaList()
{
}
diff --git a/gnu/CORBA/DefaultSocketFactory.java b/gnu/CORBA/DefaultSocketFactory.java
new file mode 100644
index 000000000..51df04719
--- /dev/null
+++ b/gnu/CORBA/DefaultSocketFactory.java
@@ -0,0 +1,79 @@
+/* DefaultSocketFactory.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.interfaces.SocketFactory;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * The default socket factory that forges "plain" server and client sockets. The
+ * class can be replaced by setting the gnu.CORBA.SocketFactory property.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class DefaultSocketFactory
+ implements SocketFactory
+{
+ /**
+ * It is enough to have one instance of this class for all ORBs.
+ */
+ public static final DefaultSocketFactory Singleton = new DefaultSocketFactory();
+
+ /**
+ * Create a client socket.
+ */
+ public Socket createClientSocket(String host, int port)
+ throws IOException
+ {
+ return new Socket(host, port);
+ }
+
+ /**
+ * Create a server socket.
+ */
+ public ServerSocket createServerSocket(int port)
+ throws IOException
+ {
+ return new ServerSocket(port);
+ }
+
+}
diff --git a/gnu/CORBA/DynAn/abstractDynAny.java b/gnu/CORBA/DynAn/AbstractAny.java
index 47176c4b5..7060f86b2 100644
--- a/gnu/CORBA/DynAn/abstractDynAny.java
+++ b/gnu/CORBA/DynAn/AbstractAny.java
@@ -1,4 +1,4 @@
-/* abstractDynAny.java --
+/* AbstractAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
-import gnu.CORBA.typeNamer;
+import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -54,7 +54,7 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class abstractDynAny
+public abstract class AbstractAny
extends LocalObject
implements Serializable
{
@@ -108,12 +108,12 @@ public abstract class abstractDynAny
/**
* The change value listener.
*/
- valueChangedListener listener;
+ ValueChangeListener listener;
/**
* Create the abstract dyn any.
*/
- public abstractDynAny(TypeCode oType, TypeCode aType,
+ public AbstractAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -163,8 +163,8 @@ public abstract class abstractDynAny
*/
String typeMismatch(TypeCode expected, TypeCode actual)
{
- return typeNamer.nameIt(expected) + " expected " +
- typeNamer.nameIt(actual);
+ return TypeKindNamer.nameIt(expected) + " expected " +
+ TypeKindNamer.nameIt(actual);
}
/**
diff --git a/gnu/CORBA/DynAn/anyDivideable.java b/gnu/CORBA/DynAn/DivideableAny.java
index 5f52c8078..c96cbedc7 100644
--- a/gnu/CORBA/DynAn/anyDivideable.java
+++ b/gnu/CORBA/DynAn/DivideableAny.java
@@ -1,4 +1,4 @@
-/* anyDivideable.java --
+/* DivideableAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
-import gnu.CORBA.typeNamer;
+import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.CompletionStatus;
@@ -58,8 +58,8 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class anyDivideable
- extends abstractDynAny
+public abstract class DivideableAny
+ extends AbstractAny
implements Serializable
{
/**
@@ -78,7 +78,7 @@ public abstract class anyDivideable
*/
protected int pos = 0;
- public anyDivideable(TypeCode oType, TypeCode aType,
+ public DivideableAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -486,9 +486,9 @@ public abstract class anyDivideable
{
if (!official_type.equal(other.type()))
return false;
- else if (other instanceof anyDivideable)
+ else if (other instanceof DivideableAny)
{
- anyDivideable x = (anyDivideable) other;
+ DivideableAny x = (DivideableAny) other;
if (x.array.length != array.length)
return false;
@@ -499,7 +499,7 @@ public abstract class anyDivideable
}
return true;
}
- else if (other == null || other instanceof abstractDynAny)
+ else if (other == null || other instanceof AbstractAny)
return false;
else
return other.to_any().equal(to_any());
diff --git a/gnu/CORBA/DynAn/abstractRecord.java b/gnu/CORBA/DynAn/RecordAny.java
index 8d8b7a559..a3e3680d9 100644
--- a/gnu/CORBA/DynAn/abstractRecord.java
+++ b/gnu/CORBA/DynAn/RecordAny.java
@@ -1,4 +1,4 @@
-/* abstractRecord.java --
+/* RecordAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
+import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -65,8 +65,8 @@ import java.lang.reflect.Field;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class abstractRecord
- extends anyDivideable
+public abstract class RecordAny
+ extends DivideableAny
implements DynAny, Serializable
{
/**
@@ -80,7 +80,7 @@ public abstract class abstractRecord
*
* @param fields The DynAny's, representing the fields of the structure.
*/
- public abstractRecord(TypeCode oType, TypeCode aType,
+ public RecordAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -277,7 +277,7 @@ public abstract class abstractRecord
c [ i ] = array [ i ].copy();
}
- abstractRecord d = newInstance(official_type, final_type, factory, orb);
+ RecordAny d = newInstance(official_type, final_type, factory, orb);
d.array = c;
return d;
}
@@ -285,7 +285,7 @@ public abstract class abstractRecord
/**
* Create a new instance when copying.
*/
- protected abstract abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ protected abstract RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory,
ORB anOrb
);
@@ -297,7 +297,7 @@ public abstract class abstractRecord
{
try
{
- Streamable sHolder = holderFactory.createHolder(official_type);
+ Streamable sHolder = HolderLocator.createHolder(official_type);
Class sHolderClass = sHolder.getClass();
Field sHolderValue = sHolderClass.getField("value");
@@ -371,7 +371,7 @@ public abstract class abstractRecord
fField = structure.getClass().getField(fNames [ i ]);
field = fField.get(structure);
fType = array [ i ].type();
- holder = holderFactory.createHolder(fType);
+ holder = HolderLocator.createHolder(fType);
member = createAny();
holder.getClass().getField("value").set(holder, field);
diff --git a/gnu/CORBA/DynAn/anyUndivideable.java b/gnu/CORBA/DynAn/UndivideableAny.java
index b31a6b357..da4e9618e 100644
--- a/gnu/CORBA/DynAn/anyUndivideable.java
+++ b/gnu/CORBA/DynAn/UndivideableAny.java
@@ -55,8 +55,8 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class anyUndivideable
- extends abstractDynAny
+public abstract class UndivideableAny
+ extends AbstractAny
implements Serializable
{
/**
@@ -67,7 +67,7 @@ public abstract class anyUndivideable
/**
* Create a new instance with the given typecode.
*/
- public anyUndivideable(TypeCode oType, TypeCode aType,
+ public UndivideableAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb)
{
super(oType, aType, aFactory, anOrb);
diff --git a/gnu/CORBA/DynAn/valueChangedListener.java b/gnu/CORBA/DynAn/ValueChangeListener.java
index 94ddffbec..597276159 100644
--- a/gnu/CORBA/DynAn/valueChangedListener.java
+++ b/gnu/CORBA/DynAn/ValueChangeListener.java
@@ -1,4 +1,4 @@
-/* valueChangedListener.java --
+/* ValueChangeListener.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ package gnu.CORBA.DynAn;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public interface valueChangedListener
+public interface ValueChangeListener
{
void changed();
} \ No newline at end of file
diff --git a/gnu/CORBA/DynAn/gnuDynAny.java b/gnu/CORBA/DynAn/gnuDynAny.java
index 015628ebf..23141de3d 100644
--- a/gnu/CORBA/DynAn/gnuDynAny.java
+++ b/gnu/CORBA/DynAn/gnuDynAny.java
@@ -38,14 +38,14 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.OctetHolder;
import gnu.CORBA.Unexpected;
import gnu.CORBA.WCharHolder;
import gnu.CORBA.WStringHolder;
-import gnu.CORBA.holderFactory;
-import gnu.CORBA.typeNamer;
-import gnu.CORBA.universalHolder;
+import gnu.CORBA.HolderLocator;
+import gnu.CORBA.TypeKindNamer;
+import gnu.CORBA.GeneralHolder;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnyHolder;
@@ -84,7 +84,7 @@ import java.util.Arrays;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
+public class gnuDynAny extends AbstractAny implements DynAny, Serializable
{
/**
* Use serialVersionUID for interoperability.
@@ -132,7 +132,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
{
if (holder != null)
{
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
holder._write(buffer);
gnuDynAny other;
@@ -165,7 +165,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
public DynAny current_component() throws TypeMismatch
{
throw new TypeMismatch("Not applicable for " +
- typeNamer.nameIt(final_type)
+ TypeKindNamer.nameIt(final_type)
);
}
@@ -193,14 +193,14 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
{
throw new InvalidValue(ISNULL);
}
- else if (a_holder instanceof universalHolder)
+ else if (a_holder instanceof GeneralHolder)
{
- holder = holderFactory.createHolder(official_type);
+ holder = HolderLocator.createHolder(official_type);
if (holder == null)
- holder = holderFactory.createHolder(final_type);
+ holder = HolderLocator.createHolder(final_type);
if (holder == null)
- holder = ((universalHolder) a_holder).Clone();
+ holder = ((GeneralHolder) a_holder).Clone();
else
{
InputStream in = an_any.create_input_stream();
@@ -890,7 +890,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
*/
public boolean equal(DynAny other)
{
- if (other instanceof abstractDynAny)
+ if (other instanceof AbstractAny)
{
if (other instanceof gnuDynAny)
{
@@ -899,10 +899,10 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
if (!x.holder.getClass().equals(holder.getClass()))
return false;
- cdrBufOutput b1 = new cdrBufOutput();
+ BufferedCdrOutput b1 = new BufferedCdrOutput();
x.holder._write(b1);
- cdrBufOutput b2 = new cdrBufOutput(b1.buffer.size() + 10);
+ BufferedCdrOutput b2 = new BufferedCdrOutput(b1.buffer.size() + 10);
holder._write(b2);
return Arrays.equals(b1.buffer.toByteArray(),
diff --git a/gnu/CORBA/DynAn/gnuDynAnyFactory.java b/gnu/CORBA/DynAn/gnuDynAnyFactory.java
index dd1762890..b8b39bfbc 100644
--- a/gnu/CORBA/DynAn/gnuDynAnyFactory.java
+++ b/gnu/CORBA/DynAn/gnuDynAnyFactory.java
@@ -40,8 +40,8 @@ package gnu.CORBA.DynAn;
import gnu.CORBA.Poa.ORB_1_4;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
-import gnu.CORBA.typeNamer;
+import gnu.CORBA.HolderLocator;
+import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -227,7 +227,7 @@ public class gnuDynAnyFactory
*/
public DynAny create_simple(TypeCode official, TypeCode type)
{
- Streamable holder = holderFactory.createHolder(type);
+ Streamable holder = HolderLocator.createHolder(type);
return new gnuDynAny(holder, official, type, this, orb);
}
@@ -314,7 +314,7 @@ public class gnuDynAnyFactory
case TCKind._tk_Principal :
case TCKind._tk_abstract_interface :
throw new InconsistentTypeCode("Following API, the " +
- typeNamer.nameIt(type) +
+ TypeKindNamer.nameIt(type) +
" must not be supported."
);
diff --git a/gnu/CORBA/DynAn/gnuDynArray.java b/gnu/CORBA/DynAn/gnuDynArray.java
index 1c08496d4..825cd0a56 100644
--- a/gnu/CORBA/DynAn/gnuDynArray.java
+++ b/gnu/CORBA/DynAn/gnuDynArray.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
+import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
@@ -66,7 +66,7 @@ import java.lang.reflect.Field;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynArray
- extends anyDivideable
+ extends DivideableAny
implements DynArray, Serializable
{
/**
@@ -238,10 +238,10 @@ public class gnuDynArray
try
{
Streamable memberHolder =
- holderFactory.createHolder(official_components);
+ HolderLocator.createHolder(official_components);
if (memberHolder == null)
- memberHolder = holderFactory.createHolder(final_components);
+ memberHolder = HolderLocator.createHolder(final_components);
Class memberHolderClass = memberHolder.getClass();
Class memberClass = memberHolderClass.getField("value").getType();
@@ -260,7 +260,7 @@ public class gnuDynArray
Array.set(members, i, member);
}
- Streamable arrayHolder = holderFactory.createHolder(official_type);
+ Streamable arrayHolder = HolderLocator.createHolder(official_type);
arrayHolder.getClass().getField("value").set(arrayHolder, members);
Any g = createAny();
@@ -296,9 +296,9 @@ public class gnuDynArray
{
if (holderClass == null)
{
- holder = holderFactory.createHolder(official_components);
+ holder = HolderLocator.createHolder(official_components);
if (holder == null)
- holder = holderFactory.createHolder(final_components);
+ holder = HolderLocator.createHolder(final_components);
holderClass = holder.getClass();
}
else
diff --git a/gnu/CORBA/DynAn/gnuDynEnum.java b/gnu/CORBA/DynAn/gnuDynEnum.java
index 2fccc85c5..6eb7fe2bc 100644
--- a/gnu/CORBA/DynAn/gnuDynEnum.java
+++ b/gnu/CORBA/DynAn/gnuDynEnum.java
@@ -60,7 +60,7 @@ import java.util.Arrays;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynEnum extends anyUndivideable implements DynEnum
+public class gnuDynEnum extends UndivideableAny implements DynEnum
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/DynAn/gnuDynFixed.java b/gnu/CORBA/DynAn/gnuDynFixed.java
index 39b002262..9655f0387 100644
--- a/gnu/CORBA/DynAn/gnuDynFixed.java
+++ b/gnu/CORBA/DynAn/gnuDynFixed.java
@@ -57,7 +57,7 @@ import java.math.BigDecimal;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynFixed extends anyUndivideable implements DynFixed
+public class gnuDynFixed extends UndivideableAny implements DynFixed
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/DynAn/gnuDynStruct.java b/gnu/CORBA/DynAn/gnuDynStruct.java
index b086d6478..b15aff3e1 100644
--- a/gnu/CORBA/DynAn/gnuDynStruct.java
+++ b/gnu/CORBA/DynAn/gnuDynStruct.java
@@ -54,7 +54,7 @@ import org.omg.DynamicAny.DynAny;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynStruct
- extends abstractRecord
+ extends RecordAny
implements DynStruct, Serializable
{
/**
@@ -89,7 +89,7 @@ public class gnuDynStruct
}
/** @inheritDoc */
- protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ protected RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb)
{
return new gnuDynStruct(oType, aType, aFactory, anOrb);
diff --git a/gnu/CORBA/DynAn/gnuDynUnion.java b/gnu/CORBA/DynAn/gnuDynUnion.java
index ad41e24b6..ef5aed645 100644
--- a/gnu/CORBA/DynAn/gnuDynUnion.java
+++ b/gnu/CORBA/DynAn/gnuDynUnion.java
@@ -62,8 +62,8 @@ import java.io.Serializable;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynUnion
- extends anyDivideable
- implements DynUnion, Serializable, valueChangedListener
+ extends DivideableAny
+ implements DynUnion, Serializable, ValueChangeListener
{
/**
* Use serialVersionUID for interoperability.
@@ -96,7 +96,7 @@ public class gnuDynUnion
discriminator =
factory.create_dyn_any_from_type_code(final_type.discriminator_type());
- ((abstractDynAny) discriminator).listener = this;
+ ((AbstractAny) discriminator).listener = this;
if (final_type.default_index() >= 0)
set_to_default_member();
@@ -114,7 +114,7 @@ public class gnuDynUnion
/*
* (non-Javadoc)
*
- * @see gnu.CORBA.DynAn.anyDivideable#to_any()
+ * @see gnu.CORBA.DynAn.DivideableAny#to_any()
*/
public Any to_any()
{
@@ -171,7 +171,7 @@ public class gnuDynUnion
gnuDynUnion other =
new gnuDynUnion(official_type, final_type, factory, orb);
other.discriminator = discriminator.copy();
- ((abstractDynAny) other.discriminator).listener = other;
+ ((AbstractAny) other.discriminator).listener = other;
if (array.length == 1)
{
other.array = new DynAny[] { other.discriminator };
diff --git a/gnu/CORBA/DynAn/gnuDynValue.java b/gnu/CORBA/DynAn/gnuDynValue.java
index c2db94797..0c31d4093 100644
--- a/gnu/CORBA/DynAn/gnuDynValue.java
+++ b/gnu/CORBA/DynAn/gnuDynValue.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
+import gnu.CORBA.Minor;
import gnu.CORBA.Unexpected;
import org.omg.CORBA.Any;
@@ -66,7 +67,7 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynValue extends abstractRecord implements DynValue,
+public class gnuDynValue extends RecordAny implements DynValue,
Serializable
{
/**
@@ -243,7 +244,7 @@ public class gnuDynValue extends abstractRecord implements DynValue,
/**
* Create a new instance.
*/
- protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ protected RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -301,9 +302,12 @@ public class gnuDynValue extends abstractRecord implements DynValue,
ValueFactory factory =
((org.omg.CORBA_2_3.ORB) orb).lookup_value_factory(official_type.id());
if (factory == null)
- throw new MARSHAL("Factory for " + official_type.id() +
- " not registered."
- );
+ {
+ MARSHAL m = new MARSHAL("Factory for " + official_type.id() +
+ " not registered.");
+ m.minor = Minor.Factory;
+ throw m;
+ }
OutputStream out = orb.create_output_stream();
diff --git a/gnu/CORBA/DynAn/gnuDynValueBox.java b/gnu/CORBA/DynAn/gnuDynValueBox.java
index 66e18f3b2..a13e9fc2c 100644
--- a/gnu/CORBA/DynAn/gnuDynValueBox.java
+++ b/gnu/CORBA/DynAn/gnuDynValueBox.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
+import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -65,7 +65,7 @@ import java.lang.reflect.Field;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynValueBox
- extends anyDivideable
+ extends DivideableAny
implements DynValueBox, Serializable
{
/**
@@ -208,7 +208,7 @@ public class gnuDynValueBox
{
try
{
- Streamable holder = holderFactory.createHolder(content);
+ Streamable holder = HolderLocator.createHolder(content);
Field v = holder.getClass().getField("value");
v.set(holder, s);
diff --git a/gnu/CORBA/EmptyExceptionHolder.java b/gnu/CORBA/EmptyExceptionHolder.java
index 890ca5fe5..8fc8697a4 100644
--- a/gnu/CORBA/EmptyExceptionHolder.java
+++ b/gnu/CORBA/EmptyExceptionHolder.java
@@ -125,6 +125,7 @@ public class EmptyExceptionHolder
catch (Exception ex)
{
BAD_OPERATION bad = new BAD_OPERATION();
+ bad.minor = Minor.CDR;
bad.initCause(ex);
throw bad;
}
diff --git a/gnu/CORBA/ExceptionCreator.java b/gnu/CORBA/ExceptionCreator.java
deleted file mode 100644
index abe309dc7..000000000
--- a/gnu/CORBA/ExceptionCreator.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/* ExceptionCreator.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.CORBA;
-
-import org.omg.CORBA.CompletionStatus;
-import org.omg.CORBA.CompletionStatusHelper;
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.SystemException;
-import org.omg.CORBA.UNKNOWN;
-import org.omg.CORBA.UserException;
-import org.omg.CORBA.portable.InputStream;
-import org.omg.CORBA.portable.OutputStream;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/**
- * Creates the objects from the agreed IDL names.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class ExceptionCreator
-{
- /**
- * The standard OMG prefix.
- */
- public static final String OMG_PREFIX = "omg.org/";
-
- /**
- * The standard java prefix.
- */
- public static final String JAVA_PREFIX = "org.omg.";
-
- /**
- * Create the system exception with the given idl name.
- *
- * @param idl the exception IDL name, must match the syntax
- * "IDL:<class/name>:1.0".
- * @param minor the exception minor code.
- * @param completed the exception completion status.
- *
- * @return the created exception.
- */
- public static SystemException createSystemException(String idl, int minor,
- CompletionStatus completed
- )
- {
- try
- {
- String cl = toClassName(idl);
- Class exClass = Class.forName(cl);
-
- Constructor constructor =
- exClass.getConstructor(new Class[]
- {
- String.class, int.class,
- CompletionStatus.class
- }
- );
-
- Object exception =
- constructor.newInstance(new Object[]
- {
- " Remote exception " + idl + ", minor " +
- minor + ", " + completed + ".",
- new Integer(minor), completed
- }
- );
-
- return (SystemException) exception;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- return new UNKNOWN("Unsupported system exception", minor, completed);
- }
- }
-
- /**
- * Read the system exception from the given stream.
- * @param input the CDR stream to read from.
- * @return the exception that has been stored in the stream
- * (IDL name, minor code and completion status).
- */
- public static SystemException readSystemException(InputStream input)
- {
- String idl = input.read_string();
- int minor = input.read_ulong();
- CompletionStatus status = CompletionStatusHelper.read(input);
-
- SystemException exception =
- ExceptionCreator.createSystemException(idl, minor, status);
-
- return exception;
- }
-
- /**
- * Reads the user exception, having the given Id, from the
- * input stream. The id is expected to be in the form like
- * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
- * @param idl the exception idl name.
- * @param input the stream to read from.
- *
- * @return the loaded exception, or <code>null</code> if the helper class
- * cannot be found.
- */
- public static UserException readUserException(String idl, InputStream input)
- {
- try
- {
- String helper = toHelperName(idl);
- Class helperClass = Class.forName(helper);
-
- Method read =
- helperClass.getMethod("read",
- new Class[]
- {
- org.omg.CORBA.portable.InputStream.class
- }
- );
-
- return (UserException) read.invoke(null, new Object[] { input });
- }
- catch (MARSHAL mex)
- {
- // This one is ok to throw
- throw mex;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- /**
- * Writes the system exception data to CDR output stream.
- *
- * @param output a stream to write data to.
- * @param ex an exception to write.
- */
- public static void writeSystemException(OutputStream output,
- SystemException ex
- )
- {
- String exIDL = toIDL(ex.getClass().getName());
- output.write_string(exIDL);
- output.write_ulong(ex.minor);
- CompletionStatusHelper.write(output, ex.completed);
- }
-
- /**
- * Converts the given IDL name to class name.
- *
- * @param IDL the idl name.
- *
- */
- protected static String toClassName(String IDL)
- {
- String s = IDL;
- int a = s.indexOf(':') + 1;
- int b = s.lastIndexOf(':');
-
- s = IDL.substring(a, b);
-
- if (s.startsWith(OMG_PREFIX))
- s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
-
- return s.replace('/', '.');
- }
-
- /**
- * Gets the helper class name from the string like
- * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
- * @param IDL the idl name.
- */
- protected static String toHelperName(String IDL)
- {
- String s = IDL;
- int a = s.indexOf(':') + 1;
- int b = s.lastIndexOf(':');
-
- s = IDL.substring(a, b);
-
- if (s.startsWith(OMG_PREFIX))
- s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
-
- return s.replace('/', '.') + "Helper";
- }
-
- /**
- * Convert the class name to IDL name.
- *
- * @param cn the class name.
- *
- * @return the idl name.
- */
- protected static String toIDL(String cn)
- {
- if (cn.startsWith(JAVA_PREFIX))
- cn = cn.substring(JAVA_PREFIX.length());
-
- cn = cn.replace('.', '/');
-
- return "IDL:" + OMG_PREFIX + cn + ":1.0";
- }
-}
diff --git a/gnu/CORBA/Focused_ORB.java b/gnu/CORBA/Focused_ORB.java
new file mode 100644
index 000000000..a895ce441
--- /dev/null
+++ b/gnu/CORBA/Focused_ORB.java
@@ -0,0 +1,375 @@
+/* Focused_ORB.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.Poa.ORB_1_4;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.NO_RESOURCES;
+import org.omg.CORBA.portable.InvokeHandler;
+
+import java.applet.Applet;
+import java.net.ServerSocket;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Random;
+import java.util.StringTokenizer;
+
+/**
+ * This class implements the ORB that uses a single port or the restricted port
+ * range for all its objects. It is required to for use together with various
+ * firewalls that does not allow opening multiple randomly selected ports, as
+ * the defauld CORBA implementation used to do. The firewal must be configured
+ * to allow CORBA to work on one fixed port or (for better performance) on a
+ * small fixed range of ports. This does not restrict the maximal number of the
+ * connected objects as the objects can share the same port.
+ *
+ * The used port or the used port range can be specified via property
+ * gnu.CORBA.ListenerPort. The value of this property is a single port or range
+ * of ports, boundary values (inclusive) being separeted by dash (for instance,
+ * "1245-1250").
+ *
+ * It is possible to instantiate multiple instances of the focused ORBs and
+ * combine them with the ordinary ORBs. If you instantiate several instances of
+ * the focused ORBs on the same host, they used port sets should not overlap.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Focused_ORB
+ extends ORB_1_4
+{
+ /**
+ * The name of the fixed port range property. The presence of this property
+ * indicates that the default focused ORB must be used.
+ */
+ public static final String LISTENER_PORT = "gnu.CORBA.ListenerPort";
+
+ /**
+ * The start of the range of the available ports, inclusive.
+ */
+ int m_ports_from = -1;
+
+ /**
+ * The end of the range of the available ports, inclusive.
+ */
+ int m_ports_to = -1;
+
+ /**
+ * The requests to port are served in parallel threads.
+ */
+ static final int PARALLEL = 0;
+
+ /**
+ * The requests to port are served in the same thread.
+ */
+ static final int SEQUENTIAL = 1;
+
+ /**
+ * The random number generator to get a random port in the valid range.
+ */
+ Random m_random = new Random();
+
+ /**
+ * Parse the "gnu.CORBA.ListenerPort" property and initialize the valid port
+ * set range.
+ */
+ public void setPortRange(String property)
+ {
+ int from, to;
+ try
+ {
+ StringTokenizer st = new StringTokenizer(property, " -");
+ if (st.countTokens() == 1)
+ from = to = Integer.parseInt(st.nextToken());
+ else
+ {
+ from = Integer.parseInt(st.nextToken());
+ to = Integer.parseInt(st.nextToken());
+ m_random = new Random();
+ }
+ setPortRange(from, to);
+ }
+ catch (Exception ex)
+ {
+ throw new BAD_PARAM("Unable to parse port range '" + property + "'");
+ }
+ }
+
+ /**
+ * Set the port range.
+ *
+ * @param from - start of the port range, inclusive.
+ * @param to - end of the port range, inclusive.
+ */
+ public void setPortRange(int from, int to)
+ {
+ if (from < 0 || to < 0 || to < from)
+ throw new BAD_PARAM("Invalid range");
+ m_ports_from = from;
+ m_ports_to = to;
+ }
+
+ /**
+ * Get the port from the previously specified usage range.
+ */
+ int getPortFromRange(int attempt)
+ {
+ if (m_ports_from == m_ports_to)
+ return m_ports_from;
+ else if (m_ports_to - m_ports_from < RANDOM_PORT_ATTEMPTS)
+ return m_ports_from + (attempt % (m_ports_to - m_ports_from + 1));
+ else
+ return m_random.nextInt(m_ports_to - m_ports_from + 1) + m_ports_from;
+ }
+
+ /**
+ * Get the shared port server where the new object can be added. This may
+ * result reusing the existing server or instantiating a new server. If the
+ * new server is instantiated and the ORB is already running, the server is
+ * started.
+ */
+ protected portServer getPortServer(int type)
+ {
+ portServer p;
+
+ int n;
+ if (m_ports_from < m_ports_to)
+ n = RANDOM_PORT_ATTEMPTS;
+ else
+ n = 1;
+
+ Ports: for (int a = 0; a < n; a++)
+ {
+ int port = getPortFromRange(a);
+ for (int i = 0; i < portServers.size(); i++)
+ {
+ p = (portServer) portServers.get(i);
+ if (p.s_port == port)
+ {
+ return (portServer) p;
+ }
+ }
+ // The server is not yet instantiated. Instantiate.
+ try
+ {
+ // Check if the port is ok:
+ ServerSocket s = socketFactory.createServerSocket(port);
+ s.close();
+
+ portServer shared;
+
+ switch (type)
+ {
+ case PARALLEL:
+ shared = new portServer(port);
+ break;
+
+ case SEQUENTIAL:
+ shared = new sharedPortServer(port);
+ break;
+
+ default:
+ throw new InternalError("Invalid server type " + type);
+ }
+
+ portServers.add(shared);
+
+ if (running)
+ shared.start();
+
+ return shared;
+ }
+ catch (Exception ex)
+ {
+ // Port is taken or probably other problems.
+ continue Ports;
+ }
+ }
+ throw new NO_RESOURCES("No free port available at " + m_ports_from + "-"
+ + m_ports_to, Minor.Ports, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Start the ORBs main working cycle (receive invocation - invoke on the local
+ * object - send response - wait for another invocation).
+ *
+ * The method only returns after calling {@link #shutdown(boolean)}.
+ */
+ public void run()
+ {
+ if (m_ports_from < 0 || m_ports_to < 0)
+ throw new BAD_INV_ORDER("For " + getClass().getName() + " "
+ + LISTENER_PORT + " property must be set");
+
+ running = true;
+
+ // Start all port servers. In the current subclass, the portServers
+ // collection must be already filled in.
+ Iterator iter = portServers.iterator();
+
+ while (iter.hasNext())
+ {
+ portServer subserver = (portServer) iter.next();
+
+ if (!subserver.isAlive())
+ {
+ // Reuse the current thread for the last portServer.
+ if (!iter.hasNext())
+ {
+ // Discard the iterator.
+ iter = null;
+ subserver.run();
+ return;
+ }
+ else
+ subserver.start();
+ }
+ }
+ }
+
+ /**
+ * Get free port from the allowed range. This method instantiates the port
+ * server for the returned port.
+ */
+ public int getFreePort()
+ throws BAD_OPERATION
+ {
+ portServer s = getPortServer(PARALLEL);
+ return s.s_port;
+ }
+
+ /**
+ * Connect the given CORBA object to this ORB, explicitly specifying the
+ * object key and the identity of the thread (and port), where the object must
+ * be served. The identity is normally the POA.
+ *
+ * The new port server will be started only if there is no one already running
+ * for the same identity. Otherwise, the task of the existing port server will
+ * be widened, including duty to serve the given object. All objects,
+ * connected to a single identity by this method, will process they requests
+ * subsequently in the same thread. The method is used when the expected
+ * number of the objects is too large to have a single port and thread per
+ * object. This method is used by POAs, having a single thread policy.
+ *
+ * @param object the object, must implement the {@link InvokeHandler})
+ * interface.
+ * @param key the object key, usually used to identify the object from remote
+ * side.
+ * @param port the port, where the object must be connected.
+ *
+ * @throws BAD_PARAM if the object does not implement the
+ * {@link InvokeHandler}).
+ */
+ public void connect_1_thread(org.omg.CORBA.Object object, byte[] key,
+ java.lang.Object identity)
+ {
+ sharedPortServer shared = (sharedPortServer) identities.get(identity);
+ if (shared == null)
+ {
+ shared = (sharedPortServer) getPortServer(SEQUENTIAL);
+ identities.put(identity, shared);
+ if (running)
+ {
+ shared.start();
+ }
+ }
+
+ Connected_objects.cObject ref = connected_objects.add(key, object,
+ shared.s_port, identity);
+ IOR ior = createIOR(ref);
+ prepareObject(object, ior);
+ }
+
+ /**
+ * In this type of ORB, the service is started by {@link #getPortServer}. The
+ * method below is not in use and should return without action.
+ */
+ public void startService(IOR ior)
+ {
+ }
+
+ /**
+ * Set parameters (additionally search for the port range property).
+ */
+ protected void set_parameters(Applet applet, Properties props)
+ {
+ super.set_parameters(applet, props);
+ String lp = applet.getParameter(LISTENER_PORT);
+ if (lp != null)
+ setPortRange(lp);
+ }
+
+ /**
+ * Set parameters (additionally search for the port range property).
+ */
+ protected void set_parameters(String[] args, Properties props)
+ {
+ super.set_parameters(args, props);
+ String lp = null;
+
+ String lpKey = "-" + LISTENER_PORT;
+
+ if (args != null)
+ if (args.length >= 2)
+ {
+ for (int i = 0; i < args.length - 1; i++)
+ if (args[i].equals(lpKey))
+ lp = args[i + 1];
+ }
+
+ if (lp != null)
+ setPortRange(lp);
+
+ }
+
+ /**
+ * Additionally set the port range property, when applicable.
+ */
+ protected void useProperties(Properties props)
+ {
+ super.useProperties(props);
+ String lp = props.getProperty(LISTENER_PORT);
+ if (lp != null)
+ setPortRange(lp);
+ }
+
+}
diff --git a/gnu/CORBA/ForwardRequestHelper.java b/gnu/CORBA/ForwardRequestHelper.java
index c7fae5b06..cbdf46f25 100644
--- a/gnu/CORBA/ForwardRequestHelper.java
+++ b/gnu/CORBA/ForwardRequestHelper.java
@@ -81,6 +81,7 @@ public abstract class ForwardRequestHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ForwardRequest expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/gnu/CORBA/GIOP/CharSets_OSF.java b/gnu/CORBA/GIOP/CharSets_OSF.java
index f3f35dbaa..bffb02678 100644
--- a/gnu/CORBA/GIOP/CharSets_OSF.java
+++ b/gnu/CORBA/GIOP/CharSets_OSF.java
@@ -47,7 +47,10 @@ import java.util.Set;
/**
* This class contains the codes, used to identify character sets
* in CORBA. These codes are defined in Open Software Foundation (OSF)
- * code set registry
+ * code set registry.
+ *
+ * The name of this class specially sets "OSF" apart if somebody would start
+ * searching Open Software Foundation abbreviation.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
diff --git a/gnu/CORBA/GIOP/CloseMessage.java b/gnu/CORBA/GIOP/CloseMessage.java
index d884329c4..38039c2ed 100644
--- a/gnu/CORBA/GIOP/CloseMessage.java
+++ b/gnu/CORBA/GIOP/CloseMessage.java
@@ -38,15 +38,13 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.IOR;
+import gnu.CORBA.Minor;
import org.omg.CORBA.MARSHAL;
import java.io.IOException;
import java.io.OutputStream;
-import java.net.Socket;
-
/**
* The explicit command to close the connection.
*
@@ -60,6 +58,11 @@ import java.net.Socket;
public class CloseMessage
extends MessageHeader
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The singleton close message is typically enough, despite new
* instances may be instantiated if the specific version field
@@ -95,6 +98,7 @@ public class CloseMessage
catch (IOException ex)
{
MARSHAL m = new MARSHAL("Unable to flush the stream");
+ m.minor = Minor.Header;
m.initCause(ex);
throw m;
}
diff --git a/gnu/CORBA/GIOP/cxCodeSet.java b/gnu/CORBA/GIOP/CodeSetServiceContext.java
index 7f42c07f2..ab565db37 100644
--- a/gnu/CORBA/GIOP/cxCodeSet.java
+++ b/gnu/CORBA/GIOP/CodeSetServiceContext.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.IOR;
import gnu.CORBA.IOR.CodeSets_profile;
@@ -51,7 +51,7 @@ import java.io.IOException;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class cxCodeSet
+public class CodeSetServiceContext
extends ServiceContext
{
/**
@@ -62,7 +62,7 @@ public class cxCodeSet
/**
* The standard component to include in the messages.
*/
- public static final cxCodeSet STANDARD = new cxCodeSet();
+ public static final CodeSetServiceContext STANDARD = new CodeSetServiceContext();
/**
* The encoding, used to transfer the narrow (1 byte) character data.
@@ -84,13 +84,13 @@ public class cxCodeSet
*
* @param contexts the array of contexts, can be null.
*/
- public static cxCodeSet find(ServiceContext[] contexts)
+ public static CodeSetServiceContext find(ServiceContext[] contexts)
{
if (contexts != null)
for (int i = 0; i < contexts.length; i++)
{
- if (contexts [ i ] instanceof cxCodeSet)
- return (cxCodeSet) contexts [ i ];
+ if (contexts [ i ] instanceof CodeSetServiceContext)
+ return (CodeSetServiceContext) contexts [ i ];
}
return STANDARD;
}
@@ -102,12 +102,12 @@ public class cxCodeSet
* If you take this task, scan 'TODO character encoding' for
* relevant places.
*/
- public static cxCodeSet negotiate(IOR.CodeSets_profile profile)
+ public static CodeSetServiceContext negotiate(IOR.CodeSets_profile profile)
{
if (profile.negotiated != null)
return profile.negotiated;
- cxCodeSet use = new cxCodeSet();
+ CodeSetServiceContext use = new CodeSetServiceContext();
use.char_data =
negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);
@@ -124,9 +124,9 @@ public class cxCodeSet
* Read the context from the given stream. Does not read the
* code sets id.
*/
- public void readContext(cdrInput input)
+ public void readContext(AbstractCdrInput input)
{
- cdrInput encap = input.read_encapsulation();
+ AbstractCdrInput encap = input.read_encapsulation();
char_data = encap.read_ulong();
wide_char_data = encap.read_ulong();
@@ -145,11 +145,11 @@ public class cxCodeSet
* Write the context to the given stream, including the code
* sets id.
*/
- public void write(cdrOutput output)
+ public void write(AbstractCdrOutput output)
{
output.write_ulong(ID);
- cdrOutput enout = output.createEncapsulation();
+ AbstractCdrOutput enout = output.createEncapsulation();
enout.write_long(char_data);
enout.write_ulong(wide_char_data);
diff --git a/gnu/CORBA/GIOP/contextSupportingHeader.java b/gnu/CORBA/GIOP/ContextHandler.java
index ba6c1f88d..77ea20e38 100644
--- a/gnu/CORBA/GIOP/contextSupportingHeader.java
+++ b/gnu/CORBA/GIOP/ContextHandler.java
@@ -1,4 +1,4 @@
-/* contextSupportingHeader.java --
+/* ContextHandler.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import org.omg.CORBA.BAD_INV_ORDER;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class contextSupportingHeader
+public abstract class ContextHandler
{
/**
diff --git a/gnu/CORBA/GIOP/ErrorMessage.java b/gnu/CORBA/GIOP/ErrorMessage.java
index 8d3b3539b..99942fee3 100644
--- a/gnu/CORBA/GIOP/ErrorMessage.java
+++ b/gnu/CORBA/GIOP/ErrorMessage.java
@@ -38,7 +38,9 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
+import gnu.CORBA.Minor;
import java.io.IOException;
import java.io.OutputStream;
@@ -46,6 +48,7 @@ import java.io.OutputStream;
import java.net.Socket;
import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
/**
* The error message is sent in response to the message, encoded
@@ -59,6 +62,11 @@ import org.omg.CORBA.MARSHAL;
public class ErrorMessage
extends MessageHeader
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* Create a new error message, setting the message field
* to the {@link MESSAGE_ERROR} and the version number to
@@ -73,14 +81,22 @@ public class ErrorMessage
/**
* Send the error message to the given IOR address.
*
- * @param to the IOR address (host and port, other fields
+ * @param ior the IOR address (host and port, other fields
* are not used).
+ *
+ * @param orb the ORB, sending the error message.
*/
- public void send(IOR ior)
+ public void send(IOR ior, ORB orb)
{
try
{
- Socket socket = new Socket(ior.Internet.host, ior.Internet.port);
+ Socket socket;
+
+ if (orb instanceof OrbFunctional)
+ socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
+ ior.Internet.host, ior.Internet.port);
+ else
+ socket = new Socket(ior.Internet.host, ior.Internet.port);
OutputStream socketOutput = socket.getOutputStream();
write(socketOutput);
@@ -90,6 +106,7 @@ public class ErrorMessage
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
diff --git a/gnu/CORBA/GIOP/MessageHeader.java b/gnu/CORBA/GIOP/MessageHeader.java
index 61c46e11e..e1bdb512b 100644
--- a/gnu/CORBA/GIOP/MessageHeader.java
+++ b/gnu/CORBA/GIOP/MessageHeader.java
@@ -1,4 +1,4 @@
-/* MessageHeader.java -- GIOP 1.0 message header.
+/* MessageHeader.java -- GIOP message header.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,33 +38,39 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
+import gnu.CORBA.Minor;
+import gnu.CORBA.Version;
+import gnu.CORBA.CDR.BigEndianInputStream;
import gnu.CORBA.CDR.BigEndianOutputStream;
import gnu.CORBA.CDR.LittleEndianInputStream;
import gnu.CORBA.CDR.LittleEndianOutputStream;
-import gnu.CORBA.CDR.abstractDataOutputStream;
-import gnu.CORBA.Version;
+import gnu.CORBA.CDR.AbstractDataInput;
+import gnu.CORBA.CDR.AbstractDataOutput;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.portable.IDLEntity;
-import java.io.DataInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-
+import java.net.Socket;
import java.util.Arrays;
-import gnu.CORBA.CDR.BigEndianInputStream;
-import gnu.CORBA.CDR.abstractDataInputStream;
-import java.io.InputStream;
/**
* The GIOP message header.
- *
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class MessageHeader
implements IDLEntity
{
/**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
* Request message.
*/
public static final byte REQUEST = 0;
@@ -80,16 +86,15 @@ public class MessageHeader
public static final byte CANCEL_REQUEST = 2;
/**
- * Locate request message, used to check the server ability to
- * process requests for the object reference.
- * This message is also used to get the
+ * Locate request message, used to check the server ability to process
+ * requests for the object reference. This message is also used to get the
* address where the object reference should be sent.
*/
public static final byte LOCATE_REQUEST = 3;
/**
- * Locate reply message, sent in response to the
- * {@link #LocateRequest} message.
+ * Locate reply message, sent in response to the {@link #LocateRequest}
+ * message.
*/
public static final byte LOCATE_REPLY = 4;
@@ -104,8 +109,8 @@ public class MessageHeader
public static final byte MESSAGE_ERROR = 6;
/**
- * The fragment messge, following the previous message that
- * has more fragments flag set. Added in GIOP 1.1
+ * The fragment messge, following the previous message that has more fragments
+ * flag set. Added in GIOP 1.1
*/
public static final byte FRAGMENT = 7;
@@ -117,12 +122,9 @@ public class MessageHeader
/**
* The message type names.
*/
- protected static String[] types =
- new String[]
- {
- "Request", "Reply", "Cancel", "Locate request", "Locate reply",
- "Close connection", "Error", "Fragment"
- };
+ protected static String[] types = new String[] { "Request", "Reply",
+ "Cancel", "Locate request", "Locate reply", "Close connection", "Error",
+ "Fragment" };
/**
* The GIOP version. Initialised to 1.0 .
@@ -154,7 +156,7 @@ public class MessageHeader
/**
* Create an empty message header, corresponding the given version.
- *
+ *
* @param major the major message header version.
* @param minor the minot message header version.
*/
@@ -164,8 +166,8 @@ public class MessageHeader
}
/**
- * Checks if the message is encoded in the Big Endian, most significant
- * byte first.
+ * Checks if the message is encoded in the Big Endian, most significant byte
+ * first.
*/
public boolean isBigEndian()
{
@@ -173,10 +175,18 @@ public class MessageHeader
}
/**
+ * Checks if the message is partial, and more subsequent fragments follow.
+ */
+ public boolean moreFragmentsFollow()
+ {
+ return (flags & 0x2) != 0;
+ }
+
+ /**
* Set the encoding to use.
- *
- * @param use_big_endian if true (default), the Big Endian
- * encoding is used. If false, the Little Endian encoding is used.
+ *
+ * @param use_big_endian if true (default), the Big Endian encoding is used.
+ * If false, the Little Endian encoding is used.
*/
public void setBigEndian(boolean use_big_endian)
{
@@ -196,16 +206,16 @@ public class MessageHeader
/**
* Get the message type as string.
- *
+ *
* @param type the message type as int (the field {@link message_type}).
- *
+ *
* @return the message type as string.
*/
public String getTypeString(int type)
{
try
{
- return types [ type ];
+ return types[type];
}
catch (ArrayIndexOutOfBoundsException ex)
{
@@ -215,10 +225,10 @@ public class MessageHeader
/**
* Creates reply header, matching the message header version number.
- *
+ *
* @return one of {@link gnu.CORBA.GIOP.v1_0.ReplyHeader},
- * {@link gnu.CORBA.GIOP.v1_2.ReplyHeader}, etc - depending on
- * the version number in this header.
+ * {@link gnu.CORBA.GIOP.v1_2.ReplyHeader}, etc - depending on the version
+ * number in this header.
*/
public ReplyHeader create_reply_header()
{
@@ -230,10 +240,10 @@ public class MessageHeader
/**
* Creates request header, matching the message header version number.
- *
+ *
* @return one of {@link gnu.CORBA.GIOP.v1_0.RequestHeader},
- * {@link gnu.CORBA.GIOP.v1_2.RequestHeader}, etc - depending on
- * the version number in this header.
+ * {@link gnu.CORBA.GIOP.v1_2.RequestHeader}, etc - depending on the version
+ * number in this header.
*/
public RequestHeader create_request_header()
{
@@ -261,24 +271,28 @@ public class MessageHeader
/**
* Read the header from the stream.
- *
+ *
* @param istream a stream to read from.
- *
+ *
* @throws MARSHAL if this is not a GIOP 1.0 header.
*/
public void read(java.io.InputStream istream)
- throws MARSHAL
+ throws MARSHAL
{
try
{
- byte[] xMagic = new byte[ MAGIC.length ];
+ byte[] xMagic = new byte[MAGIC.length];
istream.read(xMagic);
if (!Arrays.equals(xMagic, MAGIC))
- throw new MARSHAL("Not a GIOP message");
+ {
+ MARSHAL m = new MARSHAL("Not a GIOP message");
+ m.minor = Minor.Giop;
+ throw m;
+ }
version = Version.read_version(istream);
- abstractDataInputStream din;
+ AbstractDataInput din;
flags = (byte) istream.read();
@@ -295,6 +309,7 @@ public class MessageHeader
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
@@ -302,26 +317,26 @@ public class MessageHeader
/**
* Get the short string summary of the message.
- *
+ *
* @return a short message summary.
*/
public String toString()
{
- return "GIOP " + version + ", " + (isBigEndian() ? "Big" : "Little") +
- " endian, " + getTypeString(message_type) + ", " + message_size +
- " bytes. ";
+ return "GIOP " + version + ", " + (isBigEndian() ? "Big" : "Little")
+ + " endian, " + getTypeString(message_type) + ", " + message_size
+ + " bytes. ";
}
/**
* Write the header to stream.
- *
+ *
* @param out a stream to write into.
*/
public void write(java.io.OutputStream out)
{
try
{
- abstractDataOutputStream dout;
+ AbstractDataOutput dout;
if (isBigEndian())
dout = new BigEndianOutputStream(out);
@@ -333,18 +348,99 @@ public class MessageHeader
// Write version number.
version.write((OutputStream) dout);
-
dout.write(flags);
-
dout.write(message_type);
-
dout.writeInt(message_size);
}
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
}
+
+ /**
+ * Read data, followed by the message header. Handle fragmented messages.
+ *
+ * @param source the data source to read from.
+ * @param service the socket on that the time outs are set. Can be null (no
+ * timeouts are set).
+ * @param to_read the timeout while reading the message.
+ * @param to_pause the timeout for pauses between the message parts.
+ */
+ public byte[] readMessage(InputStream source, Socket service, int to_read,
+ int to_pause)
+ {
+ try
+ {
+ byte[] r = new byte[message_size];
+
+ int n = 0;
+ if (service != null)
+ service.setSoTimeout(to_read);
+
+ reading: while (n < r.length)
+ {
+ n += source.read(r, n, r.length - n);
+ }
+ if (service != null)
+ service.setSoTimeout(to_pause);
+
+ // Read the message remainder if the message is fragmented.
+ if (moreFragmentsFollow())
+ {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream(
+ 2 * r.length);
+ buffer.write(r);
+
+ if (r.length < 10)
+ // Increase the buffer size if the default value (size of the
+ // previous message) is really too small.
+ r = new byte[1024];
+
+ MessageHeader h2 = new MessageHeader();
+
+ do
+ {
+ h2.read(source);
+
+ int dn;
+
+ n = 0;
+ reading: while (n < h2.message_size)
+ {
+ dn = source.read(r, 0, h2.message_size - n);
+
+ if (n == 0 && service != null)
+ service.setSoTimeout(to_read);
+
+ if (n == 0 && version.since_inclusive(1, 2))
+ {
+ // Skip the four byte request id.
+ buffer.write(r, 4, dn - 4);
+ }
+ else
+ buffer.write(r, 0, dn);
+ n = +dn;
+ }
+
+ if (service != null)
+ service.setSoTimeout(to_pause);
+ }
+ while (h2.moreFragmentsFollow());
+ return buffer.toByteArray();
+ }
+ else
+ return r;
+ }
+ catch (IOException ioex)
+ {
+ MARSHAL m = new MARSHAL("Unable to read the message continuation.");
+ m.minor = Minor.Header;
+ m.initCause(ioex);
+ throw m;
+ }
+ }
} \ No newline at end of file
diff --git a/gnu/CORBA/GIOP/ReplyHeader.java b/gnu/CORBA/GIOP/ReplyHeader.java
index f0f409394..d14482903 100644
--- a/gnu/CORBA/GIOP/ReplyHeader.java
+++ b/gnu/CORBA/GIOP/ReplyHeader.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
/**
* The header of the standard reply.
@@ -47,7 +47,7 @@ import gnu.CORBA.CDR.cdrOutput;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class ReplyHeader
- extends contextSupportingHeader
+ extends ContextHandler
{
/**
* Reply status, if no exception occured.
@@ -121,7 +121,7 @@ public abstract class ReplyHeader
*
* @param in a stream to read from.
*/
- public abstract void read(cdrInput in);
+ public abstract void read(AbstractCdrInput in);
/**
* Returns a short string representation.
@@ -141,5 +141,5 @@ public abstract class ReplyHeader
*
* @param out a stream to write into.
*/
- public abstract void write(cdrOutput out);
+ public abstract void write(AbstractCdrOutput out);
}
diff --git a/gnu/CORBA/GIOP/RequestHeader.java b/gnu/CORBA/GIOP/RequestHeader.java
index 17cccb883..3cfadfd78 100644
--- a/gnu/CORBA/GIOP/RequestHeader.java
+++ b/gnu/CORBA/GIOP/RequestHeader.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.portable.IDLEntity;
@@ -49,7 +49,7 @@ import org.omg.CORBA.portable.IDLEntity;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class RequestHeader
- extends contextSupportingHeader
+ extends ContextHandler
implements IDLEntity
{
/**
@@ -137,7 +137,7 @@ public abstract class RequestHeader
*
* @param in a stream to read from.
*/
- public abstract void read(cdrInput in);
+ public abstract void read(AbstractCdrInput in);
/**
* Return a string representation.
@@ -149,6 +149,6 @@ public abstract class RequestHeader
*
* @param out a stream to write into.
*/
- public abstract void write(cdrOutput out);
+ public abstract void write(AbstractCdrOutput out);
}
diff --git a/gnu/CORBA/GIOP/ServiceContext.java b/gnu/CORBA/GIOP/ServiceContext.java
index 29a8ea8ac..78519510c 100644
--- a/gnu/CORBA/GIOP/ServiceContext.java
+++ b/gnu/CORBA/GIOP/ServiceContext.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
@@ -48,7 +48,7 @@ import org.omg.CORBA.portable.IDLEntity;
/**
* Contains the ORB service data being passed.
- *
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ServiceContext
@@ -59,6 +59,50 @@ public class ServiceContext
*/
private static final long serialVersionUID = 1;
+ /* Standard values for the context_id. */
+ public static final int TransactionService = 0;
+
+ /**
+ * Defines code sets, used to encode wide and narrow characters. Required for
+ * messages with data structures, involving wide characters.
+ */
+ public static final int CodeSets = 1;
+
+ public static final int ChainBypassCheck = 2;
+
+ public static final int ChainBypassInfo = 3;
+
+ public static final int LogicalThreadId = 4;
+
+ public static final int BI_DIR_IIOP = 5;
+
+ public static final int SendingContextRunTime = 6;
+
+ public static final int INVOCATION_POLICIES = 7;
+
+ public static final int FORWARDED_IDENTITY = 8;
+
+ /**
+ * Contains exception details if exception being transferred is other than
+ * System or User exception. javax.rmi uses this context to transfer arbitrary
+ * java exceptions as CORBA value types.
+ */
+ public static final int UnknownExceptionInfo = 9;
+
+ public static final int RTCorbaPriority = 10;
+
+ public static final int RTCorbaPriorityRange = 11;
+
+ public static final int FT_GROUP_VERSION = 12;
+
+ public static final int FT_REQUEST = 13;
+
+ public static final int ExceptionDetailMessage = 14;
+
+ public static final int SecurityAttributeService = 15;
+
+ public static final int ActivityService = 16;
+
/**
* The context id (for instance, 0x1 for code sets context). At the moment of
* writing, the OMG defines 16 standard values and provides rules to register
@@ -90,18 +134,18 @@ public class ServiceContext
/**
* Read the context values from the stream.
- *
+ *
* @param istream a stream to read from.
*/
- public static ServiceContext read(cdrInput istream)
+ public static ServiceContext read(AbstractCdrInput istream)
{
int id = istream.read_ulong();
switch (id)
{
- case cxCodeSet.ID:
+ case CodeSetServiceContext.ID:
- cxCodeSet codeset = new cxCodeSet();
+ CodeSetServiceContext codeset = new CodeSetServiceContext();
codeset.readContext(istream);
return codeset;
@@ -117,7 +161,7 @@ public class ServiceContext
/**
* Read a sequence of contexts from the input stream.
*/
- public static ServiceContext[] readSequence(cdrInput istream)
+ public static ServiceContext[] readSequence(AbstractCdrInput istream)
{
int size = istream.read_long();
ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[size];
@@ -128,10 +172,10 @@ public class ServiceContext
/**
* Write the context values into the stream.
- *
+ *
* @param ostream a stream to write the data to.
*/
- public void write(cdrOutput ostream)
+ public void write(AbstractCdrOutput ostream)
{
ostream.write_ulong(context_id);
ostream.write_sequence(context_data);
@@ -140,7 +184,7 @@ public class ServiceContext
/**
* Write the sequence of contexts into the input stream.
*/
- public static void writeSequence(cdrOutput ostream, ServiceContext[] value)
+ public static void writeSequence(AbstractCdrOutput ostream, ServiceContext[] value)
{
ostream.write_long(value.length);
for (int i = 0; i < value.length; i++)
@@ -172,8 +216,7 @@ public class ServiceContext
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
- + service_context.context_id, 15,
- CompletionStatus.COMPLETED_NO);
+ + service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
else
cx[exists] = service_context;
}
@@ -205,15 +248,13 @@ public class ServiceContext
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
- + service_context.context_id, 15,
- CompletionStatus.COMPLETED_NO);
+ + service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
else
cx[exists] = new ServiceContext(service_context);
return cx;
}
}
-
/**
* Find context with the given name in the context array.
*/
@@ -227,8 +268,8 @@ public class ServiceContext
}
/**
- * Find context with the given name in the context array,
- * converting into org.omg.IOP.ServiceContext.
+ * Find context with the given name in the context array, converting into
+ * org.omg.IOP.ServiceContext.
*/
public static org.omg.IOP.ServiceContext findContext(int ctx_name,
ServiceContext[] cx)
@@ -240,6 +281,17 @@ public class ServiceContext
}
/**
+ * Find context with the given name in the context array without conversions.
+ */
+ public static ServiceContext find(int ctx_name, ServiceContext[] cx)
+ {
+ for (int i = 0; i < cx.length; i++)
+ if (cx[i].context_id == ctx_name)
+ return cx[i];
+ return null;
+ }
+
+ /**
* Return a string representation.
*/
public String toString()
diff --git a/gnu/CORBA/GIOP/v1_0/ReplyHeader.java b/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
index 27181ca63..c085c17fb 100644
--- a/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
+++ b/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_0;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
/**
* The header of the standard reply.
@@ -98,13 +98,13 @@ public class ReplyHeader
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
service_context = ServiceContext.readSequence(in);
request_id = in.read_ulong();
reply_status = in.read_ulong();
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -128,12 +128,12 @@ public class ReplyHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
ServiceContext.writeSequence(out, service_context);
out.write_ulong(request_id);
out.write_ulong(reply_status);
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/gnu/CORBA/GIOP/v1_0/RequestHeader.java b/gnu/CORBA/GIOP/v1_0/RequestHeader.java
index 7ede4e5b9..5cf723cbc 100644
--- a/gnu/CORBA/GIOP/v1_0/RequestHeader.java
+++ b/gnu/CORBA/GIOP/v1_0/RequestHeader.java
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_0;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.portable.IDLEntity;
@@ -112,7 +112,7 @@ public class RequestHeader
*
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
service_context = ServiceContext.readSequence(in);
request_id = in.read_ulong();
@@ -121,7 +121,7 @@ public class RequestHeader
operation = in.read_string();
requesting_principal = in.read_sequence();
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -143,7 +143,7 @@ public class RequestHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
ServiceContext.writeSequence(out, service_context);
out.write_ulong(request_id);
@@ -152,6 +152,6 @@ public class RequestHeader
out.write_string(operation);
out.write_sequence(requesting_principal);
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/gnu/CORBA/GIOP/v1_2/ReplyHeader.java b/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
index c3f51a37b..3fc1541d9 100644
--- a/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
+++ b/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_2;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
/**
* GIOP 1.2 reply header.
@@ -56,7 +56,7 @@ public class ReplyHeader
*/
public ReplyHeader()
{
- service_context = new ServiceContext[] { cxCodeSet.STANDARD };
+ service_context = new ServiceContext[] { CodeSetServiceContext.STANDARD };
}
/**
@@ -89,13 +89,13 @@ public class ReplyHeader
*
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
request_id = in.read_ulong();
reply_status = in.read_ulong();
service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -107,12 +107,12 @@ public class ReplyHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
out.write_ulong(request_id);
out.write_ulong(reply_status);
gnu.CORBA.GIOP.ServiceContext.writeSequence(out, service_context);
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/gnu/CORBA/GIOP/v1_2/RequestHeader.java b/gnu/CORBA/GIOP/v1_2/RequestHeader.java
index d294d0067..6b37b6c67 100644
--- a/gnu/CORBA/GIOP/v1_2/RequestHeader.java
+++ b/gnu/CORBA/GIOP/v1_2/RequestHeader.java
@@ -38,10 +38,11 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_2;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.Minor;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import java.io.IOException;
@@ -58,6 +59,11 @@ import org.omg.CORBA.NO_IMPLEMENT;
public class RequestHeader
extends gnu.CORBA.GIOP.v1_0.RequestHeader
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* Indicates that the object is addressed by the object key.
*/
@@ -89,7 +95,7 @@ public class RequestHeader
*/
public RequestHeader()
{
- service_context = new ServiceContext[] { cxCodeSet.STANDARD };
+ service_context = new ServiceContext[] { CodeSetServiceContext.STANDARD };
}
/**
@@ -123,7 +129,7 @@ public class RequestHeader
*
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
try
{
@@ -150,20 +156,23 @@ public class RequestHeader
throw new NO_IMPLEMENT("Object addressing by by IOR addressing info");
default :
- throw new MARSHAL("Unknow addressing method in request, " +
+ MARSHAL m = new MARSHAL("Unknow addressing method in request, " +
AddressingDisposition
);
+ m.minor = Minor.UnsupportedAddressing;
+ throw m;
}
operation = in.read_string();
service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
// No requesting principal in this new format.
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
@@ -186,7 +195,7 @@ public class RequestHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
out.write_ulong(request_id);
@@ -208,6 +217,6 @@ public class RequestHeader
ServiceContext.writeSequence(out, service_context);
// No requesting principal in this new format.
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/gnu/CORBA/universalHolder.java b/gnu/CORBA/GeneralHolder.java
index c20dac442..ffba69d79 100644
--- a/gnu/CORBA/universalHolder.java
+++ b/gnu/CORBA/GeneralHolder.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.MARSHAL;
@@ -60,18 +60,18 @@ import java.io.IOException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class universalHolder
+public class GeneralHolder
implements Streamable
{
/**
* The binary data, stored inside this holder.
*/
- private cdrBufOutput value = new cdrBufOutput();
+ private BufferedCdrOutput value = new BufferedCdrOutput();
/**
* Create the universal holder that uses the given buffer to store the data.
*/
- public universalHolder(cdrBufOutput buffer)
+ public GeneralHolder(BufferedCdrOutput buffer)
{
value = buffer;
}
@@ -89,9 +89,9 @@ public class universalHolder
{
try
{
- if (input instanceof cdrBufInput)
+ if (input instanceof BufferredCdrInput)
{
- cdrBufInput b = (cdrBufInput) input;
+ BufferredCdrInput b = (BufferredCdrInput) input;
value.write(b.buffer.getBuffer());
}
else
@@ -110,6 +110,7 @@ public class universalHolder
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Any;
t.initCause(ex);
throw t;
}
@@ -122,7 +123,9 @@ public class universalHolder
*/
public TypeCode _type()
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.minor = Minor.Inappropriate;
+ throw bad;
}
/**
@@ -142,6 +145,7 @@ public class universalHolder
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Any;
t.initCause(ex);
throw t;
}
@@ -158,13 +162,13 @@ public class universalHolder
/**
* Clone.
*/
- public universalHolder Clone()
+ public GeneralHolder Clone()
{
try
{
- cdrBufOutput nb = new cdrBufOutput(value.buffer.size());
+ BufferedCdrOutput nb = new BufferedCdrOutput(value.buffer.size());
value.buffer.writeTo(nb);
- return new universalHolder(nb);
+ return new GeneralHolder(nb);
}
catch (IOException ex)
{
diff --git a/gnu/CORBA/holderFactory.java b/gnu/CORBA/HolderLocator.java
index 159d22332..edd4d2cf7 100644
--- a/gnu/CORBA/holderFactory.java
+++ b/gnu/CORBA/HolderLocator.java
@@ -1,4 +1,4 @@
-/* holderFactory.java --
+/* HolderLocator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -75,7 +75,7 @@ import org.omg.CORBA.ObjectHolder;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class holderFactory
+public class HolderLocator
{
/**
* The array, sufficiently large to use any {@link TCKind}._tk* constant as
diff --git a/gnu/CORBA/IOR.java b/gnu/CORBA/IOR.java
index 02e94aa64..4f724e8a1 100644
--- a/gnu/CORBA/IOR.java
+++ b/gnu/CORBA/IOR.java
@@ -38,12 +38,12 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.CharSets_OSF;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
@@ -174,16 +174,16 @@ public class IOR
* The negotiated coding result for this IOR. Saves time, requred for
* negotiation computations.
*/
- public cxCodeSet negotiated;
+ public CodeSetServiceContext negotiated;
/**
* Read the code set profile information from the given input stream.
*
* @param profile a stream to read from.
*/
- public void read(cdrInput profile)
+ public void read(AbstractCdrInput profile)
{
- cdrBufInput encapsulation = profile.read_encapsulation();
+ BufferredCdrInput encapsulation = profile.read_encapsulation();
narrow.read(encapsulation);
wide.read(encapsulation);
}
@@ -201,9 +201,9 @@ public class IOR
*
* @param profile a stream to write into.
*/
- public void write(cdrOutput profile)
+ public void write(AbstractCdrOutput profile)
{
- cdrOutput encapsulation = profile.createEncapsulation();
+ AbstractCdrOutput encapsulation = profile.createEncapsulation();
narrow.write(encapsulation);
wide.write(encapsulation);
try
@@ -274,13 +274,13 @@ public class IOR
/**
* Write the internet profile (except the heading tag.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
try
{
// Need to write the Internet profile into the separate
// stream as we must know the size in advance.
- cdrOutput b = out.createEncapsulation();
+ AbstractCdrOutput b = out.createEncapsulation();
version.write(b);
b.write_string(host);
@@ -310,6 +310,7 @@ public class IOR
catch (Exception e)
{
MARSHAL m = new MARSHAL("Unable to write Internet profile.");
+ m.minor = Minor.IOR;
m.initCause(e);
throw m;
}
@@ -392,7 +393,7 @@ public class IOR
buf.write(cx);
}
- cdrBufInput cdr = new cdrBufInput(buf.toByteArray());
+ BufferredCdrInput cdr = new BufferredCdrInput(buf.toByteArray());
r._read(cdr);
return r;
@@ -411,7 +412,7 @@ public class IOR
* @param c a stream to read from.
* @throws IOException if the stream throws it.
*/
- public void _read(cdrInput c)
+ public void _read(AbstractCdrInput c)
throws IOException, BAD_PARAM
{
int endian;
@@ -433,13 +434,13 @@ public class IOR
* If the stream contains a null value, the Id and Internet fields become
* equal to null. Otherwise Id contains some string (possibly empty).
*
- * Id is checked for null in cdrInput that then returns null instead of
+ * Id is checked for null in AbstractCdrInput that then returns null instead of
* object.
*
* @param c a stream to read from.
* @throws IOException if the stream throws it.
*/
- public void _read_no_endian(cdrInput c)
+ public void _read_no_endian(AbstractCdrInput c)
throws IOException, BAD_PARAM
{
Id = c.read_string();
@@ -456,7 +457,7 @@ public class IOR
for (int i = 0; i < n_profiles; i++)
{
int tag = c.read_long();
- cdrBufInput profile = c.read_encapsulation();
+ BufferredCdrInput profile = c.read_encapsulation();
if (tag == Internet_profile.TAG_INTERNET_IOP)
{
@@ -515,7 +516,7 @@ public class IOR
* Write this IOR record to the provided CDR stream. This procedure writes the
* zero (Big Endian) marker first.
*/
- public void _write(cdrOutput out)
+ public void _write(AbstractCdrOutput out)
{
// Always use Big Endian.
out.write(0);
@@ -528,7 +529,7 @@ public class IOR
* The null value is written as defined in OMG specification (zero length
* string, followed by an empty set of profiles).
*/
- public static void write_null(cdrOutput out)
+ public static void write_null(AbstractCdrOutput out)
{
// Empty Id string.
out.write_string("");
@@ -541,7 +542,7 @@ public class IOR
* Write this IOR record to the provided CDR stream. The procedure writed data
* in Big Endian, but does NOT add any endian marker to the beginning.
*/
- public void _write_no_endian(cdrOutput out)
+ public void _write_no_endian(AbstractCdrOutput out)
{
// Write repository id.
out.write_string(Id);
@@ -595,7 +596,7 @@ public class IOR
*/
public String toStringifiedReference()
{
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
_write(out);
@@ -675,7 +676,7 @@ public class IOR
TaggedComponent[] present;
if (profile.profile_data.length > 0)
{
- cdrBufInput in = new cdrBufInput(profile.profile_data);
+ BufferredCdrInput in = new BufferredCdrInput(profile.profile_data);
present = new TaggedComponent[in.read_long()];
@@ -687,7 +688,7 @@ public class IOR
else
present = new TaggedComponent[0];
- cdrBufOutput out = new cdrBufOutput(profile.profile_data.length
+ BufferedCdrOutput out = new BufferedCdrOutput(profile.profile_data.length
+ component.component_data.length
+ 8);
diff --git a/gnu/CORBA/Interceptor/Registrator.java b/gnu/CORBA/Interceptor/Registrator.java
index ff35cd0c8..4bb895bb3 100644
--- a/gnu/CORBA/Interceptor/Registrator.java
+++ b/gnu/CORBA/Interceptor/Registrator.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.ObjectCreator;
import gnu.CORBA.gnuCodecFactory;
import org.omg.CORBA.BAD_INV_ORDER;
@@ -87,7 +88,7 @@ public class Registrator extends LocalObject implements ORBInitInfo
/**
* The agreed properties prefix.
*/
- public final static String m_prefix =
+ public static final String m_prefix =
"org.omg.PortableInterceptor.ORBInitializerClass.";
/**
@@ -182,7 +183,8 @@ public class Registrator extends LocalObject implements ORBInitInfo
try
{
String cn = sk.substring(m_prefix.length());
- Class iClass = Class.forName(cn);
+ Class iClass = ObjectCreator.forName(cn);
+
ORBInitializer initializer =
(ORBInitializer) iClass.newInstance();
m_initializers.add(initializer);
@@ -467,4 +469,4 @@ public class Registrator extends LocalObject implements ORBInitInfo
{
return m_ior.size() > 0;
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/Interceptor/gnuIcCurrent.java b/gnu/CORBA/Interceptor/gnuIcCurrent.java
index ee8af7fc0..a33afc336 100644
--- a/gnu/CORBA/Interceptor/gnuIcCurrent.java
+++ b/gnu/CORBA/Interceptor/gnuIcCurrent.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.Poa.ORB_1_4;
import org.omg.CORBA.Any;
@@ -198,7 +198,7 @@ public class gnuIcCurrent extends ObjectImpl implements Current
Any[] r = get_slots();
Any[] copy = new Any[ r.length ];
- cdrBufOutput buf = new cdrBufOutput();
+ BufferedCdrOutput buf = new BufferedCdrOutput();
buf.setOrb(orb);
for (int i = 0; i < copy.length; i++)
diff --git a/gnu/CORBA/IOR_Delegate.java b/gnu/CORBA/IorDelegate.java
index 3b64eb585..27fb5de9a 100644
--- a/gnu/CORBA/IOR_Delegate.java
+++ b/gnu/CORBA/IorDelegate.java
@@ -38,9 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.GIOP.ReplyHeader;
-import gnu.CORBA.Poa.activeObjectMap;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.Context;
@@ -70,23 +69,12 @@ import java.net.Socket;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class IOR_Delegate extends Simple_delegate
+public class IorDelegate extends SimpleDelegate
{
/**
- * True if the current IOR does not map into the local servant. If false, the
- * IOR is either local or should be checked.
- */
- boolean remote_ior;
-
- /**
- * If not null, this field contains data about the local servant.
- */
- activeObjectMap.Obj local_ior;
-
- /**
* Contructs an instance of object using the given IOR.
*/
- public IOR_Delegate(ORB an_orb, IOR an_ior)
+ public IorDelegate(ORB an_orb, IOR an_ior)
{
super(an_orb, an_ior);
}
@@ -168,37 +156,36 @@ public class IOR_Delegate extends Simple_delegate
* request to the new direction. The ReplyHeader.LOCATION_FORWARD_PERM will
* cause additionally to remember the new location by this delegate, so
* subsequent calls will be immediately delivered to the new target.
- *
+ *
* @param target the target object.
* @param output the output stream, previously returned by
* {@link #request(org.omg.CORBA.Object, String, boolean)}.
- *
+ *
* @return the input stream, to read the response from or null for a one-way
* request.
- *
+ *
* @throws SystemException if the SystemException has been thrown on the
* remote side (the exact type and the minor code matches the data of the
* remote exception that has been thrown).
- *
+ *
* @throws org.omg.CORBA.portable.ApplicationException as specified.
* @throws org.omg.CORBA.portable.RemarshalException as specified.
*/
public InputStream invoke(org.omg.CORBA.Object target, OutputStream output)
throws ApplicationException, RemarshalException
{
- streamRequest request = (streamRequest) output;
- Forwardings:
- while (true)
+ StreamBasedRequest request = (StreamBasedRequest) output;
+ Forwardings: while (true)
{
try
{
if (request.response_expected)
{
- binaryReply response = request.request.submit();
+ RawReply response = request.request.submit();
// Read reply header.
ReplyHeader rh = response.header.create_reply_header();
- cdrBufInput input = response.getStream();
+ BufferredCdrInput input = response.getStream();
input.setOrb(orb);
rh.read(input);
request.request.m_rph = rh;
@@ -207,34 +194,33 @@ public class IOR_Delegate extends Simple_delegate
switch (rh.reply_status)
{
- case ReplyHeader.NO_EXCEPTION :
+ case ReplyHeader.NO_EXCEPTION:
if (request.request.m_interceptor != null)
- request.request.m_interceptor.
- receive_reply(request.request.m_info);
+ request.request.m_interceptor.receive_reply(request.request.m_info);
if (response.header.version.since_inclusive(1, 2))
input.align(8);
return input;
- case ReplyHeader.SYSTEM_EXCEPTION :
+ case ReplyHeader.SYSTEM_EXCEPTION:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
- throw ObjectCreator.readSystemException(input);
+ throw ObjectCreator.readSystemException(input,
+ rh.service_context);
- case ReplyHeader.USER_EXCEPTION :
+ case ReplyHeader.USER_EXCEPTION:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
- throw new ApplicationException(request.
- request.m_exception_id, input
- );
+ throw new ApplicationException(
+ request.request.m_exception_id, input);
- case ReplyHeader.LOCATION_FORWARD_PERM :
+ case ReplyHeader.LOCATION_FORWARD_PERM:
moved_permanently = true;
- case ReplyHeader.LOCATION_FORWARD :
+ case ReplyHeader.LOCATION_FORWARD:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
@@ -245,10 +231,8 @@ public class IOR_Delegate extends Simple_delegate
}
catch (IOException ex)
{
- MARSHAL t =
- new MARSHAL("Cant read forwarding info", 5102,
- CompletionStatus.COMPLETED_NO
- );
+ MARSHAL t = new MARSHAL("Cant read forwarding info",
+ 5102, CompletionStatus.COMPLETED_NO);
t.initCause(ex);
throw t;
}
@@ -277,8 +261,8 @@ public class IOR_Delegate extends Simple_delegate
r.setIor(forwarded);
- IOR_contructed_object it =
- new IOR_contructed_object(orb, forwarded);
+ IorObject it = new IorObject(orb,
+ forwarded);
r.m_target = it;
@@ -298,11 +282,10 @@ public class IOR_Delegate extends Simple_delegate
setIor(prev_ior);
}
- default :
- throw new MARSHAL("Unknow reply status: " +
- rh.reply_status, 8000 + rh.reply_status,
- CompletionStatus.COMPLETED_NO
- );
+ default:
+ throw new MARSHAL("Unknow reply status: "
+ + rh.reply_status, 8000 + rh.reply_status,
+ CompletionStatus.COMPLETED_NO);
}
}
else
@@ -314,8 +297,7 @@ public class IOR_Delegate extends Simple_delegate
catch (ForwardRequest forwarded)
{
ForwardRequest fw = forwarded;
- Forwarding2:
- while (true)
+ Forwarding2: while (true)
{
try
{
@@ -356,7 +338,7 @@ public class IOR_Delegate extends Simple_delegate
/**
* Show exception to interceptor.
*/
- void showException(streamRequest request, cdrBufInput input)
+ void showException(StreamBasedRequest request, BufferredCdrInput input)
throws ForwardRequest
{
input.mark(2048);
@@ -408,9 +390,10 @@ public class IOR_Delegate extends Simple_delegate
request.set_target(target);
request.setOperation(operation);
- streamRequest out = request.getParameterStream();
+ StreamBasedRequest out = request.getParameterStream();
out.response_expected = response_expected;
request.setORB(orb);
+ out.setOrb(orb);
return out;
}
@@ -447,8 +430,6 @@ public class IOR_Delegate extends Simple_delegate
public void setIor(IOR an_ior)
{
super.setIor(an_ior);
- remote_ior = false;
- local_ior = null;
}
/**
@@ -456,11 +437,6 @@ public class IOR_Delegate extends Simple_delegate
*/
public boolean is_local(org.omg.CORBA.Object self)
{
- if (remote_ior)
- return false;
- else if (local_ior != null)
- return true;
- else
- return super.is_local(self);
+ return false;
}
} \ No newline at end of file
diff --git a/gnu/CORBA/IOR_contructed_object.java b/gnu/CORBA/IorObject.java
index 2fab70799..02f5a495d 100644
--- a/gnu/CORBA/IOR_contructed_object.java
+++ b/gnu/CORBA/IorObject.java
@@ -1,4 +1,4 @@
-/* IOR_contructed_object.java --
+/* IorObject.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,8 +46,9 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class IOR_contructed_object
+public class IorObject
extends ObjectImpl
+ implements IorProvider
{
/**
* The IOR, from which the object was constructed.
@@ -64,10 +65,10 @@ public class IOR_contructed_object
*
* @param an_ior the IOR.
*/
- public IOR_contructed_object(ORB orb, IOR an_ior)
+ public IorObject(ORB orb, IOR an_ior)
{
ior = an_ior;
- _set_delegate(new IOR_Delegate(orb, ior));
+ _set_delegate(new IorDelegate(orb, ior));
id = new String[] { ior.Id };
}
@@ -76,12 +77,20 @@ public class IOR_contructed_object
*
* @param an_ior the IOR in the string form.
*/
- public IOR_contructed_object(Functional_ORB orb, String an_ior)
+ public IorObject(OrbFunctional orb, String an_ior)
{
ior = IOR.parse(an_ior);
- _set_delegate(new IOR_Delegate(orb, ior));
+ _set_delegate(new IorDelegate(orb, ior));
id = new String[] { ior.Id };
}
+
+ /**
+ * Get the IOR of this object.
+ */
+ public IOR getIor()
+ {
+ return ior;
+ }
public String[] _ids()
{
diff --git a/org/omg/CORBA/IDLEntity.java b/gnu/CORBA/IorProvider.java
index 6515d8330..875b5de1f 100644
--- a/org/omg/CORBA/IDLEntity.java
+++ b/gnu/CORBA/IorProvider.java
@@ -1,4 +1,4 @@
-/* IDLEntity.java --
+/* IorProvider.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,16 +35,18 @@ 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 org.omg.CORBA;
-
-import java.io.Serializable;
+package gnu.CORBA;
/**
- * Indicates that this class has a corresponding Helper class.
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ * Marks the possibility of the implementing object to return the associated
+ * IOR.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public interface IDLEntity
- extends Serializable
+public interface IorProvider
{
+ /**
+ * Get the IOR of the associated object.
+ */
+ IOR getIor();
}
diff --git a/gnu/CORBA/Minor.java b/gnu/CORBA/Minor.java
new file mode 100644
index 000000000..fb5991dc9
--- /dev/null
+++ b/gnu/CORBA/Minor.java
@@ -0,0 +1,276 @@
+/* Minor.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.CORBA;
+
+
+/**
+ * Provides information and operations, related to about the 20 bit vendor minor
+ * code Id. This code is included into all CORBA system exceptions and is also
+ * transferred to remote side.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface Minor
+{
+ // Note: MARSHAL done.
+
+ /* MARSHAL */
+
+ /**
+ * The GNU Classpath VMCID. The last 12 bits can be used to mark up to 4096
+ * possible exceptions.
+ */
+ int vendor = 0x47430000;
+
+ /*
+ * Minor codes form MARSHAL exception.
+ */
+
+ /**
+ * The message being received is not a GIOP message. It does not start from
+ * the expected magic sequence byte[] { 'G', 'I', 'O', 'P' }.
+ */
+ int Giop = 1 | vendor;
+
+ /**
+ * The unexpected IOException while reading or writing the GIOP message header
+ * or the subsequent request or response header
+ */
+ int Header = 2 | vendor;
+
+ /**
+ * The data stream ended before reading all expected values from it. This
+ * usually means that the CORBA message is corrupted, but may also indicate
+ * that the server expects the remote method being invoked to have more or
+ * different parameters.
+ */
+ int EOF = 3 | vendor;
+
+ /**
+ * The unexpected IOException while reading or writing the data via Commond
+ * Data Representation stream.
+ */
+ int CDR = 5 | vendor;
+
+ /**
+ * The unexpected IOException while reading or writing the Value type.
+ */
+ int Value = 6 | vendor;
+
+ /**
+ * The unexpected IOException while handling request forwarding.
+ */
+ int Forwarding = 7 | vendor;
+
+ /**
+ * The unexpected IOException while handling data encapsulation, tagged
+ * components, tagged profiles, etc.
+ */
+ int Encapsulation = 8 | vendor;
+
+ /**
+ * The unexpected IOException while inserting or extracting data to/from the
+ * Any or DynamicAny.
+ */
+ int Any = 9 | vendor;
+
+ /**
+ * The unexpected UserException in the context where it cannot be handled and
+ * must be converted to the SystemException.
+ */
+ int UserException = 10 | vendor;
+
+ /**
+ * While the operation could formally be applied to the target, the OMG
+ * standard states that it is actually not applicable. For example, some CORBA
+ * objects like POA are always local and should not be passed to or returned
+ * from the remote side.
+ */
+ int Inappropriate = 11 | vendor;
+
+ /**
+ * When reading data, it was discovered that size of the data structure like
+ * string, sequence or character is written as the negative number.
+ */
+ int Negative = 12 | vendor;
+
+ /**
+ * Reference to non-existing node in the data grapth while reading the value
+ * types.
+ */
+ int Graph = 14 | vendor;
+
+ /**
+ * Unexpected exception was thrown from the IDL type helper while handling the
+ * object of this type as a boxed value.
+ */
+ int Boxed = 15 | vendor;
+
+ /**
+ * Unable to instantiate an value type object while reading it from the
+ * stream.
+ */
+ int Instantiation = 16 | vendor;
+
+ /**
+ * The header tag of the value type being read from the CDR stream contains an
+ * unexpected value outside 0x7fffff00 .. 0x7fffffff and also not null and not
+ * an indirection.
+ */
+ int ValueHeaderTag = 17 | vendor;
+
+ /**
+ * The header tag flags of the value type being read from the CDR stream make
+ * the invalid combination (for instance, 0x7fffff04).
+ */
+ int ValueHeaderFlags = 18 | vendor;
+
+ /**
+ * The value type class, written on the wire, is not compatible with the
+ * expected class, passed as a parameter to the InputStream.read_value.
+ */
+ int ClassCast = 19 | vendor;
+
+ /**
+ * Positive or otherwise invalid indirection offset when reading the data
+ * graph of the value type.
+ */
+ int Offset = 20 | vendor;
+
+ /**
+ * Errors while reading the chunked value type.
+ */
+ int Chunks = 21 | vendor;
+
+ /**
+ * No means are provided to write this value type.
+ */
+ int UnsupportedValue = 22 | vendor;
+
+ /**
+ * The value factory, required for the operation being invoked, is not
+ * registered with this ORB.
+ */
+ int Factory = 23 | vendor;
+
+ /**
+ * Unsupported object addressing method in GIOP request header.
+ */
+ int UnsupportedAddressing = 24 | vendor;
+
+ /**
+ * Invalid stringified object reference (IOR).
+ */
+ int IOR = 25 | vendor;
+
+ /**
+ * Problems with converting between stubs, ties, interfaces and
+ * implementations.
+ */
+ int TargetConversion = 26 | vendor;
+
+ /**
+ * Problems with reading or writing the fields of the value type object.
+ */
+ int ValueFields = 27 | vendor;
+
+ /**
+ * The instance of the value type is not serializable.
+ */
+ int NonSerializable = 28 | vendor;
+
+ /* BAD_OPERATION */
+
+ /**
+ * The remote side requested to invoke the method that is not available on
+ * that target (client and server probably disagree in the object definition).
+ */
+ int Method = 0 | vendor;
+
+ /**
+ * Failed to activate the inactive object.
+ */
+ int Activation = 10 | vendor;
+
+ /*
+ * Any - Attempt to extract from the Any value of the different type that was
+ * stored into that Any.
+ */
+
+ /* ClassCast - Unable to narrow the object into stub. */
+
+ /**
+ * The policies, applying to ORB or POA prevent the requested operation.
+ */
+ int Policy = 11 | vendor;
+
+ /**
+ * Socket related errors like failure to open socket on the expected port,
+ * failure to get a free port when required and so on.
+ */
+ int Socket = 12 | vendor;
+
+ /**
+ * The passed value for enumeration is outside the valid range for that
+ * enumeration.
+ */
+ int Enumeration = 14 | vendor;
+
+ /**
+ * The passed policy code is outside the valid range of the possible policies
+ * for the given policy type.
+ */
+ int PolicyType = 15 | vendor;
+
+ /* NO_RESOURCES */
+
+ /**
+ * Unable to get a free port for a new socket. Proably too many objects under
+ * unsuitable POA policy.
+ */
+ int Ports = 20 | vendor;
+
+ /**
+ * Too many parallel calls (too many parallel threads). The thread control
+ * prevents malicios client from knocking the server out by suddenly
+ * submitting large number of requests.
+ */
+ int Threads = 21 | vendor;
+
+}
diff --git a/gnu/CORBA/NamingService/Ext.java b/gnu/CORBA/NamingService/Ext.java
index fb7406c46..ee27e68cd 100644
--- a/gnu/CORBA/NamingService/Ext.java
+++ b/gnu/CORBA/NamingService/Ext.java
@@ -73,7 +73,7 @@ public class Ext
* The converter class converts between string and array form of the
* name.
*/
- private snConverter converter = new snConverter();
+ private NameTransformer converter = new NameTransformer();
/**
* Create the extensions for the given instance of the context.
diff --git a/gnu/CORBA/NamingService/cmpNameComponent.java b/gnu/CORBA/NamingService/NameComponentComparator.java
index 1e06fb8ee..6116ba94e 100644
--- a/gnu/CORBA/NamingService/cmpNameComponent.java
+++ b/gnu/CORBA/NamingService/NameComponentComparator.java
@@ -1,4 +1,4 @@
-/* cmpNameComponent.java --
+/* NameComponentComparator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -49,18 +49,18 @@ import java.util.Comparator;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public final class cmpNameComponent
+public final class NameComponentComparator
implements Comparator
{
/**
* The singleton instance of the name comparator.
*/
- public static final cmpNameComponent singleton = new cmpNameComponent();
+ public static final NameComponentComparator singleton = new NameComponentComparator();
/**
* It is enough to have a singleton.
*/
- private cmpNameComponent()
+ private NameComponentComparator()
{
}
@@ -93,6 +93,6 @@ public final class cmpNameComponent
*/
public boolean equals(Object x)
{
- return x instanceof cmpNameComponent;
+ return x instanceof NameComponentComparator;
}
}
diff --git a/gnu/CORBA/NamingService/NameParser.java b/gnu/CORBA/NamingService/NameParser.java
index f886cf935..8fc75c6a5 100644
--- a/gnu/CORBA/NamingService/NameParser.java
+++ b/gnu/CORBA/NamingService/NameParser.java
@@ -1,44 +1,44 @@
/* NameParser.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
-
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
package gnu.CORBA.NamingService;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
@@ -51,8 +51,6 @@ import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CosNaming.NamingContext;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.CosNaming.NamingContextHelper;
import org.omg.CosNaming._NamingContextStub;
import java.io.UnsupportedEncodingException;
@@ -74,7 +72,7 @@ import java.util.StringTokenizer;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class NameParser
- extends snConverter
+ extends NameTransformer
{
/**
* The corbaloc prefix.
@@ -114,7 +112,7 @@ public class NameParser
/**
* The string to name converter, initialized on demand.
*/
- static snConverter converter;
+ static NameTransformer converter;
/**
* The current position.
@@ -143,7 +141,7 @@ public class NameParser
* @return the resolved object.
*/
public synchronized org.omg.CORBA.Object corbaloc(String corbaloc,
- Functional_ORB orb)
+ OrbFunctional orb)
throws BAD_PARAM
{
boolean corbaname;
@@ -329,7 +327,7 @@ public class NameParser
}
if (converter == null)
- converter = new snConverter();
+ converter = new NameTransformer();
try
{
@@ -380,7 +378,7 @@ public class NameParser
static NameParser n = new NameParser();
- static void corbalocT(String ior, Functional_ORB orb)
+ static void corbalocT(String ior, OrbFunctional orb)
{
System.out.println(ior);
System.out.println(n.corbaloc(ior, orb));
@@ -391,7 +389,7 @@ public class NameParser
{
try
{
- Functional_ORB orb = (Functional_ORB) ORB.init(args, null);
+ OrbFunctional orb = (OrbFunctional) ORB.init(args, null);
corbalocT("corbaloc:iiop:1.3@155axyz.com/Prod/aTradingService", orb);
corbalocT("corbaloc:iiop:2.7@255bxyz.com/Prod/bTradingService", orb);
corbalocT("corbaloc:iiop:355cxyz.com/Prod/cTradingService", orb);
diff --git a/gnu/CORBA/NamingService/snConverter.java b/gnu/CORBA/NamingService/NameTransformer.java
index a9b9219d7..0e0782a57 100644
--- a/gnu/CORBA/NamingService/snConverter.java
+++ b/gnu/CORBA/NamingService/NameTransformer.java
@@ -1,4 +1,4 @@
-/* snConverter.java --
+/* NameTransformer.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,7 +51,7 @@ import java.util.StringTokenizer;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class snConverter
+public class NameTransformer
{
/**
* A string, indicating the escape character.
@@ -301,7 +301,7 @@ public class snConverter
NameComponent b = new NameComponent("b/z", "b.k");
NameComponent c = new NameComponent("c", "");
- snConverter sn = new snConverter();
+ NameTransformer sn = new NameTransformer();
try
{
diff --git a/gnu/CORBA/NamingService/NamingMap.java b/gnu/CORBA/NamingService/NamingMap.java
index a69b06172..95deb0096 100644
--- a/gnu/CORBA/NamingService/NamingMap.java
+++ b/gnu/CORBA/NamingService/NamingMap.java
@@ -66,7 +66,7 @@ public class NamingMap
*/
public NamingMap()
{
- map = new TreeMap(cmpNameComponent.singleton);
+ map = new TreeMap(NameComponentComparator.singleton);
}
/**
diff --git a/gnu/CORBA/NamingService/NamingServiceTransient.java b/gnu/CORBA/NamingService/NamingServiceTransient.java
index e46bed7f7..bf72637d7 100644
--- a/gnu/CORBA/NamingService/NamingServiceTransient.java
+++ b/gnu/CORBA/NamingService/NamingServiceTransient.java
@@ -1,4 +1,4 @@
-/* Server.java --
+/* NamingServiceTransient.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.NamingService;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import org.omg.CosNaming.NamingContextExt;
@@ -102,7 +102,7 @@ public class NamingServiceTransient
try
{
// Create and initialize the ORB
- final Functional_ORB orb = new Functional_ORB();
+ final OrbFunctional orb = new OrbFunctional();
if (args.length > 1)
for (int i = 0; i < args.length - 1; i++)
@@ -114,7 +114,7 @@ public class NamingServiceTransient
iorf = args[i + 1];
}
- Functional_ORB.setPort(port);
+ OrbFunctional.setPort(port);
// Create the servant and register it with the ORB
NamingContextExt namer = new Ext(new TransientContext());
@@ -159,6 +159,6 @@ public class NamingServiceTransient
// Restore the default value for allocating ports for the subsequent
// objects.
- Functional_ORB.setPort(Functional_ORB.DEFAULT_INITIAL_PORT);
+ OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
}
}
diff --git a/gnu/CORBA/ObjectCreator.java b/gnu/CORBA/ObjectCreator.java
index 81c1d06e7..5937e76b3 100644
--- a/gnu/CORBA/ObjectCreator.java
+++ b/gnu/CORBA/ObjectCreator.java
@@ -38,27 +38,37 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.UnknownExceptionCtxHandler;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.GIOP.ServiceContext;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.classpath.VMStackWalker;
import org.omg.CORBA.Any;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.CompletionStatusHelper;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ValueBase;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.rmi.CORBA.Util;
/**
* Creates java objects from the agreed IDL names for the simple case when the
* CORBA object is directly mapped into the locally defined java class.
- *
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ObjectCreator
@@ -79,91 +89,137 @@ public class ObjectCreator
public static final String CLASSPATH_PREFIX = "gnu.CORBA.";
/**
+ * Maps classes to they IDL or RMI names. Computing RMI name is an expensive
+ * operations, so frequently used RMI keys are reused. The map must be weak to
+ * ensure that the class can be unloaded, when applicable.
+ */
+ public static Map m_names = new WeakHashMap();
+
+ /**
+ * Maps IDL strings into known classes. The map must be weak to ensure that
+ * the class can be unloaded, when applicable.
+ */
+ public static Map m_classes = new WeakHashMap();
+
+ /**
+ * Maps IDL types to they helpers.
+ */
+ public static Map m_helpers = new WeakHashMap();
+
+ /**
* Try to instantiate an object with the given IDL name. The object must be
* mapped to the local java class. The omg.org domain must be mapped into the
* object in either org/omg or gnu/CORBA namespace.
- *
+ *
* @param IDL name
* @return instantiated object instance or null if no such available.
*/
public static java.lang.Object createObject(String idl, String suffix)
{
- try
- {
- return Class.forName(toClassName(JAVA_PREFIX, idl) + suffix)
- .newInstance();
- }
- catch (Exception ex)
+ synchronized (m_classes)
{
- try
+ Class known = (Class) (suffix == null ? m_classes.get(idl)
+ : m_classes.get(idl + 0xff + suffix));
+ Object object;
+
+ if (known != null)
{
- return Class.forName(toClassName(CLASSPATH_PREFIX, idl) + suffix)
- .newInstance();
+ try
+ {
+ return known.newInstance();
+ }
+ catch (Exception ex)
+ {
+ RuntimeException rex = new RuntimeException(idl + " suffix "
+ + suffix, ex);
+ throw rex;
+ }
}
- catch (Exception exex)
+ else
{
- return null;
+ if (suffix == null)
+ suffix = "";
+ try
+ {
+ known = forName(toClassName(JAVA_PREFIX, idl) + suffix);
+ object = known.newInstance();
+ }
+ catch (Exception ex)
+ {
+ try
+ {
+ known = forName(toClassName(CLASSPATH_PREFIX, idl)
+ + suffix);
+ object = known.newInstance();
+ }
+ catch (Exception exex)
+ {
+ return null;
+ }
+ }
+ m_classes.put(idl + 0xff + suffix, known);
+ return object;
}
}
}
/**
- * Create the system exception with the given idl name.
- *
- * @param idl the exception IDL name, must match the syntax "IDL:<class/name>:1.0".
- * @param minor the exception minor code.
- * @param completed the exception completion status.
- *
- * @return the created exception.
+ * Read the system exception from the given stream.
+ *
+ * @param input the CDR stream to read from.
+ * @param contexts the service contexts in request/reply header/
+ *
+ * @return the exception that has been stored in the stream (IDL name, minor
+ * code and completion status).
*/
- public static SystemException createSystemException(String idl, int minor,
- CompletionStatus completed
- )
+ public static SystemException readSystemException(InputStream input,
+ ServiceContext[] contexts)
{
+ SystemException exception;
+
+ String idl = input.read_string();
+ int minor = input.read_ulong();
+ CompletionStatus completed = CompletionStatusHelper.read(input);
+
try
{
- String cl = toClassName(JAVA_PREFIX, idl);
- Class exClass = Class.forName(cl);
-
- Constructor constructor =
- exClass.getConstructor(new Class[]
- {
- String.class, int.class, CompletionStatus.class
- }
- );
-
- Object exception =
- constructor.newInstance(new Object[]
- {
- " Remote exception " + idl + ", minor " + minor + ", " +
- completed + ".", new Integer(minor), completed
- }
- );
-
- return (SystemException) exception;
+ exception = (SystemException) createObject(idl, null);
+ exception.minor = minor;
+ exception.completed = completed;
}
catch (Exception ex)
{
- ex.printStackTrace();
- return new UNKNOWN("Unsupported system exception", minor, completed);
+ UNKNOWN u = new UNKNOWN("Unsupported system exception " + idl, minor,
+ completed);
+ u.initCause(ex);
+ throw u;
}
- }
- /**
- * Read the system exception from the given stream.
- *
- * @param input the CDR stream to read from.
- * @return the exception that has been stored in the stream (IDL name, minor
- * code and completion status).
- */
- public static SystemException readSystemException(InputStream input)
- {
- String idl = input.read_string();
- int minor = input.read_ulong();
- CompletionStatus status = CompletionStatusHelper.read(input);
+ try
+ {
+ // If UnknownExceptionInfo is present in the contexts, read it and
+ // set as a cause of this exception.
+ ServiceContext uEx = ServiceContext.find(
+ ServiceContext.UnknownExceptionInfo, contexts);
- SystemException exception =
- ObjectCreator.createSystemException(idl, minor, status);
+ if (uEx != null)
+ {
+ BufferredCdrInput in = new BufferredCdrInput(uEx.context_data);
+ in.setOrb(in.orb());
+ if (input instanceof AbstractCdrInput)
+ {
+ ((AbstractCdrInput) input).cloneSettings(in);
+ }
+
+ Throwable t = UnknownExceptionCtxHandler.read(in, contexts);
+ exception.initCause(t);
+ }
+ }
+ catch (Exception ex)
+ {
+ // Unsupported context format. Do not terminate as the user program may
+ // not need it.
+ }
return exception;
}
@@ -172,10 +228,10 @@ public class ObjectCreator
* Reads the user exception, having the given Id, from the input stream. The
* id is expected to be in the form like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
+ *
* @param idl the exception idl name.
* @param input the stream to read from.
- *
+ *
* @return the loaded exception.
* @return null if the helper class cannot be found.
*/
@@ -183,13 +239,10 @@ public class ObjectCreator
{
try
{
- String helper = toHelperName(idl);
- Class helperClass = Class.forName(helper);
+ Class helperClass = findHelper(idl);
- Method read =
- helperClass.getMethod("read",
- new Class[] { org.omg.CORBA.portable.InputStream.class }
- );
+ Method read = helperClass.getMethod("read",
+ new Class[] { org.omg.CORBA.portable.InputStream.class });
return (UserException) read.invoke(null, new Object[] { input });
}
@@ -208,7 +261,7 @@ public class ObjectCreator
/**
* Gets the helper class name from the string like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
+ *
* @param IDL the idl name.
*/
public static String toHelperName(String IDL)
@@ -227,15 +280,14 @@ public class ObjectCreator
/**
* Writes the system exception data to CDR output stream.
- *
+ *
* @param output a stream to write data to.
* @param ex an exception to write.
*/
public static void writeSystemException(OutputStream output,
- SystemException ex
- )
+ SystemException ex)
{
- String exIDL = toIDL(ex.getClass().getName());
+ String exIDL = getRepositoryId(ex.getClass());
output.write_string(exIDL);
output.write_ulong(ex.minor);
CompletionStatusHelper.write(output, ex.completed);
@@ -243,9 +295,9 @@ public class ObjectCreator
/**
* Converts the given IDL name to class name.
- *
+ *
* @param IDL the idl name.
- *
+ *
*/
protected static String toClassName(String prefix, String IDL)
{
@@ -265,34 +317,43 @@ public class ObjectCreator
* Converts the given IDL name to class name and tries to load the matching
* class. The OMG prefix (omg.org) is replaced by the java prefix org.omg. No
* other prefixes are added.
- *
+ *
* @param IDL the idl name.
- *
- * TODO Cache the returned classes, avoiding these string manipulations each
- * time the conversion is required.
- *
+ *
* @return the matching class or null if no such is available.
*/
public static Class Idl2class(String IDL)
{
- String s = IDL;
- int a = s.indexOf(':') + 1;
- int b = s.lastIndexOf(':');
-
- s = IDL.substring(a, b);
-
- if (s.startsWith(OMG_PREFIX))
- s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
-
- String cn = s.replace('/', '.');
-
- try
+ synchronized (m_classes)
{
- return Class.forName(cn);
- }
- catch (ClassNotFoundException ex)
- {
- return null;
+ Class c = (Class) m_classes.get(IDL);
+
+ if (c != null)
+ return c;
+ else
+ {
+ String s = IDL;
+ int a = s.indexOf(':') + 1;
+ int b = s.lastIndexOf(':');
+
+ s = IDL.substring(a, b);
+
+ if (s.startsWith(OMG_PREFIX))
+ s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
+
+ String cn = s.replace('/', '.');
+
+ try
+ {
+ c = forName(cn);
+ m_classes.put(IDL, c);
+ return c;
+ }
+ catch (ClassNotFoundException ex)
+ {
+ return null;
+ }
+ }
}
}
@@ -301,9 +362,9 @@ public class ObjectCreator
* and create an object instance with parameterless constructor. The OMG
* prefix (omg.org) is replaced by the java prefix org.omg. No other prefixes
* are added.
- *
+ *
* @param IDL the idl name.
- *
+ *
* @return instantiated object instance or null if such attempt was not
* successful.
*/
@@ -325,34 +386,53 @@ public class ObjectCreator
}
/**
- * Convert the class name to IDL name.
- *
- * @param cn the class name.
- *
- * @return the idl name.
+ * Convert the class name to IDL or RMI name (repository id). If the class
+ * inherits from IDLEntity, ValueBase or SystemException, returns repository
+ * Id in the IDL:(..) form. If it does not, returns repository Id in the
+ * RMI:(..) form.
+ *
+ * @param cx the class for that the name must be computed.
+ *
+ * @return the idl or rmi name.
*/
- public static String toIDL(String cn)
+ public static synchronized String getRepositoryId(Class cx)
{
- if (cn.startsWith(JAVA_PREFIX))
- cn = OMG_PREFIX + cn.substring(JAVA_PREFIX.length()).replace('.', '/');
- else if (cn.startsWith(CLASSPATH_PREFIX))
- cn =
- OMG_PREFIX +
- cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
-
- return "IDL:" + cn + ":1.0";
+ String name = (String) m_names.get(cx);
+ if (name != null)
+ return name;
+
+ String cn = cx.getName();
+ if (!(IDLEntity.class.isAssignableFrom(cx)
+ || ValueBase.class.isAssignableFrom(cx) || SystemException.class.isAssignableFrom(cx)))
+ {
+ // Not an IDL entity.
+ name = Util.createValueHandler().getRMIRepositoryID(cx);
+ }
+ else
+ {
+ if (cn.startsWith(JAVA_PREFIX))
+ cn = OMG_PREFIX
+ + cn.substring(JAVA_PREFIX.length()).replace('.', '/');
+ else if (cn.startsWith(CLASSPATH_PREFIX))
+ cn = OMG_PREFIX
+ + cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
+
+ name = "IDL:" + cn + ":1.0";
+ }
+ m_names.put(cx, name);
+ return name;
}
/**
* Insert the passed parameter into the given Any, assuming that the helper
* class is available. The helper class must have the "Helper" suffix and be
* in the same package as the class of the object being inserted.
- *
+ *
* @param into the target to insert.
- *
+ *
* @param object the object to insert. It can be any object as far as the
* corresponding helper is provided.
- *
+ *
* @return true on success, false otherwise.
*/
public static boolean insertWithHelper(Any into, Object object)
@@ -360,12 +440,10 @@ public class ObjectCreator
try
{
String helperClassName = object.getClass().getName() + "Helper";
- Class helperClass = Class.forName(helperClassName);
+ Class helperClass = forName(helperClassName);
- Method insert =
- helperClass.getMethod("insert",
- new Class[] { Any.class, object.getClass() }
- );
+ Method insert = helperClass.getMethod("insert", new Class[] {
+ Any.class, object.getClass() });
insert.invoke(null, new Object[] { into, object });
@@ -385,20 +463,20 @@ public class ObjectCreator
{
try
{
- cdrBufOutput output = new cdrBufOutput();
+ BufferedCdrOutput output = new BufferedCdrOutput();
- String m_exception_id = toIDL(exception.getClass().getName());
+ String m_exception_id = getRepositoryId(exception.getClass());
output.write_string(m_exception_id);
output.write_ulong(exception.minor);
CompletionStatusHelper.write(output, exception.completed);
String name = getDefaultName(m_exception_id);
- universalHolder h = new universalHolder(output);
+ GeneralHolder h = new GeneralHolder(output);
into.insert_Streamable(h);
- recordTypeCode r = new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_except);
r.setId(m_exception_id);
r.setName(name);
into.type(r);
@@ -444,4 +522,69 @@ public class ObjectCreator
if (!ok)
throw new InternalError("Exception wrapping broken");
}
+
+ /**
+ * Find helper for the class with the given name.
+ */
+ public static Class findHelper(String idl)
+ {
+ synchronized (m_helpers)
+ {
+ Class c = (Class) m_helpers.get(idl);
+ if (c != null)
+ return c;
+ try
+ {
+ String helper = toHelperName(idl);
+ c = forName(helper);
+
+ m_helpers.put(idl, c);
+ return c;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Load the class with the given name. This method tries to use the context
+ * class loader first. If this fails, it searches for the suitable class
+ * loader in the caller stack trace. This method is a central point where all
+ * requests to find a class by name are delegated.
+ */
+ public static Class forName(String className) throws ClassNotFoundException
+ {
+ try
+ {
+ return Class.forName(className, true,
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException nex)
+ {
+ /**
+ * Returns the first user defined class loader on the call stack, or
+ * null when no non-null class loader was found.
+ */
+ Class[] ctx = VMStackWalker.getClassContext();
+ for (int i = 0; i < ctx.length; i++)
+ {
+ // Since we live in a class loaded by the bootstrap
+ // class loader, getClassLoader is safe to call without
+ // needing to be wrapped in a privileged action.
+ ClassLoader cl = ctx[i].getClassLoader();
+ try
+ {
+ if (cl != null)
+ return Class.forName(className, true, cl);
+ }
+ catch (ClassNotFoundException nex2)
+ {
+ // Try next.
+ }
+ }
+ }
+ throw new ClassNotFoundException(className);
+ }
} \ No newline at end of file
diff --git a/gnu/CORBA/OctetHolder.java b/gnu/CORBA/OctetHolder.java
index 02fd9a432..06d7538d7 100644
--- a/gnu/CORBA/OctetHolder.java
+++ b/gnu/CORBA/OctetHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -64,7 +64,7 @@ public final class OctetHolder
* The default type code for this holder.
*/
private static final TypeCode t_octet =
- new primitiveTypeCode(TCKind.tk_octet);
+ new PrimitiveTypeCode(TCKind.tk_octet);
/**
* The <code>long</code> (CORBA <code>octet</code>) value,
diff --git a/gnu/CORBA/OrbFocused.java b/gnu/CORBA/OrbFocused.java
new file mode 100644
index 000000000..a0f9993c1
--- /dev/null
+++ b/gnu/CORBA/OrbFocused.java
@@ -0,0 +1,375 @@
+/* OrbFocused.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.Poa.ORB_1_4;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.NO_RESOURCES;
+import org.omg.CORBA.portable.InvokeHandler;
+
+import java.applet.Applet;
+import java.net.ServerSocket;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Random;
+import java.util.StringTokenizer;
+
+/**
+ * This class implements the ORB that uses a single port or the restricted port
+ * range for all its objects. It is required to for use together with various
+ * firewalls that does not allow opening multiple randomly selected ports, as
+ * the defauld CORBA implementation used to do. The firewal must be configured
+ * to allow CORBA to work on one fixed port or (for better performance) on a
+ * small fixed range of ports. This does not restrict the maximal number of the
+ * connected objects as the objects can share the same port.
+ *
+ * The used port or the used port range can be specified via property
+ * gnu.CORBA.ListenerPort. The value of this property is a single port or range
+ * of ports, boundary values (inclusive) being separeted by dash (for instance,
+ * "1245-1250").
+ *
+ * It is possible to instantiate multiple instances of the focused ORBs and
+ * combine them with the ordinary ORBs. If you instantiate several instances of
+ * the focused ORBs on the same host, they used port sets should not overlap.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class OrbFocused
+ extends ORB_1_4
+{
+ /**
+ * The name of the fixed port range property. The presence of this property
+ * indicates that the default focused ORB must be used.
+ */
+ public static final String LISTENER_PORT = "gnu.CORBA.ListenerPort";
+
+ /**
+ * The start of the range of the available ports, inclusive.
+ */
+ int m_ports_from = -1;
+
+ /**
+ * The end of the range of the available ports, inclusive.
+ */
+ int m_ports_to = -1;
+
+ /**
+ * The requests to port are served in parallel threads.
+ */
+ static final int PARALLEL = 0;
+
+ /**
+ * The requests to port are served in the same thread.
+ */
+ static final int SEQUENTIAL = 1;
+
+ /**
+ * The random number generator to get a random port in the valid range.
+ */
+ Random m_random = new Random();
+
+ /**
+ * Parse the "gnu.CORBA.ListenerPort" property and initialize the valid port
+ * set range.
+ */
+ public void setPortRange(String property)
+ {
+ int from, to;
+ try
+ {
+ StringTokenizer st = new StringTokenizer(property, " -");
+ if (st.countTokens() == 1)
+ from = to = Integer.parseInt(st.nextToken());
+ else
+ {
+ from = Integer.parseInt(st.nextToken());
+ to = Integer.parseInt(st.nextToken());
+ m_random = new Random();
+ }
+ setPortRange(from, to);
+ }
+ catch (Exception ex)
+ {
+ throw new BAD_PARAM("Unable to parse port range '" + property + "'");
+ }
+ }
+
+ /**
+ * Set the port range.
+ *
+ * @param from - start of the port range, inclusive.
+ * @param to - end of the port range, inclusive.
+ */
+ public void setPortRange(int from, int to)
+ {
+ if (from < 0 || to < 0 || to < from)
+ throw new BAD_PARAM("Invalid range");
+ m_ports_from = from;
+ m_ports_to = to;
+ }
+
+ /**
+ * Get the port from the previously specified usage range.
+ */
+ int getPortFromRange(int attempt)
+ {
+ if (m_ports_from == m_ports_to)
+ return m_ports_from;
+ else if (m_ports_to - m_ports_from < RANDOM_PORT_ATTEMPTS)
+ return m_ports_from + (attempt % (m_ports_to - m_ports_from + 1));
+ else
+ return m_random.nextInt(m_ports_to - m_ports_from + 1) + m_ports_from;
+ }
+
+ /**
+ * Get the shared port server where the new object can be added. This may
+ * result reusing the existing server or instantiating a new server. If the
+ * new server is instantiated and the ORB is already running, the server is
+ * started.
+ */
+ protected portServer getPortServer(int type)
+ {
+ portServer p;
+
+ int n;
+ if (m_ports_from < m_ports_to)
+ n = RANDOM_PORT_ATTEMPTS;
+ else
+ n = 1;
+
+ Ports: for (int a = 0; a < n; a++)
+ {
+ int port = getPortFromRange(a);
+ for (int i = 0; i < portServers.size(); i++)
+ {
+ p = (portServer) portServers.get(i);
+ if (p.s_port == port)
+ {
+ return (portServer) p;
+ }
+ }
+ // The server is not yet instantiated. Instantiate.
+ try
+ {
+ // Check if the port is ok:
+ ServerSocket s = socketFactory.createServerSocket(port);
+ s.close();
+
+ portServer shared;
+
+ switch (type)
+ {
+ case PARALLEL:
+ shared = new portServer(port);
+ break;
+
+ case SEQUENTIAL:
+ shared = new sharedPortServer(port);
+ break;
+
+ default:
+ throw new InternalError("Invalid server type " + type);
+ }
+
+ portServers.add(shared);
+
+ if (running)
+ shared.start();
+
+ return shared;
+ }
+ catch (Exception ex)
+ {
+ // Port is taken or probably other problems.
+ continue Ports;
+ }
+ }
+ throw new NO_RESOURCES("No free port available at " + m_ports_from + "-"
+ + m_ports_to, Minor.Ports, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Start the ORBs main working cycle (receive invocation - invoke on the local
+ * object - send response - wait for another invocation).
+ *
+ * The method only returns after calling {@link #shutdown(boolean)}.
+ */
+ public void run()
+ {
+ if (m_ports_from < 0 || m_ports_to < 0)
+ throw new BAD_INV_ORDER("For " + getClass().getName() + " "
+ + LISTENER_PORT + " property must be set");
+
+ running = true;
+
+ // Start all port servers. In the current subclass, the portServers
+ // collection must be already filled in.
+ Iterator iter = portServers.iterator();
+
+ while (iter.hasNext())
+ {
+ portServer subserver = (portServer) iter.next();
+
+ if (!subserver.isAlive())
+ {
+ // Reuse the current thread for the last portServer.
+ if (!iter.hasNext())
+ {
+ // Discard the iterator.
+ iter = null;
+ subserver.run();
+ return;
+ }
+ else
+ subserver.start();
+ }
+ }
+ }
+
+ /**
+ * Get free port from the allowed range. This method instantiates the port
+ * server for the returned port.
+ */
+ public int getFreePort()
+ throws BAD_OPERATION
+ {
+ portServer s = getPortServer(PARALLEL);
+ return s.s_port;
+ }
+
+ /**
+ * Connect the given CORBA object to this ORB, explicitly specifying the
+ * object key and the identity of the thread (and port), where the object must
+ * be served. The identity is normally the POA.
+ *
+ * The new port server will be started only if there is no one already running
+ * for the same identity. Otherwise, the task of the existing port server will
+ * be widened, including duty to serve the given object. All objects,
+ * connected to a single identity by this method, will process they requests
+ * subsequently in the same thread. The method is used when the expected
+ * number of the objects is too large to have a single port and thread per
+ * object. This method is used by POAs, having a single thread policy.
+ *
+ * @param object the object, must implement the {@link InvokeHandler})
+ * interface.
+ * @param key the object key, usually used to identify the object from remote
+ * side.
+ * @param port the port, where the object must be connected.
+ *
+ * @throws BAD_PARAM if the object does not implement the
+ * {@link InvokeHandler}).
+ */
+ public void connect_1_thread(org.omg.CORBA.Object object, byte[] key,
+ java.lang.Object identity)
+ {
+ sharedPortServer shared = (sharedPortServer) identities.get(identity);
+ if (shared == null)
+ {
+ shared = (sharedPortServer) getPortServer(SEQUENTIAL);
+ identities.put(identity, shared);
+ if (running)
+ {
+ shared.start();
+ }
+ }
+
+ Connected_objects.cObject ref = connected_objects.add(key, object,
+ shared.s_port, identity);
+ IOR ior = createIOR(ref);
+ prepareObject(object, ior);
+ }
+
+ /**
+ * In this type of ORB, the service is started by {@link #getPortServer}. The
+ * method below is not in use and should return without action.
+ */
+ public void startService(IOR ior)
+ {
+ }
+
+ /**
+ * Set parameters (additionally search for the port range property).
+ */
+ protected void set_parameters(Applet applet, Properties props)
+ {
+ super.set_parameters(applet, props);
+ String lp = applet.getParameter(LISTENER_PORT);
+ if (lp != null)
+ setPortRange(lp);
+ }
+
+ /**
+ * Set parameters (additionally search for the port range property).
+ */
+ protected void set_parameters(String[] args, Properties props)
+ {
+ super.set_parameters(args, props);
+ String lp = null;
+
+ String lpKey = "-" + LISTENER_PORT;
+
+ if (args != null)
+ if (args.length >= 2)
+ {
+ for (int i = 0; i < args.length - 1; i++)
+ if (args[i].equals(lpKey))
+ lp = args[i + 1];
+ }
+
+ if (lp != null)
+ setPortRange(lp);
+
+ }
+
+ /**
+ * Additionally set the port range property, when applicable.
+ */
+ protected void useProperties(Properties props)
+ {
+ super.useProperties(props);
+ String lp = props.getProperty(LISTENER_PORT);
+ if (lp != null)
+ setPortRange(lp);
+ }
+
+}
diff --git a/gnu/CORBA/Functional_ORB.java b/gnu/CORBA/OrbFunctional.java
index 1565b2cf1..dd9dcb831 100644
--- a/gnu/CORBA/Functional_ORB.java
+++ b/gnu/CORBA/OrbFunctional.java
@@ -1,4 +1,4 @@
-/* Functional_ORB.java --
+/* OrbFunctional.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.UnknownExceptionCtxHandler;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.CloseMessage;
import gnu.CORBA.GIOP.ErrorMessage;
import gnu.CORBA.GIOP.MessageHeader;
@@ -48,38 +49,35 @@ import gnu.CORBA.GIOP.RequestHeader;
import gnu.CORBA.NamingService.NameParser;
import gnu.CORBA.NamingService.NamingServiceTransient;
import gnu.CORBA.Poa.gnuForwardRequest;
+import gnu.CORBA.interfaces.SocketFactory;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
-import org.omg.CORBA.DATA_CONVERSION;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_RESOURCES;
import org.omg.CORBA.OBJECT_NOT_EXIST;
-import org.omg.CORBA.Object;
-import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.Request;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.WrongTransaction;
+import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InvokeHandler;
import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.UnknownException;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import java.applet.Applet;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
-
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -87,6 +85,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
+import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
@@ -98,14 +97,15 @@ import java.util.TreeMap;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class Functional_ORB extends Restricted_ORB
+public class OrbFunctional extends OrbRestricted
{
/**
* A server, responsible for listening on requests on some local port. The ORB
* may listen on multiple ports and process the requests in separate threads.
* Normally the server takes one port per object being served.
*/
- class portServer extends Thread
+ protected class portServer
+ extends Thread
{
/**
* The number of the currently running parallel threads.
@@ -133,26 +133,27 @@ public class Functional_ORB extends Restricted_ORB
portServer(int _port)
{
s_port = _port;
- }
-
- /**
- * Enter the serving loop (get request/process it). All portServer normally
- * terminate thy threads when the Functional_ORB.running is set to false.
- */
- public void run()
- {
+ setDaemon(true);
try
{
- service = new ServerSocket(s_port);
+ service = socketFactory.createServerSocket(s_port);
}
catch (IOException ex)
{
- BAD_OPERATION bad =
- new BAD_OPERATION("Unable to open the server socket.");
+ BAD_OPERATION bad = new BAD_OPERATION(
+ "Unable to open the server socket at " + s_port);
+ bad.minor = Minor.Socket;
bad.initCause(ex);
throw bad;
}
+ }
+ /**
+ * Enter the serving loop (get request/process it). All portServer normally
+ * terminate thy threads when the OrbFunctional.running is set to false.
+ */
+ public void run()
+ {
while (running)
{
try
@@ -168,11 +169,11 @@ public class Functional_ORB extends Restricted_ORB
}
catch (Exception iex)
{
- // Wait 5 seconds. Do not terminate the
+ // Wait. Do not terminate the
// service due potentially transient error.
try
{
- Thread.sleep(5000);
+ Thread.sleep(TWAIT_SERVER_ERROR_PAUSE);
}
catch (InterruptedException ex)
{
@@ -183,10 +184,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* Perform a single serving step.
- *
+ *
* @throws java.lang.Exception
*/
- void tick() throws Exception
+ void tick()
+ throws Exception
{
serve(this, service);
}
@@ -222,7 +224,7 @@ public class Functional_ORB extends Restricted_ORB
* serving multiple requests (probably to the different objects) on the same
* thread.
*/
- class sharedPortServer extends portServer
+ protected class sharedPortServer extends portServer
{
/**
* Create a new portServer, serving on specific port.
@@ -249,6 +251,23 @@ public class Functional_ORB extends Restricted_ORB
* for a free port.
*/
public static int DEFAULT_INITIAL_PORT = 1126;
+
+ /**
+ * When trying to open the socket on a random port, start of the interval to
+ * try.
+ */
+ public static int RANDOM_PORT_FROM = 1024;
+
+ /**
+ * When trying to open the socket on a random port, end of the interval to
+ * try.
+ */
+ public static int RANDOM_PORT_TO = 4024;
+
+ /**
+ * The number of attempts to try when opening random port.
+ */
+ public static int RANDOM_PORT_ATTEMPTS = 64;
/**
* The property of port, on that this ORB is listening for requests from
@@ -277,7 +296,7 @@ public class Functional_ORB extends Restricted_ORB
* The string, defining the naming service initial reference.
*/
public static final String NAME_SERVICE = "NameService";
-
+
/**
* The if the client has once opened a socket, it should start sending the
* message header in a given time. Otherwise the server will close the socket.
@@ -301,6 +320,13 @@ public class Functional_ORB extends Restricted_ORB
*/
public static String AFTER_RECEIVING =
"gnu.classpath.CORBA.TOUT_AFTER_RECEIVING";
+
+ /**
+ * The server waits for this duration after the potentially transient error
+ * during its servicing cycle.
+ */
+ public static String SERVER_ERROR_PAUSE =
+ "gnu.classpath.CORBA.SERVER_ERROR_PAUSE";
/**
* The address of the local host.
@@ -313,7 +339,7 @@ public class Functional_ORB extends Restricted_ORB
* This prevents server hang when the client opens the socket, but does not
* send any message, usually due crash on the client side.
*/
- private int TOUT_START_READING_MESSAGE = 20 * 1000;
+ public int TOUT_START_READING_MESSAGE = 20 * 1000;
// (Here and below, we use * to make the meaning of the constant clearler).
@@ -321,14 +347,20 @@ public class Functional_ORB extends Restricted_ORB
* If the client has started to send the request message, the socket time out
* changes to the specified value.
*/
- private int TOUT_WHILE_READING = 2 * 60 * 1000;
+ public int TOUT_WHILE_READING = 2 * 60 * 1000;
/**
* If the message body is received, the time out changes to the specifice
* value. This must be longer, as includes time, required to process the
* received task. We make it 40 minutes.
*/
- private int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
+ public int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
+
+ /**
+ * The server waits for this duration after the potentially transient error
+ * during its servicing cycle.
+ */
+ public int TWAIT_SERVER_ERROR_PAUSE = 5000;
/**
* Some clients tend to submit multiple requests over the same socket. The
@@ -365,7 +397,7 @@ public class Functional_ORB extends Restricted_ORB
/**
* The currently active portServers.
*/
- private ArrayList portServers = new ArrayList();
+ protected ArrayList portServers = new ArrayList();
/**
* The host, on that the name service is expected to be running.
@@ -414,11 +446,16 @@ public class Functional_ORB extends Restricted_ORB
* exceeding this limit, the NO_RESOURCES is thrown back to the client.
*/
private int MAX_RUNNING_THREADS = 256;
+
+ /**
+ * The producer of the client and server sockets for this ORB.
+ */
+ public SocketFactory socketFactory = DefaultSocketFactory.Singleton;
/**
* Create the instance of the Functional ORB.
*/
- public Functional_ORB()
+ public OrbFunctional()
{
try
{
@@ -457,13 +494,14 @@ public class Functional_ORB extends Restricted_ORB
/**
* Get the currently free port, starting from the initially set port and going
* up max 20 steps, then trying to bind into any free address.
- *
+ *
* @return the currently available free port.
- *
+ *
* @throws NO_RESOURCES if the server socked cannot be opened on the local
* host.
*/
- public int getFreePort() throws BAD_OPERATION
+ public int getFreePort()
+ throws BAD_OPERATION
{
ServerSocket s;
int a_port;
@@ -475,7 +513,7 @@ public class Functional_ORB extends Restricted_ORB
{
Integer free = (Integer) freed_ports.getLast();
freed_ports.removeLast();
- s = new ServerSocket(free.intValue());
+ s = socketFactory.createServerSocket(free.intValue());
s.close();
return free.intValue();
}
@@ -491,7 +529,7 @@ public class Functional_ORB extends Restricted_ORB
{
try
{
- s = new ServerSocket(a_port);
+ s = socketFactory.createServerSocket(a_port);
s.close();
Port = a_port + 1;
return a_port;
@@ -502,21 +540,31 @@ public class Functional_ORB extends Restricted_ORB
}
}
- try
- {
- // Try any port.
- s = new ServerSocket();
- a_port = s.getLocalPort();
- s.close();
- return a_port;
- }
- catch (IOException ex)
+ Random rand = new Random();
+ // Try any random port in the interval RANDOM_PORT_FROM.RANDOM_PORT_TO.
+ int range = RANDOM_PORT_TO - RANDOM_PORT_FROM;
+ IOException ioex = null;
+ for (int i = 0; i < RANDOM_PORT_ATTEMPTS; i++)
{
- NO_RESOURCES bad =
- new NO_RESOURCES("Unable to open the server socket.");
- bad.initCause(ex);
- throw bad;
+ try
+ {
+ a_port = RANDOM_PORT_FROM + rand.nextInt(range);
+ s = socketFactory.createServerSocket(a_port);
+ s.close();
+ return a_port;
+ }
+ catch (IOException ex)
+ {
+ // Repeat the loop if this exception has been thrown.
+ ioex = ex;
+ }
}
+
+ NO_RESOURCES bad = new NO_RESOURCES("Unable to open the server socket.");
+ bad.minor = Minor.Ports;
+ if (ioex != null)
+ bad.initCause(ioex);
+ throw bad;
}
/**
@@ -525,7 +573,7 @@ public class Functional_ORB extends Restricted_ORB
* on this port first. It the port is busy, or if more objects are connected,
* the subsequent object will receive a larger port values, skipping
* unavailable ports, if required. The change applies globally.
- *
+ *
* @param a_Port a port, on that the server is listening for requests.
*/
public static void setPort(int a_Port)
@@ -677,9 +725,9 @@ public class Functional_ORB extends Restricted_ORB
if (object instanceof ObjectImpl)
{
Delegate delegate = ((ObjectImpl) object)._get_delegate();
- if (delegate instanceof Simple_delegate)
+ if (delegate instanceof SimpleDelegate)
{
- byte[] key = ((Simple_delegate) delegate).getIor().key;
+ byte[] key = ((SimpleDelegate) delegate).getIor().key;
rmKey = connected_objects.get(key);
}
}
@@ -756,11 +804,7 @@ public class Functional_ORB extends Restricted_ORB
if (!ior.Internet.host.equals(LOCAL_HOST))
return null;
- // Must be the same port.
- if (ior.Internet.port != Port)
- return null;
-
- return find_connected_object(ior.key);
+ return find_connected_object(ior.key, ior.Internet.port);
}
/**
@@ -806,8 +850,8 @@ public class Functional_ORB extends Restricted_ORB
if (forObject instanceof ObjectImpl)
{
Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
- if (delegate instanceof Simple_delegate)
- return ((Simple_delegate) delegate).getIor().toStringifiedReference();
+ if (delegate instanceof SimpleDelegate)
+ return ((SimpleDelegate) delegate).getIor().toStringifiedReference();
}
// Handle the case when the object is local.
@@ -899,7 +943,7 @@ public class Functional_ORB extends Restricted_ORB
}
else
subserver = (portServer) identities.get(obj.identity);
-
+
if (!subserver.isAlive())
{
// Reuse the current thread for the last portServer.
@@ -915,6 +959,30 @@ public class Functional_ORB extends Restricted_ORB
}
}
}
+
+ /**
+ * Start the server in a new thread, if not already running. This method is
+ * used to ensure that the objects being transfered will be served from the
+ * remote side, if required. If the ORB is started using this method, it
+ * starts as a daemon thread.
+ */
+ public void ensureRunning()
+ {
+ final OrbFunctional THIS = this;
+
+ if (!running)
+ {
+ Thread t = new Thread()
+ {
+ public void run()
+ {
+ THIS.run();
+ }
+ };
+ t.setDaemon(true);
+ t.start();
+ }
+ }
/**
* Shutdown the ORB server.
@@ -961,21 +1029,22 @@ public class Functional_ORB extends Restricted_ORB
org.omg.CORBA.Object object = find_local_object(ior);
if (object == null)
{
- ObjectImpl impl = stubFinder.search(this, ior);
+ ObjectImpl impl = StubLocator.search(this, ior);
try
{
if (impl._get_delegate() == null)
- impl._set_delegate(new IOR_Delegate(this, ior));
+ impl._set_delegate(new IorDelegate(this, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception
// in response to the attempt to get the unset delegate.
- impl._set_delegate(new IOR_Delegate(this, ior));
+ impl._set_delegate(new IorDelegate(this, ior));
}
object = impl;
- connected_objects.add(ior.key, impl, ior.Internet.port, null);
+ // TODO remove commented out code below.
+ // connected_objects.add(ior.key, impl, ior.Internet.port, null);
}
return object;
}
@@ -995,7 +1064,7 @@ public class Functional_ORB extends Restricted_ORB
ior.Internet.port = ns_port;
ior.key = NamingServiceTransient.getDefaultKey();
- IOR_contructed_object iorc = new IOR_contructed_object(this, ior);
+ IorObject iorc = new IorObject(this, ior);
NamingContextExt namer = NamingContextExtHelper.narrow(iorc);
initial_references.put(NAME_SERVICE, namer);
return namer;
@@ -1004,15 +1073,21 @@ public class Functional_ORB extends Restricted_ORB
/**
* Find and return the object, that must be previously connected to this ORB.
* Return null if no such object is available.
- *
+ *
* @param key the object key.
- *
+ * @param port the port where the object is connected.
+ *
* @return the connected object, null if none.
*/
- protected org.omg.CORBA.Object find_connected_object(byte[] key)
+ protected org.omg.CORBA.Object find_connected_object(byte[] key, int port)
{
Connected_objects.cObject ref = connected_objects.get(key);
- return ref == null ? null : ref.object;
+ if (ref == null)
+ return null;
+ if (port >= 0 && ref.port != port)
+ return null;
+ else
+ return ref.object;
}
/**
@@ -1156,7 +1231,7 @@ public class Functional_ORB extends Restricted_ORB
* @throws BAD_PARAM if the object does not implement the
* {@link InvokeHandler}).
*/
- private void prepareObject(org.omg.CORBA.Object object, IOR ior)
+ protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
throws BAD_PARAM
{
/*
@@ -1172,12 +1247,12 @@ public class Functional_ORB extends Restricted_ORB
try
{
if (impl._get_delegate() == null)
- impl._set_delegate(new Simple_delegate(this, ior));
+ impl._set_delegate(new SimpleDelegate(this, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception.
- impl._set_delegate(new Simple_delegate(this, ior));
+ impl._set_delegate(new SimpleDelegate(this, ior));
}
}
}
@@ -1197,7 +1272,7 @@ public class Functional_ORB extends Restricted_ORB
*/
private void respond_to_client(OutputStream net_out,
MessageHeader msh_request, RequestHeader rh_request,
- bufferedResponseHandler handler, SystemException sysEx
+ ResponseHandlerImpl handler, SystemException sysEx
) throws IOException
{
// Set the reply header properties.
@@ -1211,8 +1286,8 @@ public class Functional_ORB extends Restricted_ORB
reply.reply_status = ReplyHeader.NO_EXCEPTION;
reply.request_id = rh_request.request_id;
- cdrBufOutput out =
- new cdrBufOutput(50 + handler.getBuffer().buffer.size());
+ BufferedCdrOutput out =
+ new BufferedCdrOutput(50 + handler.getBuffer().buffer.size());
out.setOrb(this);
out.setOffset(msh_request.getHeaderSize());
@@ -1256,7 +1331,7 @@ public class Functional_ORB extends Restricted_ORB
rh_forward.request_id = rh_request.request_id;
// The forwarding code is either LOCATION_FORWARD or LOCATION_FORWARD_PERM.
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
out.setOrb(this);
out.setOffset(msh_forward.getHeaderSize());
@@ -1324,11 +1399,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* A single servicing step, when the client socket is alrady open.
- *
+ *
* Normally, each task matches a single remote invocation. However under
* frequent tandem submissions the same task may span over several
* invocations.
- *
+ *
* @param service the opened client socket.
* @param no_resources if true, the "NO RESOURCES" exception is thrown to the
* client.
@@ -1337,8 +1412,7 @@ public class Functional_ORB extends Restricted_ORB
{
try
{
- Serving:
- while (true)
+ Serving: while (true)
{
InputStream in = service.getInputStream();
service.setSoTimeout(TOUT_START_READING_MESSAGE);
@@ -1358,9 +1432,7 @@ public class Functional_ORB extends Restricted_ORB
if (max_version != null)
{
if (!msh_request.version.until_inclusive(max_version.major,
- max_version.minor
- )
- )
+ max_version.minor))
{
OutputStream out = service.getOutputStream();
new ErrorMessage(max_version).write(out);
@@ -1368,25 +1440,14 @@ public class Functional_ORB extends Restricted_ORB
}
}
- byte[] r = new byte[ msh_request.message_size ];
-
- int n = 0;
-
- service.setSoTimeout(TOUT_WHILE_READING);
-
- reading:
- while (n < r.length)
- {
- n += in.read(r, n, r.length - n);
- }
-
- service.setSoTimeout(TOUT_AFTER_RECEIVING);
+ byte[] r = msh_request.readMessage(in, service, TOUT_WHILE_READING,
+ TOUT_AFTER_RECEIVING);
if (msh_request.message_type == MessageHeader.REQUEST)
{
RequestHeader rh_request;
- cdrBufInput cin = new cdrBufInput(r);
+ BufferredCdrInput cin = new BufferredCdrInput(r);
cin.setOrb(this);
cin.setVersion(msh_request.version);
cin.setOffset(msh_request.getHeaderSize());
@@ -1406,8 +1467,8 @@ public class Functional_ORB extends Restricted_ORB
// find the target object.
}
- InvokeHandler target =
- (InvokeHandler) find_connected_object(rh_request.object_key);
+ InvokeHandler target = (InvokeHandler) find_connected_object(
+ rh_request.object_key, -1);
// Prepare the reply header. This must be done in advance,
// as the size must be known for handler to set alignments
@@ -1415,17 +1476,19 @@ public class Functional_ORB extends Restricted_ORB
ReplyHeader rh_reply = msh_request.create_reply_header();
// TODO log errors about not existing objects and methods.
- bufferedResponseHandler handler =
- new bufferedResponseHandler(this, msh_request, rh_reply,
- rh_request
- );
+ ResponseHandlerImpl handler = new ResponseHandlerImpl(
+ this, msh_request, rh_reply, rh_request);
SystemException sysEx = null;
try
{
if (no_resources)
- throw new NO_RESOURCES();
+ {
+ NO_RESOURCES no = new NO_RESOURCES("Too many parallel calls");
+ no.minor = Minor.Threads;
+ throw no;
+ }
if (target == null)
throw new OBJECT_NOT_EXIST();
target._invoke(rh_request.operation, cin, handler);
@@ -1442,24 +1505,45 @@ public class Functional_ORB extends Restricted_ORB
continue Serving;
}
}
+ catch (UnknownException uex)
+ {
+ sysEx = new UNKNOWN("Unknown", 2,
+ CompletionStatus.COMPLETED_MAYBE);
+ sysEx.initCause(uex.originalEx);
+
+ org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
+
+ rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
+ rh_reply.service_context, uex.originalEx, ech);
+
+ ObjectCreator.writeSystemException(ech, sysEx);
+ }
catch (SystemException ex)
{
sysEx = ex;
-
- org.omg.CORBA.portable.OutputStream ech =
- handler.createExceptionReply();
+
+ org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
+
+ rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
+ rh_reply.service_context, ex, ech);
+
ObjectCreator.writeSystemException(ech, ex);
}
catch (Exception except)
{
+ // This should never happen under normal operation and
+ // can only indicate errors in user object implementation.
+ // We inform the user.
except.printStackTrace();
- sysEx =
- new UNKNOWN("Unknown", 2,
- CompletionStatus.COMPLETED_MAYBE
- );
- org.omg.CORBA.portable.OutputStream ech =
- handler.createExceptionReply();
+ sysEx = new UNKNOWN("Unknown", 2,
+ CompletionStatus.COMPLETED_MAYBE);
+ sysEx.initCause(except);
+
+ org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
+
+ rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
+ rh_reply.service_context, except, ech);
ObjectCreator.writeSystemException(ech, sysEx);
}
@@ -1469,21 +1553,17 @@ public class Functional_ORB extends Restricted_ORB
{
OutputStream sou = service.getOutputStream();
respond_to_client(sou, msh_request, rh_request, handler,
- sysEx
- );
+ sysEx);
}
}
- else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION ||
- msh_request.message_type == MessageHeader.MESSAGE_ERROR
- )
+ else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION
+ || msh_request.message_type == MessageHeader.MESSAGE_ERROR)
{
CloseMessage.close(service.getOutputStream());
service.close();
return;
}
- ;
- // TODO log error: "Not a request message."
if (service != null && !service.isClosed())
// Wait for the subsequent invocations on the
@@ -1505,8 +1585,12 @@ public class Functional_ORB extends Restricted_ORB
return;
}
}
-
- private void useProperties(Properties props)
+
+ /**
+ * Set the ORB parameters from the properties that were accumulated
+ * from several locations.
+ */
+ protected void useProperties(Properties props)
{
if (props != null)
{
@@ -1527,6 +1611,9 @@ public class Functional_ORB extends Restricted_ORB
if (props.containsKey(AFTER_RECEIVING))
TOUT_AFTER_RECEIVING =
Integer.parseInt(props.getProperty(AFTER_RECEIVING));
+ if (props.containsKey(SERVER_ERROR_PAUSE))
+ TWAIT_SERVER_ERROR_PAUSE =
+ Integer.parseInt(props.getProperty(SERVER_ERROR_PAUSE));
}
catch (NumberFormatException ex)
{
@@ -1535,7 +1622,25 @@ public class Functional_ORB extends Restricted_ORB
"'"
);
}
-
+
+ if (props.containsKey(SocketFactory.PROPERTY))
+ {
+ String factory = null;
+ try
+ {
+ factory = props.getProperty(SocketFactory.PROPERTY);
+ if (factory!=null)
+ socketFactory = (SocketFactory)
+ ObjectCreator.forName(factory).newInstance();
+ }
+ catch (Exception ex)
+ {
+ BAD_PARAM p = new BAD_PARAM("Bad socket factory "+factory);
+ p.initCause(ex);
+ throw p;
+ }
+ }
+
Enumeration en = props.elements();
while (en.hasMoreElements())
{
diff --git a/gnu/CORBA/Restricted_ORB.java b/gnu/CORBA/OrbRestricted.java
index 247cd205c..783ced080 100644
--- a/gnu/CORBA/Restricted_ORB.java
+++ b/gnu/CORBA/OrbRestricted.java
@@ -38,7 +38,11 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.typecodes.AliasTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
@@ -82,12 +86,12 @@ import java.util.Properties;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
+public class OrbRestricted extends org.omg.CORBA_2_3.ORB
{
/**
* The singleton instance of this ORB.
*/
- public static final ORB Singleton = new Restricted_ORB();
+ public static final ORB Singleton = new OrbRestricted();
/**
* The cumulated listener for all IOR interceptors. Interceptors are used by
@@ -126,14 +130,14 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
* Create a new instance of the RestrictedORB. This is used in derived classes
* only.
*/
- protected Restricted_ORB()
+ protected OrbRestricted()
{
}
/** {@inheritDoc} */
public TypeCode create_alias_tc(String id, String name, TypeCode typecode)
{
- return new aliasTypeCode(typecode, id, name);
+ return new AliasTypeCode(typecode, id, name);
}
/** {@inheritDoc} */
@@ -147,8 +151,8 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_array_tc(int length, TypeCode element_type)
{
- primitiveArrayTypeCode p =
- new primitiveArrayTypeCode(TCKind.tk_array, element_type);
+ ArrayTypeCode p =
+ new ArrayTypeCode(TCKind.tk_array, element_type);
p.setLength(length);
return p;
}
@@ -162,7 +166,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_enum_tc(String id, String name, String[] values)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_enum);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_enum);
for (int i = 0; i < values.length; i++)
{
r.field().name = values [ i ];
@@ -191,7 +195,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
StructMember[] members
)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_except);
r.setId(id);
r.setName(name);
@@ -229,7 +233,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public OutputStream create_output_stream()
{
- cdrBufOutput stream = new cdrBufOutput();
+ BufferedCdrOutput stream = new BufferedCdrOutput();
stream.setOrb(this);
return stream;
}
@@ -237,8 +241,8 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_sequence_tc(int bound, TypeCode element_type)
{
- primitiveArrayTypeCode p =
- new primitiveArrayTypeCode(TCKind.tk_sequence, element_type);
+ ArrayTypeCode p =
+ new ArrayTypeCode(TCKind.tk_sequence, element_type);
p.setLength(bound);
return p;
}
@@ -246,7 +250,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_string_tc(int bound)
{
- stringTypeCode p = new stringTypeCode(TCKind.tk_string);
+ StringTypeCode p = new StringTypeCode(TCKind.tk_string);
p.setLength(bound);
return p;
}
@@ -256,7 +260,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
StructMember[] members
)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_struct);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_struct);
r.setId(id);
r.setName(name);
@@ -273,7 +277,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
TypeCode discriminator_type, UnionMember[] members
)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_union);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_union);
r.setId(id);
r.setName(name);
r.setDiscriminator_type(discriminator_type);
@@ -290,7 +294,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_wstring_tc(int bound)
{
- stringTypeCode p = new stringTypeCode(TCKind.tk_wstring);
+ StringTypeCode p = new StringTypeCode(TCKind.tk_wstring);
p.setLength(bound);
return p;
}
@@ -300,7 +304,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
{
try
{
- return typeNamer.getPrimitveTC(tcKind);
+ return TypeKindNamer.getPrimitveTC(tcKind);
}
catch (BadKind ex)
{
diff --git a/gnu/CORBA/Poa/activeObjectMap.java b/gnu/CORBA/Poa/AOM.java
index c6ba6512f..db98043d0 100644
--- a/gnu/CORBA/Poa/activeObjectMap.java
+++ b/gnu/CORBA/Poa/AOM.java
@@ -1,4 +1,4 @@
-/* activeObjectMap.java --
+/* AOM.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,7 +57,7 @@ import java.util.TreeMap;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class activeObjectMap
+public class AOM
{
/**
* The reference data about the object, placed on the AOM.
@@ -287,7 +287,7 @@ public class activeObjectMap
* and object.
* @param port the port that this object would take.
*/
- public Obj add(servantDelegate delegate)
+ public Obj add(ServantDelegateImpl delegate)
{
Obj rec =
new Obj(delegate.object, delegate.servant_id, delegate.servant,
diff --git a/gnu/CORBA/Poa/vPolicy.java b/gnu/CORBA/Poa/AccessiblePolicy.java
index 9e45b56d7..44ebaf453 100644
--- a/gnu/CORBA/Poa/vPolicy.java
+++ b/gnu/CORBA/Poa/AccessiblePolicy.java
@@ -1,4 +1,4 @@
-/* vPolicy.java --
+/* AccessiblePolicy.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import org.omg.CORBA.Policy;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public interface vPolicy
+public interface AccessiblePolicy
extends Policy
{
/**
diff --git a/gnu/CORBA/Poa/dynImpHandler.java b/gnu/CORBA/Poa/DynamicImpHandler.java
index 1cc3e131c..903f8bfbb 100644
--- a/gnu/CORBA/Poa/dynImpHandler.java
+++ b/gnu/CORBA/Poa/DynamicImpHandler.java
@@ -1,4 +1,4 @@
-/* dynImpHandler.java --
+/* DynamicImpHandler.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,7 +53,7 @@ import org.omg.PortableServer.DynamicImplementation;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class dynImpHandler
+public class DynamicImpHandler
implements InvokeHandler
{
/**
@@ -66,7 +66,7 @@ public class dynImpHandler
* Create a new instance, wrapping some dyn implementation.
* @param _servant
*/
- public dynImpHandler(DynamicImplementation _servant)
+ public DynamicImpHandler(DynamicImplementation _servant)
{
servant = _servant;
}
diff --git a/gnu/CORBA/Poa/ForwardedServant.java b/gnu/CORBA/Poa/ForwardedServant.java
index 2df378df6..b1d5eaf8c 100644
--- a/gnu/CORBA/Poa/ForwardedServant.java
+++ b/gnu/CORBA/Poa/ForwardedServant.java
@@ -39,8 +39,9 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.IOR;
-import gnu.CORBA.IOR_Delegate;
-import gnu.CORBA.IOR_contructed_object;
+import gnu.CORBA.IorDelegate;
+import gnu.CORBA.IorObject;
+import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
@@ -101,9 +102,9 @@ public class ForwardedServant
ObjectImpl fto = (ObjectImpl) a_ref;
// Check maybe the remote side forwarded back to our local object.
- if (fto instanceof IOR_contructed_object)
+ if (fto instanceof IorObject)
{
- IOR_contructed_object iref = (IOR_contructed_object) fto;
+ IorObject iref = (IorObject) fto;
// Check maybe the IOR is local.
ORB t_orb = iref._orb();
@@ -111,13 +112,13 @@ public class ForwardedServant
{
ORB_1_4 orb = (ORB_1_4) t_orb;
Delegate d = iref._get_delegate();
- if (d instanceof IOR_Delegate)
+ if (d instanceof IorDelegate)
{
- IOR_Delegate ird = (IOR_Delegate) iref._get_delegate();
+ IorDelegate ird = (IorDelegate) iref._get_delegate();
IOR ior = ird.getIor();
if (orb.LOCAL_HOST.equalsIgnoreCase(ior.Internet.host))
{
- activeObjectMap.Obj rx = orb.rootPOA.findIorKey(ior.key);
+ AOM.Obj rx = orb.rootPOA.findIorKey(ior.key);
if (rx != null)
{
if (rx.object == fto ||
@@ -175,6 +176,7 @@ public class ForwardedServant
catch (IOException io_ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Forwarding;
m.initCause(io_ex);
throw m;
}
diff --git a/gnu/CORBA/Poa/LocalDelegate.java b/gnu/CORBA/Poa/LocalDelegate.java
index 7af3369d2..72dd8f0cf 100644
--- a/gnu/CORBA/Poa/LocalDelegate.java
+++ b/gnu/CORBA/Poa/LocalDelegate.java
@@ -38,8 +38,10 @@ exception statement from your version. */
package gnu.CORBA.Poa;
-import gnu.CORBA.CDR.cdrOutput;
-import gnu.CORBA.streamRequest;
+import gnu.CORBA.CDR.AbstractCdrOutput;
+import gnu.CORBA.IOR;
+import gnu.CORBA.IorProvider;
+import gnu.CORBA.StreamBasedRequest;
import org.omg.CORBA.ARG_INOUT;
import org.omg.CORBA.Bounds;
@@ -68,17 +70,22 @@ import java.util.Arrays;
* A local delegate, transferring all object requests to the locally available
* servant. This class is involved in handling the method invocations on the
* local object, obtained by POA.create_reference_with_id.
- *
+ *
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
+public class LocalDelegate
+ extends org.omg.CORBA_2_3.portable.Delegate
+ implements IorProvider
{
/**
* The same servant as an invocation handler.
*/
gnuServantObject object;
+
String operation;
- final gnuPOA poa;
+
+ public final gnuPOA poa;
+
final byte[] Id;
/**
@@ -91,6 +98,14 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
poa = a_poa;
Id = an_id;
}
+
+ /**
+ * Get the IOR of the connected object.
+ */
+ public IOR getIor()
+ {
+ return object.getIor();
+ }
public Request request(org.omg.CORBA.Object target, String method)
{
@@ -107,8 +122,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
}
public boolean is_equivalent(org.omg.CORBA.Object target,
- org.omg.CORBA.Object other
- )
+ org.omg.CORBA.Object other)
{
if (target == other)
return true;
@@ -157,9 +171,9 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Check if this object could be named by the given repository id.
- *
+ *
* @param idl_id the repository id to check.
- *
+ *
* @return true if it is one of the possible repository ids of this object.
*/
public boolean is_a(org.omg.CORBA.Object a_servant, String idl_id)
@@ -167,7 +181,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
String[] maybe = object._ids();
for (int i = 0; i < maybe.length; i++)
{
- if (maybe [ i ].equals(idl_id))
+ if (maybe[i].equals(idl_id))
return true;
}
return false;
@@ -186,8 +200,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String method, NVList parameters, NamedValue returns,
- ExceptionList exceptions, ContextList ctx_list
- )
+ ExceptionList exceptions, ContextList ctx_list)
{
operation = method;
@@ -204,8 +217,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
* Create request for using with DII.
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
- String method, NVList parameters, NamedValue returns
- )
+ String method, NVList parameters, NamedValue returns)
{
operation = method;
@@ -226,23 +238,20 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Create a request to invoke the method of this CORBA object.
- *
+ *
* @param operation the name of the method to invoke.
* @param response_expected specifies if this is one way message or the
* response to the message is expected.
- *
+ *
* @return the stream where the method arguments should be written.
*/
public org.omg.CORBA.portable.OutputStream request(
- org.omg.CORBA.Object target,
- String method,
- boolean response_expected
- )
+ org.omg.CORBA.Object target, String method, boolean response_expected)
{
operation = method;
// Check if the object is not explicitly deactivated.
- activeObjectMap.Obj e = poa.aom.get(Id);
+ AOM.Obj e = poa.aom.get(Id);
if (e != null && e.isDeactiveted())
{
if (poa.servant_activator != null || poa.servant_locator != null)
@@ -280,7 +289,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Make an invocation.
- *
+ *
* @param target not in use.
* @param output the stream request that should be returned by
* {@link #m_request} in this method.
@@ -292,31 +301,29 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
{
try
{
- streamRequest sr = (streamRequest) output;
+ StreamBasedRequest sr = (StreamBasedRequest) output;
LocalRequest lr = (LocalRequest) sr.request;
- InvokeHandler handler =
- lr.object.getHandler(lr.operation(), lr.cookie, false);
+ InvokeHandler handler = lr.object.getHandler(lr.operation(), lr.cookie,
+ false);
- if (handler instanceof dynImpHandler)
+ if (handler instanceof DynamicImpHandler)
{
// The local request known how to handle it, but the different
// method must be called.
lr.invoke();
// The encapsulation will inherit orb, endian, charsets, etc.
- cdrOutput buf = sr.createEncapsulation();
+ AbstractCdrOutput buf = sr.createEncapsulation();
// Write all request parameters to the buffer stream.
if (lr.env().exception() != null)
{
try
{
- UnknownUserException uex =
- (UnknownUserException) lr.env().exception();
+ UnknownUserException uex = (UnknownUserException) lr.env().exception();
throw new ApplicationException(uex.except.type().id(),
- uex.except.create_input_stream()
- );
+ uex.except.create_input_stream());
}
catch (BadKind ex)
{
@@ -334,9 +341,8 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
for (int i = 0; i < lr.arguments().count(); i++)
{
a = lr.arguments().item(i);
- if (a.flags() == ARG_INOUT.value ||
- a.flags() == ARG_INOUT.value
- )
+ if (a.flags() == ARG_INOUT.value
+ || a.flags() == ARG_INOUT.value)
{
a.value().write_value(buf);
}
@@ -362,10 +368,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
try
{
return ((ObjectImpl) f.forward_reference)._invoke(f.forward_reference._request(
- operation,
- true
- )
- );
+ operation, true));
}
catch (RemarshalException e)
{
diff --git a/gnu/CORBA/Poa/LocalRequest.java b/gnu/CORBA/Poa/LocalRequest.java
index a727499fc..a2c0bb106 100644
--- a/gnu/CORBA/Poa/LocalRequest.java
+++ b/gnu/CORBA/Poa/LocalRequest.java
@@ -38,19 +38,19 @@ exception statement from your version. */
package gnu.CORBA.Poa;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.v1_2.ReplyHeader;
import gnu.CORBA.GIOP.v1_2.RequestHeader;
import gnu.CORBA.Interceptor.gnuClientRequestInfo;
import gnu.CORBA.Interceptor.gnuServerRequestInfo;
+import gnu.CORBA.typecodes.RecordTypeCode;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Unexpected;
import gnu.CORBA.gnuAny;
import gnu.CORBA.gnuRequest;
-import gnu.CORBA.recordTypeCode;
-import gnu.CORBA.streamReadyHolder;
-import gnu.CORBA.streamRequest;
+import gnu.CORBA.StreamHolder;
+import gnu.CORBA.StreamBasedRequest;
import org.omg.CORBA.ARG_OUT;
import org.omg.CORBA.Any;
@@ -115,7 +115,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
/**
* The buffer to write into.
*/
- cdrBufOutput buffer;
+ BufferedCdrOutput buffer;
/**
* The responsible POA.
@@ -252,7 +252,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
handler = object.getHandler(operation(), cookie, false);
}
- cdrBufOutput request_part = new cdrBufOutput();
+ BufferedCdrOutput request_part = new BufferedCdrOutput();
request_part.setOrb(orb());
@@ -288,7 +288,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
request_part.create_input_stream();
// Ensure the servant (handler) has a delegate set.
- servantDelegate sd = null;
+ ServantDelegateImpl sd = null;
Delegate d = null;
@@ -300,19 +300,19 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
// In some cases exception is thrown if the delegate is not set.
}
- if (d instanceof servantDelegate)
+ if (d instanceof ServantDelegateImpl)
{
// If the delegate is already set, try to reuse the existing
// instance.
- sd = (servantDelegate) d;
+ sd = (ServantDelegateImpl) d;
if (sd.object != object)
{
- sd = new servantDelegate(servant, poa, Id);
+ sd = new ServantDelegateImpl(servant, poa, Id);
}
}
else
{
- sd = new servantDelegate(servant, poa, Id);
+ sd = new ServantDelegateImpl(servant, poa, Id);
}
servant._set_delegate(sd);
@@ -368,13 +368,13 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
// Failed due any reason, insert without
// helper.
- a.insert_Streamable(new streamReadyHolder(
+ a.insert_Streamable(new StreamHolder(
buf.create_input_stream()
)
);
- recordTypeCode r =
- new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r =
+ new RecordTypeCode(TCKind.tk_except);
r.setId(uex_idl);
r.setName(ObjectCreator.getDefaultName(uex_idl));
}
@@ -531,9 +531,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
InvokeHandler handler = object.getHandler(operation(), cookie, false);
- if (handler instanceof dynImpHandler)
+ if (handler instanceof DynamicImpHandler)
{
- DynamicImplementation dyn = ((dynImpHandler) handler).servant;
+ DynamicImplementation dyn = ((DynamicImpHandler) handler).servant;
if (serverRequest == null)
{
serverRequest = new LocalServerRequest(this);
@@ -589,7 +589,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
// Prepare an Any that will hold the exception.
gnuAny exc = new gnuAny();
- exc.insert_Streamable(new streamReadyHolder(input));
+ exc.insert_Streamable(new StreamHolder(input));
UnknownUserException unuex = new UnknownUserException(exc);
m_environment.exception(unuex);
@@ -637,7 +637,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
*
* @return the CDR output stream, containing the written output.
*/
- cdrBufOutput getBuffer()
+ BufferedCdrOutput getBuffer()
{
return buffer;
}
@@ -656,7 +656,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
*/
private void prepareStream()
{
- buffer = new cdrBufOutput();
+ buffer = new BufferedCdrOutput();
buffer.setOrb(orb());
}
@@ -664,9 +664,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
* Get the parameter stream, where the invocation arguments should be written
* if they are written into the stream directly.
*/
- public streamRequest getParameterStream()
+ public StreamBasedRequest getParameterStream()
{
- m_parameter_buffer = new streamRequest();
+ m_parameter_buffer = new StreamBasedRequest();
m_parameter_buffer.request = this;
m_parameter_buffer.setOrb(poa.orb());
return m_parameter_buffer;
diff --git a/gnu/CORBA/Poa/ORB_1_4.java b/gnu/CORBA/Poa/ORB_1_4.java
index 356029a89..b2451b337 100644
--- a/gnu/CORBA/Poa/ORB_1_4.java
+++ b/gnu/CORBA/Poa/ORB_1_4.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.Poa;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.Connected_objects.cObject;
import gnu.CORBA.DynAn.gnuDynAnyFactory;
@@ -53,11 +53,14 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.ORB;
import org.omg.CORBA.Policy;
import org.omg.CORBA.PolicyError;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.PortableInterceptor.PolicyFactory;
import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
import org.omg.PortableServer.POAPackage.InvalidPolicy;
import java.applet.Applet;
@@ -69,7 +72,7 @@ import java.util.Properties;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class ORB_1_4
- extends Functional_ORB
+ extends OrbFunctional
{
/**
* The root POA.
@@ -100,7 +103,7 @@ public class ORB_1_4
super();
try
{
- rootPOA = new gnuPOA(null, "RootPOA", null, policySets.rootPoa(), this);
+ rootPOA = new gnuPOA(null, "RootPOA", null, StandardPolicies.rootPoa(), this);
}
catch (InvalidPolicy ex)
{
@@ -130,7 +133,7 @@ public class ORB_1_4
{
try
{
- activeObjectMap.Obj exists = rootPOA.findObject(forObject);
+ AOM.Obj exists = rootPOA.findObject(forObject);
if (exists == null)
throw new OBJECT_NOT_EXIST(forObject == null ? "null"
: forObject.toString());
@@ -201,7 +204,7 @@ public class ORB_1_4
IOR ior = super.createIOR(ref);
if (iIor != null)
{
- activeObjectMap.Obj obj = rootPOA.findIorKey(ior.key);
+ AOM.Obj obj = rootPOA.findIorKey(ior.key);
POA poa;
@@ -252,5 +255,39 @@ public class ORB_1_4
super.set_parameters(para, props);
registerInterceptors(props, para);
}
+
+ /**
+ * This method is called by RMI-IIOP {@link javax.rmi.Tie#orb(ORB)}, passing
+ * <code>this</code> as parameter. The ORB will try to connect that tie as
+ * one of its objects, if it is not already connected. If the wrapper is an
+ * instance of Servant this method also activates the root poa (if not already
+ * active).
+ */
+ public void set_delegate(java.lang.Object wrapper)
+ {
+ if (wrapper instanceof org.omg.CORBA.Object)
+ {
+ org.omg.CORBA.Object object = (org.omg.CORBA.Object) wrapper;
+ if (connected_objects.getKey(object) == null)
+ connect(object);
+ }
+ else if (wrapper instanceof Servant)
+ {
+ Servant s = (Servant) wrapper;
+ if (rootPOA.findServant(s) == null)
+ try
+ {
+ rootPOA.servant_to_reference(s);
+ if (rootPOA.the_POAManager().get_state().value() == State._HOLDING)
+ rootPOA.the_POAManager().activate();
+ }
+ catch (Exception e)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("Unable to connect "
+ + wrapper + " to " + this);
+ throw bad;
+ }
+ }
+ }
}
diff --git a/gnu/CORBA/Poa/servantDelegate.java b/gnu/CORBA/Poa/ServantDelegateImpl.java
index f59c01c6b..e65214d4a 100644
--- a/gnu/CORBA/Poa/servantDelegate.java
+++ b/gnu/CORBA/Poa/ServantDelegateImpl.java
@@ -1,4 +1,4 @@
-/* servantDelegate.java --
+/* ServantDelegateImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ import org.omg.PortableServer.portable.Delegate;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class servantDelegate
+public class ServantDelegateImpl
implements Delegate
{
/**
@@ -93,7 +93,7 @@ public class servantDelegate
* @param a_servant the servant.
* @param a_servant_id the servant id.
*/
- public servantDelegate(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id)
+ public ServantDelegateImpl(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id)
{
poa = a_poa;
servant = a_servant;
diff --git a/gnu/CORBA/Poa/policySets.java b/gnu/CORBA/Poa/StandardPolicies.java
index eb688467a..b2edc4056 100644
--- a/gnu/CORBA/Poa/policySets.java
+++ b/gnu/CORBA/Poa/StandardPolicies.java
@@ -1,4 +1,4 @@
-/* policySets.java --
+/* StandardPolicies.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,14 +56,14 @@ import java.util.ArrayList;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class policySets
+public class StandardPolicies
{
/**
* The default policy set, as defined in OMG specs. This is also
* the policy set for the root POA.
*/
- private static final vPolicy[] rootPOASet =
- new vPolicy[]
+ private static final AccessiblePolicy[] rootPOASet =
+ new AccessiblePolicy[]
{
new gnuThreadPolicy(ThreadPolicyValue.ORB_CTRL_MODEL),
new gnuLifespanPolicy(LifespanPolicyValue.TRANSIENT),
diff --git a/gnu/CORBA/Poa/gnuAdapterActivator.java b/gnu/CORBA/Poa/gnuAdapterActivator.java
index 3019a2ae9..17d5a0f9e 100644
--- a/gnu/CORBA/Poa/gnuAdapterActivator.java
+++ b/gnu/CORBA/Poa/gnuAdapterActivator.java
@@ -69,7 +69,7 @@ public class gnuAdapterActivator
{
try
{
- POA n = parent.create_POA(child_name, null, policySets.rootPoa());
+ POA n = parent.create_POA(child_name, null, StandardPolicies.rootPoa());
n.the_POAManager().activate();
}
catch (Exception ex)
diff --git a/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java b/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java
index a404486ce..91531909a 100644
--- a/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java
+++ b/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.IdAssignmentPolicyValue;
*/
public class gnuIdAssignmentPolicy
extends _PolicyImplBase
- implements IdAssignmentPolicy, vPolicy
+ implements IdAssignmentPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java b/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java
index 2abd1f484..0b5fa1420 100644
--- a/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java
+++ b/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.IdUniquenessPolicyValue;
*/
public class gnuIdUniquenessPolicy
extends _PolicyImplBase
- implements IdUniquenessPolicy, vPolicy
+ implements IdUniquenessPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java b/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java
index 1e539a2c4..f1721beef 100644
--- a/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java
+++ b/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ImplicitActivationPolicyValue;
*/
public class gnuImplicitActivationPolicy
extends _PolicyImplBase
- implements ImplicitActivationPolicy, vPolicy
+ implements ImplicitActivationPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/Poa/gnuLifespanPolicy.java b/gnu/CORBA/Poa/gnuLifespanPolicy.java
index 97b3f2d7a..f26596cd9 100644
--- a/gnu/CORBA/Poa/gnuLifespanPolicy.java
+++ b/gnu/CORBA/Poa/gnuLifespanPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.LifespanPolicyValue;
*/
public class gnuLifespanPolicy
extends _PolicyImplBase
- implements LifespanPolicy, vPolicy
+ implements LifespanPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/Poa/gnuPOA.java b/gnu/CORBA/Poa/gnuPOA.java
index 1d9e83853..4c1826a81 100644
--- a/gnu/CORBA/Poa/gnuPOA.java
+++ b/gnu/CORBA/Poa/gnuPOA.java
@@ -87,8 +87,8 @@ import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongAdapter;
import org.omg.PortableServer.POAPackage.WrongPolicy;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
/**
* Our POA implementation.
@@ -102,7 +102,7 @@ public class gnuPOA
/**
* The active object map, mapping between object keys, objects and servants.
*/
- public final activeObjectMap aom = new activeObjectMap();
+ public final AOM aom = new AOM();
/**
* The children of this POA.
@@ -199,7 +199,7 @@ public class gnuPOA
throws InvalidPolicy
{
// Add default policies.
- Policy[] all_policies = policySets.withDefault(a_policies);
+ Policy[] all_policies = StandardPolicies.withDefault(a_policies);
name = a_name;
parent = a_parent;
@@ -222,7 +222,7 @@ public class gnuPOA
for (int i = 0; i < s_policies.length; i++)
{
s_policies [ i ] = all_policies [ i ].copy();
- m_policies.add(((vPolicy) s_policies [ i ]).getValue());
+ m_policies.add(((AccessiblePolicy) s_policies [ i ]).getValue());
}
retain_servant = applies(ServantRetentionPolicyValue.RETAIN);
@@ -281,7 +281,7 @@ public class gnuPOA
keys.addAll(aom.keySet());
byte[] key;
- activeObjectMap.Obj obj;
+ AOM.Obj obj;
boolean last;
for (int i = 0; i < keys.size(); i++)
{
@@ -445,7 +445,7 @@ public class gnuPOA
required(ServantRetentionPolicyValue.RETAIN);
required(IdAssignmentPolicyValue.SYSTEM_ID);
- activeObjectMap.Obj exists = aom.findServant(a_servant);
+ AOM.Obj exists = aom.findServant(a_servant);
if (exists != null)
{
@@ -464,8 +464,8 @@ public class gnuPOA
// activations.
}
- byte[] object_key = activeObjectMap.getFreeId();
- servantDelegate delegate = new servantDelegate(a_servant, this, object_key);
+ byte[] object_key = AOM.getFreeId();
+ ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this, object_key);
connectDelegate(object_key, delegate);
return object_key;
}
@@ -514,12 +514,12 @@ public class gnuPOA
// already active.
if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
{
- activeObjectMap.Obj sx = aom.findServant(a_servant, false);
+ AOM.Obj sx = aom.findServant(a_servant, false);
if (sx != null)
throw new ServantAlreadyActive();
}
- activeObjectMap.Obj exists = aom.get(an_Object_Id);
+ AOM.Obj exists = aom.get(an_Object_Id);
if (exists != null)
{
if (exists.servant == null)
@@ -537,8 +537,8 @@ public class gnuPOA
}
else
{
- servantDelegate delegate =
- new servantDelegate(a_servant, this, an_Object_Id);
+ ServantDelegateImpl delegate =
+ new ServantDelegateImpl(a_servant, this, an_Object_Id);
connectDelegate(an_Object_Id, delegate);
}
}
@@ -556,7 +556,7 @@ public class gnuPOA
* (the required servant manager may be missing).
*/
private void locateServant(byte[] an_Object_Id, Servant a_servant,
- activeObjectMap.Obj exists, boolean use_forwarding
+ AOM.Obj exists, boolean use_forwarding
)
throws InternalError
{
@@ -582,8 +582,8 @@ public class gnuPOA
throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO);
}
- servantDelegate delegate =
- new servantDelegate(exists.servant, this, an_Object_Id);
+ ServantDelegateImpl delegate =
+ new ServantDelegateImpl(exists.servant, this, an_Object_Id);
exists.servant._set_delegate(delegate);
object.setServant(exists.servant);
connect_to_orb(an_Object_Id, delegate.object);
@@ -605,7 +605,7 @@ public class gnuPOA
{
required(ServantRetentionPolicyValue.RETAIN);
- activeObjectMap.Obj exists = aom.get(the_Object_Id);
+ AOM.Obj exists = aom.get(the_Object_Id);
if (exists == null || exists.isDeactiveted())
throw new ObjectNotActive();
@@ -615,7 +615,7 @@ public class gnuPOA
// Check if this servant is serving something else.
aom.remove(the_Object_Id);
- activeObjectMap.Obj other = aom.findServant(exists.servant, false);
+ AOM.Obj other = aom.findServant(exists.servant, false);
boolean remaining = other != null;
@@ -643,7 +643,7 @@ public class gnuPOA
throws WrongPolicy
{
required(IdAssignmentPolicyValue.SYSTEM_ID);
- return create_reference_with_id(activeObjectMap.getFreeId(), a_repository_id);
+ return create_reference_with_id(AOM.getFreeId(), a_repository_id);
}
/**
@@ -672,7 +672,7 @@ public class gnuPOA
ids = new String[] { a_repository_id };
// Check maybe such object is already activated.
- activeObjectMap.Obj e = aom.get(an_object_id);
+ AOM.Obj e = aom.get(an_object_id);
Servant servant;
if (e == null)
@@ -847,7 +847,7 @@ public class gnuPOA
return m_poa_id;
else
{
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
POA p = this;
while (p != null)
{
@@ -874,7 +874,7 @@ public class gnuPOA
{
required(ServantRetentionPolicyValue.RETAIN);
- activeObjectMap.Obj ref = aom.get(the_Object_Id);
+ AOM.Obj ref = aom.get(the_Object_Id);
if (ref == null)
throw new ObjectNotActive();
else
@@ -897,7 +897,7 @@ public class gnuPOA
{
if (applies(ServantRetentionPolicyValue.RETAIN))
{
- activeObjectMap.Obj ref = aom.get(the_Object_Id);
+ AOM.Obj ref = aom.get(the_Object_Id);
if (ref == null || ref.isDeactiveted())
{
if (default_servant != null)
@@ -932,7 +932,7 @@ public class gnuPOA
public byte[] reference_to_id(org.omg.CORBA.Object the_Object)
throws WrongAdapter, WrongPolicy
{
- activeObjectMap.Obj ref = aom.findObject(the_Object);
+ AOM.Obj ref = aom.findObject(the_Object);
if (ref == null)
throw new WrongAdapter();
return ref.key;
@@ -958,7 +958,7 @@ public class gnuPOA
{
if (applies(ServantRetentionPolicyValue.RETAIN))
{
- activeObjectMap.Obj ref = aom.findObject(the_Object);
+ AOM.Obj ref = aom.findObject(the_Object);
if (ref == null)
throw new WrongAdapter();
else if (ref.isDeactiveted() || ref.servant == null)
@@ -1017,7 +1017,7 @@ public class gnuPOA
)
)
{
- activeObjectMap.Obj ref = null;
+ AOM.Obj ref = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
ref = aom.findServant(the_Servant);
if (ref == null &&
@@ -1071,7 +1071,7 @@ public class gnuPOA
{
required(ServantRetentionPolicyValue.RETAIN);
- activeObjectMap.Obj exists = null;
+ AOM.Obj exists = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
exists = aom.findServant(the_Servant);
@@ -1098,10 +1098,10 @@ public class gnuPOA
{
checkDiscarding();
- byte[] object_key = activeObjectMap.getFreeId();
+ byte[] object_key = AOM.getFreeId();
- servantDelegate delegate =
- new servantDelegate(the_Servant, this, object_key);
+ ServantDelegateImpl delegate =
+ new ServantDelegateImpl(the_Servant, this, object_key);
connectDelegate(object_key, delegate);
return delegate.object;
@@ -1126,7 +1126,7 @@ public class gnuPOA
* under the forwarding exception (for remote client). Otherwise, the
* request is internally redirected (for local invocation).
*/
- private Servant incarnate(activeObjectMap.Obj x, byte[] object_key,
+ private Servant incarnate(AOM.Obj x, byte[] object_key,
Servant a_servant, boolean use_forwarding
)
{
@@ -1328,7 +1328,7 @@ public class gnuPOA
keys.addAll(aom.keySet());
byte[] key;
- activeObjectMap.Obj obj;
+ AOM.Obj obj;
for (int i = 0; i < keys.size(); i++)
{
key = (byte[]) keys.get(i);
@@ -1433,7 +1433,7 @@ public class gnuPOA
* Connect the given delegate under the given key, also calling
* incarnate.
*/
- private void connectDelegate(byte[] object_key, servantDelegate delegate)
+ private void connectDelegate(byte[] object_key, ServantDelegateImpl delegate)
{
aom.add(delegate);
connect_to_orb(object_key, delegate.object);
@@ -1517,9 +1517,9 @@ public class gnuPOA
/**
* Recursively searches for the given object in the POA tree.
*/
- public activeObjectMap.Obj findObject(org.omg.CORBA.Object object)
+ public AOM.Obj findObject(org.omg.CORBA.Object object)
{
- activeObjectMap.Obj h = aom.findObject(object);
+ AOM.Obj h = aom.findObject(object);
if (h != null)
return h;
else
@@ -1533,16 +1533,16 @@ public class gnuPOA
}
return h;
}
-
+
/**
* Recursively searches for the given key in the POA tree.
* @param ior_key the key, ecapsulating both object
* and poa ids.
* @return
*/
- public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id)
+ public AOM.Obj findKey(byte[] object_id, byte[] poa_id)
{
- activeObjectMap.Obj h = null;
+ AOM.Obj h = null;
if (Arrays.equals(poa_id, id()))
h = aom.get(object_id);
if (h != null)
@@ -1563,9 +1563,9 @@ public class gnuPOA
* Parses the given key, extracts poa and object id and searches
* for such reference.
*/
- public activeObjectMap.Obj findIorKey(byte[] ior_key)
+ public AOM.Obj findIorKey(byte[] ior_key)
{
- cdrBufInput in = new cdrBufInput(ior_key);
+ BufferredCdrInput in = new BufferredCdrInput(ior_key);
int signature = in.read_long();
if (signature != SIGNATURE)
return null;
@@ -1582,7 +1582,7 @@ public class gnuPOA
*/
public byte[] toIORKey(byte[] object_id)
{
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
buffer.write_long(SIGNATURE);
buffer.write_sequence(object_id);
buffer.write_sequence(id());
@@ -1600,7 +1600,7 @@ public class gnuPOA
*/
public byte[] idFormIor(byte[] ior_key)
{
- cdrBufInput in = new cdrBufInput(ior_key);
+ BufferredCdrInput in = new BufferredCdrInput(ior_key);
int signature = in.read_long();
if (signature != SIGNATURE)
return null;
@@ -1612,4 +1612,24 @@ public class gnuPOA
else
return null;
}
-} \ No newline at end of file
+
+ /**
+ * Recursively searches for the given servant in the POA tree.
+ */
+ public AOM.Obj findServant(Servant servant)
+ {
+ AOM.Obj h = aom.findServant(servant);
+ if (h != null)
+ return h;
+ else
+ {
+ for (int i = 0; i < children.size(); i++)
+ {
+ h = ((gnuPOA) children.get(i)).findServant(servant);
+ if (h != null)
+ return h;
+ }
+ }
+ return h;
+ }
+}
diff --git a/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java b/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java
index 5bbcd1321..2f77639c6 100644
--- a/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java
+++ b/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.RequestProcessingPolicyValue;
*/
public class gnuRequestProcessingPolicy
extends _PolicyImplBase
- implements RequestProcessingPolicy, vPolicy
+ implements RequestProcessingPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/Poa/gnuServantObject.java b/gnu/CORBA/Poa/gnuServantObject.java
index 1ad98d1ce..020897a45 100644
--- a/gnu/CORBA/Poa/gnuServantObject.java
+++ b/gnu/CORBA/Poa/gnuServantObject.java
@@ -39,14 +39,17 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.GIOP.ReplyHeader;
-import gnu.CORBA.IOR_Delegate;
-import gnu.CORBA.IOR_contructed_object;
+import gnu.CORBA.IorDelegate;
+import gnu.CORBA.IorObject;
import gnu.CORBA.Interceptor.gnuServerRequestInfo;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.CORBA.IOR;
+import gnu.CORBA.IorProvider;
+import gnu.CORBA.Minor;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.bufferedResponseHandler;
-import gnu.CORBA.recordTypeCode;
-import gnu.CORBA.streamReadyHolder;
+import gnu.CORBA.ResponseHandlerImpl;
+import gnu.CORBA.StreamHolder;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -90,7 +93,8 @@ import java.util.Arrays;
public class gnuServantObject extends ObjectImpl
implements org.omg.CORBA.Object,
InvokeHandler,
- CurrentOperations
+ CurrentOperations,
+ IorProvider
{
/**
* The associated servant that must also implement the {@link InvokeHandler}
@@ -144,6 +148,14 @@ public class gnuServantObject extends ObjectImpl
poa = a_poa;
orb = an_orb;
}
+
+ /**
+ * Get the IOR as it would be for this object.
+ */
+ public IOR getIor()
+ {
+ return orb.getLocalIor(this);
+ }
/**
* Create a servant object, associated with the passed servant.
@@ -257,10 +269,8 @@ public class gnuServantObject extends ObjectImpl
}
catch (Exception ex)
{
- ex.printStackTrace();
-
BAD_OPERATION bad =
- new BAD_OPERATION("Unable to activate", 0x5004,
+ new BAD_OPERATION("Unable to activate", Minor.Activation,
CompletionStatus.COMPLETED_NO
);
bad.initCause(ex);
@@ -276,7 +286,7 @@ public class gnuServantObject extends ObjectImpl
// No servant and no servant manager - throw exception.
else
{
- throw new BAD_OPERATION("Unable to activate", 0x5002,
+ throw new BAD_OPERATION("Unable to activate", Minor.Activation,
CompletionStatus.COMPLETED_NO
);
}
@@ -294,7 +304,7 @@ public class gnuServantObject extends ObjectImpl
}
else if (a_servant instanceof DynamicImplementation)
{
- return new dynImpHandler((DynamicImplementation) a_servant);
+ return new DynamicImpHandler((DynamicImplementation) a_servant);
}
else
{
@@ -402,17 +412,17 @@ public class gnuServantObject extends ObjectImpl
boolean intercept = false;
ServerRequestInterceptorOperations interceptor = null;
gnuServerRequestInfo info = null;
- bufferedResponseHandler i_handler = null;
+ ResponseHandlerImpl i_handler = null;
try
{
if (orb.iServer != null &&
- r_handler instanceof bufferedResponseHandler
+ r_handler instanceof ResponseHandlerImpl
)
{
interceptor = orb.iServer;
- i_handler = (bufferedResponseHandler) r_handler;
+ i_handler = (ResponseHandlerImpl) r_handler;
info =
new gnuServerRequestInfo(this, i_handler.request_header,
@@ -426,7 +436,7 @@ public class gnuServantObject extends ObjectImpl
try
{
CookieHolder cookie = null;
- activeObjectMap.Obj self = poa.aom.get(Id);
+ AOM.Obj self = poa.aom.get(Id);
if (poa.servant_locator != null)
{
@@ -467,18 +477,18 @@ public class gnuServantObject extends ObjectImpl
{
// In some cases exception is thrown if the delegate is not set.
}
- if (d instanceof servantDelegate)
+ if (d instanceof ServantDelegateImpl)
{
// If the delegate is already set, check maybe we can
// reuse the existing instance.
- if (((servantDelegate) d).object != this)
+ if (((ServantDelegateImpl) d).object != this)
{
- servant._set_delegate(new servantDelegate(servant, poa, Id));
+ servant._set_delegate(new ServantDelegateImpl(servant, poa, Id));
}
}
else
{
- servant._set_delegate(new servantDelegate(servant, poa, Id));
+ servant._set_delegate(new ServantDelegateImpl(servant, poa, Id));
}
try
@@ -536,13 +546,13 @@ public class gnuServantObject extends ObjectImpl
{
// Failed due any reason, insert without
// helper.
- a.insert_Streamable(new streamReadyHolder(
+ a.insert_Streamable(new StreamHolder(
buf.create_input_stream()
)
);
- recordTypeCode r =
- new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r =
+ new RecordTypeCode(TCKind.tk_except);
r.setId(uex_idl);
r.setName(ObjectCreator.getDefaultName(
uex_idl
@@ -774,12 +784,12 @@ public class gnuServantObject extends ObjectImpl
gnuServantObject g = (gnuServantObject) other;
return orb == g.orb && poa == g.poa && Arrays.equals(Id, g.Id);
}
- else if (other instanceof IOR_contructed_object)
+ else if (other instanceof IorObject)
{
- IOR_contructed_object ir = ((IOR_contructed_object) other);
+ IorObject ir = ((IorObject) other);
try
{
- IOR_Delegate ird = (IOR_Delegate) ir._get_delegate();
+ IorDelegate ird = (IorDelegate) ir._get_delegate();
byte[] ior_id = poa.idFormIor(ird.getIor().key);
if (ior_id != null && Arrays.equals(ior_id, Id))
{
diff --git a/gnu/CORBA/Poa/gnuServantRetentionPolicy.java b/gnu/CORBA/Poa/gnuServantRetentionPolicy.java
index 009e70e1b..9fb61ab3f 100644
--- a/gnu/CORBA/Poa/gnuServantRetentionPolicy.java
+++ b/gnu/CORBA/Poa/gnuServantRetentionPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ServantRetentionPolicyValue;
*/
public class gnuServantRetentionPolicy
extends _PolicyImplBase
- implements ServantRetentionPolicy, vPolicy
+ implements ServantRetentionPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/Poa/gnuThreadPolicy.java b/gnu/CORBA/Poa/gnuThreadPolicy.java
index f42ebefb3..1de94a101 100644
--- a/gnu/CORBA/Poa/gnuThreadPolicy.java
+++ b/gnu/CORBA/Poa/gnuThreadPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ThreadPolicyValue;
*/
public class gnuThreadPolicy
extends _PolicyImplBase
- implements ThreadPolicy, vPolicy
+ implements ThreadPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/gnu/CORBA/binaryReply.java b/gnu/CORBA/RawReply.java
index 71afa3776..a36f4b4b2 100644
--- a/gnu/CORBA/binaryReply.java
+++ b/gnu/CORBA/RawReply.java
@@ -1,4 +1,4 @@
-/* binaryReply.java --
+/* RawReply.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,7 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.GIOP.MessageHeader;
import org.omg.CORBA.ORB;
@@ -48,7 +48,7 @@ import org.omg.CORBA.ORB;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-class binaryReply
+class RawReply
{
/**
* The message header.
@@ -71,7 +71,7 @@ class binaryReply
* @param an_header the message header
* @param a_data the message data.
*/
- binaryReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
+ RawReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
{
orb = an_orb;
header = an_header;
@@ -83,9 +83,9 @@ class binaryReply
*
* @return the CDR stream to read the message data.
*/
- cdrBufInput getStream()
+ BufferredCdrInput getStream()
{
- cdrBufInput in = new cdrBufInput(data);
+ BufferredCdrInput in = new BufferredCdrInput(data);
in.setOffset(header.getHeaderSize());
in.setVersion(header.version);
in.setOrb(orb);
diff --git a/gnu/CORBA/bufferedResponseHandler.java b/gnu/CORBA/ResponseHandlerImpl.java
index 0fe945ca1..4d509cc52 100644
--- a/gnu/CORBA/bufferedResponseHandler.java
+++ b/gnu/CORBA/ResponseHandlerImpl.java
@@ -1,4 +1,4 @@
-/* bufferedResponseHandler.java --
+/* ResponseHandlerImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,11 +38,11 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.GIOP.RequestHeader;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.ORB;
import org.omg.CORBA.portable.OutputStream;
@@ -53,7 +53,7 @@ import org.omg.CORBA.portable.ResponseHandler;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class bufferedResponseHandler
+public class ResponseHandlerImpl
implements ResponseHandler
{
/**
@@ -86,7 +86,7 @@ public class bufferedResponseHandler
/**
* The buffer to write into.
*/
- private cdrBufOutput buffer;
+ private BufferedCdrOutput buffer;
/**
* Create a new buffered response handler that uses the given message headers.
@@ -96,7 +96,7 @@ public class bufferedResponseHandler
* @param m_header a message header.
* @param r_header a reply header.
*/
- bufferedResponseHandler(ORB an_orb, MessageHeader m_header,
+ ResponseHandlerImpl(ORB an_orb, MessageHeader m_header,
ReplyHeader r_header, RequestHeader rq_header)
{
message_header = m_header;
@@ -147,7 +147,7 @@ public class bufferedResponseHandler
*
* @return the CDR output stream, containing the written output.
*/
- public cdrBufOutput getBuffer()
+ public BufferedCdrOutput getBuffer()
{
return buffer;
}
@@ -166,10 +166,10 @@ public class bufferedResponseHandler
*/
private void prepareStream()
{
- buffer = new cdrBufOutput();
+ buffer = new BufferedCdrOutput();
buffer.setOrb(orb);
buffer.setVersion(message_header.version);
- buffer.setCodeSet(cxCodeSet.find(reply_header.service_context));
+ buffer.setCodeSet(CodeSetServiceContext.find(reply_header.service_context));
// Since 1.2, the data section is always aligned on the 8 byte boundary.
// In older versions, it is necessary to set the offset correctly.
diff --git a/gnu/CORBA/ServiceRequestAdapter.java b/gnu/CORBA/ServiceRequestAdapter.java
index 7f40fc84d..a6f7aa52b 100644
--- a/gnu/CORBA/ServiceRequestAdapter.java
+++ b/gnu/CORBA/ServiceRequestAdapter.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import org.omg.CORBA.ARG_IN;
import org.omg.CORBA.ARG_INOUT;
@@ -67,7 +67,7 @@ public class ServiceRequestAdapter
/**
* A buffer for writing the response.
*/
- cdrBufOutput reply = new cdrBufOutput();
+ BufferedCdrOutput reply = new BufferedCdrOutput();
/**
* If set to true, an exception has been thrown during the invocation.
@@ -105,7 +105,7 @@ public class ServiceRequestAdapter
int OUT = ARG_OUT.value;
// Write all arguments to the buffer output stream.
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
gnuNVList args = new gnuNVList();
request.arguments(args);
@@ -127,7 +127,7 @@ public class ServiceRequestAdapter
{
// Write the exception information
gnuAny exc = new gnuAny();
- universalHolder uku = new universalHolder(h.reply);
+ GeneralHolder uku = new GeneralHolder(h.reply);
exc.insert_Streamable(uku);
request.set_exception(exc);
}
@@ -146,7 +146,7 @@ public class ServiceRequestAdapter
{
// Use the universal holder otherwise.
gnuAny r = new gnuAny();
- r.insert_Streamable(new streamReadyHolder(in));
+ r.insert_Streamable(new StreamHolder(in));
}
// Unpack the arguments
diff --git a/gnu/CORBA/Simple_delegate.java b/gnu/CORBA/SimpleDelegate.java
index 5eabc7da8..3b5e1d81c 100644
--- a/gnu/CORBA/Simple_delegate.java
+++ b/gnu/CORBA/SimpleDelegate.java
@@ -57,8 +57,9 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class Simple_delegate
+public class SimpleDelegate
extends Delegate
+ implements IorProvider
{
/**
* The orb.
@@ -70,7 +71,7 @@ public class Simple_delegate
*/
protected IOR ior;
- public Simple_delegate(ORB an_orb, IOR an_ior)
+ public SimpleDelegate(ORB an_orb, IOR an_ior)
{
orb = an_orb;
ior = an_ior;
@@ -265,12 +266,19 @@ public class Simple_delegate
}
/**
- * This should never be called this type delegate.
- *
- * @throws InternalError, always.
+ * This method assumes that the target is local and connected to the ORB.
*/
public Request request(org.omg.CORBA.Object target, String operation)
{
- throw new InternalError();
+ if (orb instanceof OrbFunctional)
+ {
+ ((OrbFunctional) orb).ensureRunning();
+ }
+ gnuRequest g = new gnuRequest();
+ g.setORB(orb);
+ g.setOperation(operation);
+ g.setIor(ior);
+ g.m_target = target;
+ return g;
}
} \ No newline at end of file
diff --git a/gnu/CORBA/SocketRepository.java b/gnu/CORBA/SocketRepository.java
index a6b99200a..cac4ad65f 100644
--- a/gnu/CORBA/SocketRepository.java
+++ b/gnu/CORBA/SocketRepository.java
@@ -40,8 +40,9 @@ package gnu.CORBA;
import java.net.Socket;
import java.net.SocketException;
-
-import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
/**
* This class caches the opened sockets that are reused during the
@@ -55,10 +56,11 @@ public class SocketRepository
/**
* The socket map.
*/
- private static HashMap sockets = new HashMap();
-
+ private static Hashtable sockets = new Hashtable();
+
/**
- * Put a socket.
+ * Put a socket. This method also discards all not reusable sockets from
+ * the map.
*
* @param key as socket key.
*
@@ -67,6 +69,36 @@ public class SocketRepository
public static void put_socket(Object key, Socket s)
{
sockets.put(key, s);
+ gc();
+ }
+
+ /**
+ * Removes all non reusable sockets.
+ */
+ public static void gc()
+ {
+ Iterator iter = sockets.entrySet().iterator();
+
+ Map.Entry e;
+ Socket sx;
+
+ while (iter.hasNext())
+ {
+ e = (Map.Entry) iter.next();
+ sx = (Socket) e.getValue();
+
+ if (not_reusable(sx))
+ iter.remove();
+ }
+ }
+
+ /**
+ * Return true if the socket is no longer reusable.
+ */
+ static boolean not_reusable(Socket s)
+ {
+ return (s.isClosed() || !s.isBound() || !s.isConnected() ||
+ s.isInputShutdown() || s.isOutputShutdown());
}
/**
@@ -75,21 +107,26 @@ public class SocketRepository
* @param key a socket key.
*
* @return an opened socket for reuse, null if no such available or it is
- * closed.
+ * closed, its input or output has been shutown or otherwise the socket
+ * is not reuseable.
*/
public static Socket get_socket(Object key)
{
+ if (true)
+ return null;
+
Socket s = (Socket) sockets.get(key);
if (s == null)
return null;
- else if (s.isClosed())
+
+ // Ensure that the socket is fully reusable.
+ else if (not_reusable(s))
{
sockets.remove(key);
return null;
}
else
{
- sockets.remove(key);
try
{
// Set one minute time out that will be changed later.
@@ -99,6 +136,8 @@ public class SocketRepository
{
s = null;
}
+
+ sockets.remove(key);
return s;
}
}
diff --git a/gnu/CORBA/streamRequest.java b/gnu/CORBA/StreamBasedRequest.java
index a0f7eb099..66796d653 100644
--- a/gnu/CORBA/streamRequest.java
+++ b/gnu/CORBA/StreamBasedRequest.java
@@ -38,15 +38,15 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
/**
* A stream, additionally holding the gnu request.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class streamRequest
- extends cdrBufOutput
+public class StreamBasedRequest
+ extends BufferedCdrOutput
{
/**
* The enclosed request.
diff --git a/gnu/CORBA/streamReadyHolder.java b/gnu/CORBA/StreamHolder.java
index a777bd555..de2fda0ba 100644
--- a/gnu/CORBA/streamReadyHolder.java
+++ b/gnu/CORBA/StreamHolder.java
@@ -1,4 +1,4 @@
-/* streamReadyHolder.java --
+/* StreamHolder.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import java.io.IOException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class streamReadyHolder
+public class StreamHolder
implements Streamable
{
/**
@@ -65,7 +65,7 @@ public class streamReadyHolder
*
* @param a_stream a stream.
*/
- public streamReadyHolder(InputStream a_stream)
+ public StreamHolder(InputStream a_stream)
{
stream = a_stream;
}
@@ -98,7 +98,10 @@ public class streamReadyHolder
}
catch (IOException ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL();
+ m.initCause(ex);
+ m.minor = Minor.CDR;
+ throw m;
}
}
diff --git a/gnu/CORBA/stubFinder.java b/gnu/CORBA/StubLocator.java
index 77efd0047..d9e5ee471 100644
--- a/gnu/CORBA/stubFinder.java
+++ b/gnu/CORBA/StubLocator.java
@@ -1,4 +1,4 @@
-/* stubFinder.java --
+/* StubLocator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class stubFinder
+public class StubLocator
{
/**
* Search for the possibly available default stub.
@@ -83,7 +83,7 @@ public class stubFinder
String stub = "_" + s.substring(b + 1) + "Stub";
- Class stubClass = Class.forName(path + stub);
+ Class stubClass = ObjectCreator.forName(path + stub);
return (ObjectImpl) stubClass.newInstance();
}
@@ -105,6 +105,6 @@ public class stubFinder
*/
protected static ObjectImpl createDefaultStub(ORB orb, IOR ior)
{
- return new IOR_contructed_object(orb, ior);
+ return new IorObject(orb, ior);
}
}
diff --git a/gnu/CORBA/TypeCodeHelper.java b/gnu/CORBA/TypeCodeHelper.java
index c74227542..4ffb0b744 100644
--- a/gnu/CORBA/TypeCodeHelper.java
+++ b/gnu/CORBA/TypeCodeHelper.java
@@ -38,6 +38,13 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.FixedTypeCode;
+import gnu.CORBA.typecodes.GeneralTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
@@ -62,10 +69,10 @@ public class TypeCodeHelper
{
TCKind kind = TCKind.from_int(in.read_long());
TypeCode rt;
- generalTypeCode g;
- recordTypeCode r;
- recordTypeCode.Field f;
- stringTypeCode s;
+ GeneralTypeCode g;
+ RecordTypeCode r;
+ RecordTypeCode.Field f;
+ StringTypeCode s;
int n;
switch (kind.value())
@@ -73,21 +80,21 @@ public class TypeCodeHelper
case TCKind._tk_sequence :
case TCKind._tk_array :
- primitiveArrayTypeCode p = new primitiveArrayTypeCode(kind);
+ ArrayTypeCode p = new ArrayTypeCode(kind);
p.setLength(in.read_long());
rt = p;
break;
case TCKind._tk_string :
case TCKind._tk_wstring :
- s = new stringTypeCode(kind);
+ s = new StringTypeCode(kind);
s.setLength(in.read_long());
rt = s;
break;
case TCKind._tk_fixed :
- fixedTypeCode fx = new fixedTypeCode();
+ FixedTypeCode fx = new FixedTypeCode();
fx.setDigits(in.read_short());
fx.setScale(in.read_short());
rt = fx;
@@ -96,7 +103,7 @@ public class TypeCodeHelper
case TCKind._tk_objref :
case TCKind._tk_native :
case TCKind._tk_abstract_interface :
- g = new generalTypeCode(kind);
+ g = new GeneralTypeCode(kind);
g.setId(in.read_string());
g.setName(in.read_string());
rt = g;
@@ -104,7 +111,7 @@ public class TypeCodeHelper
case TCKind._tk_alias :
case TCKind._tk_value_box :
- g = new generalTypeCode(kind);
+ g = new GeneralTypeCode(kind);
g.setId(in.read_string());
g.setName(in.read_string());
g.setContentType(in.read_TypeCode());
@@ -113,7 +120,7 @@ public class TypeCodeHelper
case TCKind._tk_struct :
case TCKind._tk_except :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
@@ -129,7 +136,7 @@ public class TypeCodeHelper
break;
case TCKind._tk_enum :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
@@ -144,7 +151,7 @@ public class TypeCodeHelper
break;
case TCKind._tk_union :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
r.setDiscriminator_type(in.read_TypeCode());
@@ -164,7 +171,7 @@ public class TypeCodeHelper
break;
case TCKind._tk_value :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
r.setTypeModifier(in.read_short());
@@ -183,7 +190,7 @@ public class TypeCodeHelper
break;
default :
- rt = new primitiveTypeCode(kind);
+ rt = new PrimitiveTypeCode(kind);
}
return rt;
}
diff --git a/gnu/CORBA/typeNamer.java b/gnu/CORBA/TypeKindNamer.java
index f790dc959..3296db360 100644
--- a/gnu/CORBA/typeNamer.java
+++ b/gnu/CORBA/TypeKindNamer.java
@@ -38,6 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
@@ -48,7 +51,7 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class typeNamer
+public class TypeKindNamer
{
/**
* Names of the primitve types.
@@ -69,46 +72,46 @@ public class typeNamer
protected static final TypeCode[] primitveCodes =
new TypeCode[]
{
- new primitiveTypeCode(TCKind.tk_null),
- new primitiveTypeCode(TCKind.tk_void),
- new primitiveTypeCode(TCKind.tk_short),
- new primitiveTypeCode(TCKind.tk_long),
- new primitiveTypeCode(TCKind.tk_ushort),
- new primitiveTypeCode(TCKind.tk_ulong),
- new primitiveTypeCode(TCKind.tk_float),
- new primitiveTypeCode(TCKind.tk_double),
- new primitiveTypeCode(TCKind.tk_boolean),
- new primitiveTypeCode(TCKind.tk_char),
- new primitiveTypeCode(TCKind.tk_octet),
- new primitiveTypeCode(TCKind.tk_any),
- new primitiveTypeCode(TCKind.tk_TypeCode),
- new primitiveTypeCode(TCKind.tk_Principal),
- new recordTypeCode(TCKind.tk_objref),
- new primitiveTypeCode(TCKind.tk_struct),
- new primitiveTypeCode(TCKind.tk_union),
- new primitiveTypeCode(TCKind.tk_enum),
- new primitiveTypeCode(TCKind.tk_string),
- new primitiveTypeCode(TCKind.tk_sequence),
- new primitiveTypeCode(TCKind.tk_array),
- new primitiveTypeCode(TCKind.tk_alias),
- new primitiveTypeCode(TCKind.tk_except),
- new primitiveTypeCode(TCKind.tk_longlong),
- new primitiveTypeCode(TCKind.tk_ulonglong),
- new primitiveTypeCode(TCKind.tk_longdouble),
- new primitiveTypeCode(TCKind.tk_wchar),
- new primitiveTypeCode(TCKind.tk_wstring),
- new primitiveTypeCode(TCKind.tk_fixed),
- new primitiveTypeCode(TCKind.tk_value),
- new primitiveTypeCode(TCKind.tk_value_box),
- new primitiveTypeCode(TCKind.tk_native),
- new primitiveTypeCode(TCKind.tk_abstract_interface)
+ new PrimitiveTypeCode(TCKind.tk_null),
+ new PrimitiveTypeCode(TCKind.tk_void),
+ new PrimitiveTypeCode(TCKind.tk_short),
+ new PrimitiveTypeCode(TCKind.tk_long),
+ new PrimitiveTypeCode(TCKind.tk_ushort),
+ new PrimitiveTypeCode(TCKind.tk_ulong),
+ new PrimitiveTypeCode(TCKind.tk_float),
+ new PrimitiveTypeCode(TCKind.tk_double),
+ new PrimitiveTypeCode(TCKind.tk_boolean),
+ new PrimitiveTypeCode(TCKind.tk_char),
+ new PrimitiveTypeCode(TCKind.tk_octet),
+ new PrimitiveTypeCode(TCKind.tk_any),
+ new PrimitiveTypeCode(TCKind.tk_TypeCode),
+ new PrimitiveTypeCode(TCKind.tk_Principal),
+ new RecordTypeCode(TCKind.tk_objref),
+ new PrimitiveTypeCode(TCKind.tk_struct),
+ new PrimitiveTypeCode(TCKind.tk_union),
+ new PrimitiveTypeCode(TCKind.tk_enum),
+ new PrimitiveTypeCode(TCKind.tk_string),
+ new PrimitiveTypeCode(TCKind.tk_sequence),
+ new PrimitiveTypeCode(TCKind.tk_array),
+ new PrimitiveTypeCode(TCKind.tk_alias),
+ new PrimitiveTypeCode(TCKind.tk_except),
+ new PrimitiveTypeCode(TCKind.tk_longlong),
+ new PrimitiveTypeCode(TCKind.tk_ulonglong),
+ new PrimitiveTypeCode(TCKind.tk_longdouble),
+ new PrimitiveTypeCode(TCKind.tk_wchar),
+ new PrimitiveTypeCode(TCKind.tk_wstring),
+ new PrimitiveTypeCode(TCKind.tk_fixed),
+ new PrimitiveTypeCode(TCKind.tk_value),
+ new PrimitiveTypeCode(TCKind.tk_value_box),
+ new PrimitiveTypeCode(TCKind.tk_native),
+ new PrimitiveTypeCode(TCKind.tk_abstract_interface)
};
static
{
// The Id of the "abstract object" is defined as empty string.
- recordTypeCode object =
- (recordTypeCode) primitveCodes [ TCKind._tk_objref ];
+ RecordTypeCode object =
+ (RecordTypeCode) primitveCodes [ TCKind._tk_objref ];
object.setId("");
object.setName("Object");
}
diff --git a/gnu/CORBA/Version.java b/gnu/CORBA/Version.java
index 5a6eb5c25..efc27c220 100644
--- a/gnu/CORBA/Version.java
+++ b/gnu/CORBA/Version.java
@@ -123,7 +123,10 @@ public class Version
}
catch (IOException ex)
{
- throw new MARSHAL("IOException while reading message header");
+ MARSHAL m = new MARSHAL("IOException while reading message header");
+ m.initCause(ex);
+ m.minor = Minor.Header;
+ throw m;
}
}
@@ -209,7 +212,10 @@ public class Version
}
catch (IOException ex)
{
- throw new MARSHAL("IOException while writing message header");
+ MARSHAL m = new MARSHAL("IOException while writing message header");
+ m.minor = Minor.Header;
+ m.initCause(ex);
+ throw m;
}
}
diff --git a/gnu/CORBA/WCharHolder.java b/gnu/CORBA/WCharHolder.java
index 23f0ad100..3c6a87fbe 100644
--- a/gnu/CORBA/WCharHolder.java
+++ b/gnu/CORBA/WCharHolder.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
@@ -61,7 +63,7 @@ public final class WCharHolder
/**
* The default type code for this holder.
*/
- private static final TypeCode t_char = new primitiveTypeCode(TCKind.tk_wchar);
+ private static final TypeCode t_char = new PrimitiveTypeCode(TCKind.tk_wchar);
/**
* The <code>char</code> (CORBA <code>wchar</code>) value,
diff --git a/gnu/CORBA/WStringHolder.java b/gnu/CORBA/WStringHolder.java
index c9e8e3323..7f18791df 100644
--- a/gnu/CORBA/WStringHolder.java
+++ b/gnu/CORBA/WStringHolder.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.StringTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
@@ -62,8 +64,8 @@ public class WStringHolder
/**
* The default type code for this holder.
*/
- private static final stringTypeCode t_string =
- new stringTypeCode(TCKind.tk_wstring);
+ private static final StringTypeCode t_string =
+ new StringTypeCode(TCKind.tk_wstring);
/**
* The <code>String</code> (CORBA <code>string</code>) value,
diff --git a/gnu/CORBA/_PolicyImplBase.java b/gnu/CORBA/_PolicyImplBase.java
index d9ff9d648..17a5f4a40 100644
--- a/gnu/CORBA/_PolicyImplBase.java
+++ b/gnu/CORBA/_PolicyImplBase.java
@@ -165,7 +165,8 @@ public abstract class _PolicyImplBase
output.write_long(policyCode);
}
else
- throw new BAD_OPERATION(method, 0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(method, Minor.Method,
+ CompletionStatus.COMPLETED_MAYBE);
return output;
}
diff --git a/gnu/CORBA/gnuAny.java b/gnu/CORBA/gnuAny.java
index 80946b046..729386da2 100644
--- a/gnu/CORBA/gnuAny.java
+++ b/gnu/CORBA/gnuAny.java
@@ -39,8 +39,10 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.Vio;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnyHolder;
@@ -63,7 +65,6 @@ import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodeHolder;
import org.omg.CORBA.ValueBaseHolder;
-import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.Streamable;
import java.io.Serializable;
@@ -89,12 +90,17 @@ import java.util.zip.Adler32;
public class gnuAny
extends Any
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The value, returned by {@link #type()} if the value has been
* not intialized.
*/
protected static final TypeCode nullType =
- new primitiveTypeCode(TCKind.tk_null);
+ new PrimitiveTypeCode(TCKind.tk_null);
/**
* The Streamable, representing the value, held by this gnuAny.
@@ -133,11 +139,11 @@ public class gnuAny
*/
public gnuAny Clone()
{
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
out.setOrb(orb);
out.write_any(this);
- cdrBufInput in = new cdrBufInput(out.buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
in.setOrb(orb);
return (gnuAny) in.read_any();
}
@@ -148,18 +154,18 @@ public class gnuAny
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
- if (has instanceof universalHolder)
+ if (has instanceof GeneralHolder)
{
- universalHolder u = (universalHolder) has;
+ GeneralHolder u = (GeneralHolder) has;
return u.getInputStream();
}
else
{
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
out.setOrb(orb);
write_value(out);
- cdrBufInput in = new cdrBufInput(out.buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
in.setOrb(orb);
return in;
}
@@ -170,7 +176,7 @@ public class gnuAny
*/
public org.omg.CORBA.portable.OutputStream create_output_stream()
{
- cdrBufOutput stream = new cdrBufOutput();
+ BufferedCdrOutput stream = new BufferedCdrOutput();
stream.setOrb(orb);
return stream;
}
@@ -190,11 +196,11 @@ public class gnuAny
if (has.equals(((gnuAny) other).has))
return true;
- cdrBufOutput a = new cdrBufOutput();
+ BufferedCdrOutput a = new BufferedCdrOutput();
a.setOrb(orb);
write_value(a);
- cdrBufOutput b = new cdrBufOutput();
+ BufferedCdrOutput b = new BufferedCdrOutput();
b.setOrb(orb);
other.write_value(b);
@@ -215,7 +221,7 @@ public class gnuAny
{
Adler32 adler = new Adler32();
- cdrBufOutput a = new cdrBufOutput();
+ BufferedCdrOutput a = new BufferedCdrOutput();
a.setOrb(orb);
write_value(a);
@@ -250,7 +256,10 @@ public class gnuAny
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
@@ -315,7 +324,10 @@ public class gnuAny
}
catch (Exception ex)
{
- return new BAD_OPERATION("Value type expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Value type expected");
+ bad.minor = Minor.Any;
+ bad.initCause(ex);
+ throw bad;
}
}
@@ -682,7 +694,7 @@ public class gnuAny
else
has = new StringHolder(x);
- typecode = new stringTypeCode(TCKind.tk_string);
+ typecode = new StringTypeCode(TCKind.tk_string);
}
/** {@inheritDoc} */
@@ -769,40 +781,27 @@ public class gnuAny
}
else
{
- has = holderFactory.createHolder(a_type);
+ has = HolderLocator.createHolder(a_type);
if (has == null)
{
// Use the Universal Holder that reads till the end of stream.
// This works with the extract/insert pair of the typical
// Helper.
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
buffer.setOrb(orb);
- has = new universalHolder(buffer);
+ has = new GeneralHolder(buffer);
}
}
type(a_type);
- if (!(has instanceof universalHolder) &&
+ if (!(has instanceof GeneralHolder) &&
(kind == TCKind._tk_value_box))
{
// The streamable only contains operations for
// reading the value, not the value header.
Field vField = has.getClass().getField("value");
- BoxedValueHelper helper;
-
- try
- {
- Class helperClass =
- Class.forName(ObjectCreator.toHelperName(a_type.id()));
- helper = (BoxedValueHelper) helperClass.newInstance();
- }
- catch (Exception ex)
- {
- helper = null;
- }
-
- Object content = Vio.read(input, helper);
+ Object content = Vio.read(input, a_type.id());
vField.set(has, content);
}
else
@@ -811,6 +810,7 @@ public class gnuAny
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Any;
m.initCause(ex);
throw m;
}
@@ -823,7 +823,7 @@ public class gnuAny
return typecode;
else if (xKind >= 0)
{
- typecode = new primitiveTypeCode(TCKind.from_int(xKind));
+ typecode = new PrimitiveTypeCode(TCKind.from_int(xKind));
return typecode;
}
else
@@ -856,38 +856,43 @@ public class gnuAny
/**
* Check if the current value if the value of the given kind.
+ *
* @param kind a kind to check.
* @throws BAD_OPERATION if the value is not set of is different kind.
*/
protected void check(int kind)
- throws BAD_OPERATION
+ throws BAD_OPERATION
{
if (has == null)
- throw new BAD_OPERATION("value not set");
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("value not set");
+ bad.minor = Minor.Any;
+ throw bad;
+ }
if (xKind >= 0)
{
if (xKind != kind)
- if (!(
- xKind == TCKind._tk_alias &&
- has._type().kind().value() == kind
- )
- )
- throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
- " when stored " + typeNamer.nameIt(xKind)
- );
+ if (!(xKind == TCKind._tk_alias && has._type().kind().value() == kind))
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("Extracting "
+ + TypeKindNamer.nameIt(kind) + " when stored "
+ + TypeKindNamer.nameIt(xKind));
+ bad.minor = Minor.Any;
+ throw bad;
+ }
}
else
{
if (type().kind().value() != kind)
- if (!(
- type().kind().value() == TCKind._tk_alias &&
- has._type().kind().value() == kind
- )
- )
- throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
- " stored " + typeNamer.nameIt(type())
- );
+ if (!(type().kind().value() == TCKind._tk_alias && has._type().kind().value() == kind))
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("Extracting "
+ + TypeKindNamer.nameIt(kind) + " stored "
+ + TypeKindNamer.nameIt(type()));
+ bad.minor = Minor.Any;
+ throw bad;
+ }
}
}
diff --git a/gnu/CORBA/gnuCodecFactory.java b/gnu/CORBA/gnuCodecFactory.java
index 067de498c..8cf9ccf7b 100644
--- a/gnu/CORBA/gnuCodecFactory.java
+++ b/gnu/CORBA/gnuCodecFactory.java
@@ -83,7 +83,7 @@ public class gnuCodecFactory extends LocalObject implements CodecFactory
"supported by this factory."
);
- return new cdrEncapsCodec(orb,
+ return new CdrEncapsCodecImpl(orb,
new Version(for_encoding.major_version, for_encoding.minor_version)
);
}
diff --git a/gnu/CORBA/gnuContextList.java b/gnu/CORBA/gnuContextList.java
index 2a26437de..68584c389 100644
--- a/gnu/CORBA/gnuContextList.java
+++ b/gnu/CORBA/gnuContextList.java
@@ -53,7 +53,7 @@ public class gnuContextList
/**
* The collection, holding the actual list of strings.
*/
- corbaArrayList strings = new corbaArrayList();
+ CorbaList strings = new CorbaList();
/** {@inheritDoc} */
public void add(String name)
diff --git a/gnu/CORBA/gnuExceptionList.java b/gnu/CORBA/gnuExceptionList.java
index b684ec928..5f0c0c9f5 100644
--- a/gnu/CORBA/gnuExceptionList.java
+++ b/gnu/CORBA/gnuExceptionList.java
@@ -54,7 +54,7 @@ public class gnuExceptionList
/**
* A list to store the objects.
*/
- protected corbaArrayList list = new corbaArrayList();
+ protected CorbaList list = new CorbaList();
/** {@inheritDoc} */
public void add(TypeCode an_exception)
diff --git a/gnu/CORBA/gnuNVList.java b/gnu/CORBA/gnuNVList.java
index e436c332c..3645a3e8d 100644
--- a/gnu/CORBA/gnuNVList.java
+++ b/gnu/CORBA/gnuNVList.java
@@ -53,14 +53,14 @@ public class gnuNVList
/**
* The list of the named values.
*/
- protected corbaArrayList list;
+ protected CorbaList list;
/**
* Creates the list with the default initial size.
*/
public gnuNVList()
{
- list = new corbaArrayList();
+ list = new CorbaList();
}
/**
@@ -68,7 +68,7 @@ public class gnuNVList
*/
public gnuNVList(int initial_size)
{
- list = new corbaArrayList(initial_size);
+ list = new CorbaList(initial_size);
}
/** {@inheritDoc} */
diff --git a/gnu/CORBA/gnuRequest.java b/gnu/CORBA/gnuRequest.java
index 7d756eddb..5adf74129 100644
--- a/gnu/CORBA/gnuRequest.java
+++ b/gnu/CORBA/gnuRequest.java
@@ -38,12 +38,12 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.GIOP.RequestHeader;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import gnu.CORBA.Interceptor.gnuClientRequestInfo;
import gnu.CORBA.Poa.ORB_1_4;
@@ -54,6 +54,7 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.Bounds;
+import org.omg.CORBA.COMM_FAILURE;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
@@ -134,8 +135,8 @@ public class gnuRequest extends Request implements Cloneable
/**
* The empty byte array.
*/
- private static final binaryReply EMPTY =
- new binaryReply(null, new MessageHeader(), new byte[ 0 ]);
+ private static final RawReply EMPTY =
+ new RawReply(null, new MessageHeader(), new byte[ 0 ]);
/**
* The context holder for methods ctx(Context) and ctx().
@@ -222,7 +223,7 @@ public class gnuRequest extends Request implements Cloneable
* The request arguments in the case when they are directly written into the
* parameter buffer.
*/
- protected streamRequest m_parameter_buffer;
+ protected StreamBasedRequest m_parameter_buffer;
/**
* The array of slots.
@@ -294,8 +295,8 @@ public class gnuRequest extends Request implements Cloneable
orb = an_orb;
// Take the interceptor from the ORB.
- if (orb instanceof Restricted_ORB)
- m_interceptor = ((Restricted_ORB) orb).iClient;
+ if (orb instanceof OrbRestricted)
+ m_interceptor = ((OrbRestricted) orb).iClient;
if (m_interceptor != null && orb instanceof ORB_1_4)
{
@@ -332,12 +333,12 @@ public class gnuRequest extends Request implements Cloneable
* Get the parameter stream, where the invocation arguments should be written
* if they are written into the stream directly.
*/
- public streamRequest getParameterStream()
+ public StreamBasedRequest getParameterStream()
{
- m_parameter_buffer = new streamRequest();
+ m_parameter_buffer = new StreamBasedRequest();
m_parameter_buffer.request = this;
m_parameter_buffer.setVersion(ior.Internet.version);
- m_parameter_buffer.setCodeSet(cxCodeSet.negotiate(ior.Internet.CodeSets));
+ m_parameter_buffer.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
m_parameter_buffer.setOrb(orb);
m_parameter_buffer.setBigEndian(Big_endian);
@@ -345,7 +346,7 @@ public class gnuRequest extends Request implements Cloneable
// correctly.
if (ior.Internet.version.until_inclusive(1, 1))
{
- cdrBufOutput measure = new cdrBufOutput();
+ BufferedCdrOutput measure = new BufferedCdrOutput();
measure.setOffset(12);
if (m_rqh == null)
m_rqh = new gnu.CORBA.GIOP.v1_0.RequestHeader();
@@ -513,8 +514,8 @@ public class gnuRequest extends Request implements Cloneable
try
{
ObjectImpl impl = (ObjectImpl) e.forward;
- Simple_delegate delegate =
- (Simple_delegate) impl._get_delegate();
+ SimpleDelegate delegate =
+ (SimpleDelegate) impl._get_delegate();
ior = delegate.getIor();
}
catch (Exception ex)
@@ -714,14 +715,15 @@ public class gnuRequest extends Request implements Cloneable
/**
* Do the actual invocation. This implementation requires to set the IOR
* property ({@link #setIOR(IOR)} before calling this method.
- *
+ *
* @throws BAD_INV_ORDER, minor code 0, if the IOR has not been previously set
* or if the direct argument addition is mixed with the direct argument
* writing into the output stream.
- *
+ *
* @return the server response in binary form.
*/
- public synchronized binaryReply submit() throws ForwardRequest
+ public synchronized RawReply submit()
+ throws ForwardRequest
{
gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader();
@@ -742,26 +744,25 @@ public class gnuRequest extends Request implements Cloneable
m_interceptor.send_request(m_info);
// Prepare the submission.
- cdrBufOutput request_part = new cdrBufOutput();
+ BufferedCdrOutput request_part = new BufferedCdrOutput();
request_part.setOffset(header.getHeaderSize());
request_part.setVersion(header.version);
- request_part.setCodeSet(cxCodeSet.negotiate(ior.Internet.CodeSets));
+ request_part.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
request_part.setOrb(orb);
request_part.setBigEndian(header.isBigEndian());
// This also sets the stream encoding to the encoding, specified
// in the header.
rh.write(request_part);
-
+
if (m_args != null && m_args.count() > 0)
{
write_parameters(header, request_part);
if (m_parameter_buffer != null)
- throw new BAD_INV_ORDER("Please either add parameters or " +
- "write them into stream, but not both " + "at once."
- );
+ throw new BAD_INV_ORDER("Please either add parameters or "
+ + "write them into stream, but not both " + "at once.");
}
if (m_parameter_buffer != null)
@@ -789,12 +790,15 @@ public class gnuRequest extends Request implements Cloneable
{
// The BindException may be thrown under very heavy parallel
// load. For some time, just wait, exceptiong the socket to free.
- Open:
- for (int i = 0; i < PAUSE_STEPS; i++)
+ Open: for (int i = 0; i < PAUSE_STEPS; i++)
{
try
{
- socket = new Socket(ior.Internet.host, ior.Internet.port);
+ if (orb instanceof OrbFunctional)
+ socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
+ ior.Internet.host, ior.Internet.port);
+ else
+ socket = new Socket(ior.Internet.host, ior.Internet.port);
break Open;
}
catch (BindException ex)
@@ -816,9 +820,8 @@ public class gnuRequest extends Request implements Cloneable
}
if (socket == null)
- throw new NO_RESOURCES(ior.Internet.host + ":" + ior.Internet.port +
- " in use"
- );
+ throw new NO_RESOURCES(ior.Internet.host + ":" + ior.Internet.port
+ + " in use");
socket.setKeepAlive(true);
OutputStream socketOutput = socket.getOutputStream();
@@ -836,25 +839,26 @@ public class gnuRequest extends Request implements Cloneable
InputStream socketInput = socket.getInputStream();
response_header.read(socketInput);
- byte[] r = new byte[ response_header.message_size ];
- int n = 0;
- reading:
- while (n < r.length)
+ byte[] r;
+ if (orb instanceof OrbFunctional)
{
- n += socketInput.read(r, n, r.length - n);
+ OrbFunctional fo = (OrbFunctional) orb;
+ r = response_header.readMessage(socketInput, socket,
+ fo.TOUT_WHILE_READING, fo.TOUT_AFTER_RECEIVING);
}
- return new binaryReply(orb, response_header, r);
+ else
+ r = response_header.readMessage(socketInput, null, 0, 0);
+
+ return new RawReply(orb, response_header, r);
}
else
return EMPTY;
}
catch (IOException io_ex)
{
- MARSHAL m =
- new MARSHAL("Unable to open a socket at " + ior.Internet.host + ":" +
- ior.Internet.port, 10000 + ior.Internet.port,
- CompletionStatus.COMPLETED_NO
- );
+ COMM_FAILURE m = new COMM_FAILURE("Unable to open a socket at "
+ + ior.Internet.host + ":" + ior.Internet.port, 0xC9,
+ CompletionStatus.COMPLETED_NO);
m.initCause(io_ex);
throw m;
}
@@ -864,7 +868,7 @@ public class gnuRequest extends Request implements Cloneable
{
if (socket != null && !socket.isClosed())
{
- socket.setSoTimeout(Functional_ORB.TANDEM_REQUESTS);
+ socket.setSoTimeout(OrbFunctional.TANDEM_REQUESTS);
SocketRepository.put_socket(key, socket);
}
}
@@ -929,14 +933,15 @@ public class gnuRequest extends Request implements Cloneable
* Do actual invocation. This method recursively calls itself if the
* redirection is detected.
*/
- private void p_invoke() throws SystemException, ForwardRequest
+ private void p_invoke()
+ throws SystemException, ForwardRequest
{
- binaryReply response = submit();
+ RawReply response = submit();
if (m_rph == null)
m_rph = response.header.create_reply_header();
- cdrBufInput input = response.getStream();
+ BufferredCdrInput input = response.getStream();
input.setOrb(orb);
m_rph.read(input);
@@ -946,7 +951,7 @@ public class gnuRequest extends Request implements Cloneable
switch (m_rph.reply_status)
{
- case ReplyHeader.NO_EXCEPTION :
+ case ReplyHeader.NO_EXCEPTION:
NamedValue arg;
@@ -992,7 +997,7 @@ public class gnuRequest extends Request implements Cloneable
break;
- case ReplyHeader.SYSTEM_EXCEPTION :
+ case ReplyHeader.SYSTEM_EXCEPTION:
if (align)
{
input.align(8);
@@ -1000,7 +1005,8 @@ public class gnuRequest extends Request implements Cloneable
}
readExceptionId(input);
- m_sys_ex = ObjectCreator.readSystemException(input);
+ m_sys_ex = ObjectCreator.readSystemException(input,
+ m_rph.service_context);
m_environment.exception(m_sys_ex);
if (m_interceptor != null)
@@ -1008,7 +1014,7 @@ public class gnuRequest extends Request implements Cloneable
throw m_sys_ex;
- case ReplyHeader.USER_EXCEPTION :
+ case ReplyHeader.USER_EXCEPTION:
if (align)
{
input.align(8);
@@ -1020,7 +1026,7 @@ public class gnuRequest extends Request implements Cloneable
gnuAny exc = new gnuAny();
exc.setOrb(orb);
- exc.insert_Streamable(new streamReadyHolder(input));
+ exc.insert_Streamable(new StreamHolder(input));
UnknownUserException unuex = new UnknownUserException(exc);
m_environment.exception(unuex);
@@ -1030,8 +1036,8 @@ public class gnuRequest extends Request implements Cloneable
break;
- case ReplyHeader.LOCATION_FORWARD_PERM :
- case ReplyHeader.LOCATION_FORWARD :
+ case ReplyHeader.LOCATION_FORWARD_PERM:
+ case ReplyHeader.LOCATION_FORWARD:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
@@ -1043,8 +1049,7 @@ public class gnuRequest extends Request implements Cloneable
catch (IOException ex)
{
new MARSHAL("Cant read forwarding info", 5103,
- CompletionStatus.COMPLETED_NO
- );
+ CompletionStatus.COMPLETED_NO);
}
setIor(forwarded);
@@ -1058,17 +1063,16 @@ public class gnuRequest extends Request implements Cloneable
p_invoke();
return;
- default :
+ default:
throw new MARSHAL("Unknow reply status", 8100 + m_rph.reply_status,
- CompletionStatus.COMPLETED_NO
- );
+ CompletionStatus.COMPLETED_NO);
}
}
/**
* Read exception id without changing the stream pointer position.
*/
- void readExceptionId(cdrBufInput input)
+ void readExceptionId(BufferredCdrInput input)
{
input.mark(2048);
m_exception_id = input.read_string();
@@ -1084,7 +1088,7 @@ public class gnuRequest extends Request implements Cloneable
* @throws MARSHAL if the attempt to write the parameters has failde.
*/
protected void write_parameter_buffer(MessageHeader header,
- cdrBufOutput request_part
+ BufferedCdrOutput request_part
) throws MARSHAL
{
try
@@ -1097,7 +1101,9 @@ public class gnuRequest extends Request implements Cloneable
}
catch (IOException ex)
{
- throw new MARSHAL("Unable to write method arguments to CDR output.");
+ MARSHAL m = new MARSHAL("Unable to write method arguments to CDR output.");
+ m.minor = Minor.CDR;
+ throw m;
}
}
@@ -1110,7 +1116,7 @@ public class gnuRequest extends Request implements Cloneable
* @throws MARSHAL if the attempt to write the parameters has failde.
*/
protected void write_parameters(MessageHeader header,
- cdrBufOutput request_part
+ BufferedCdrOutput request_part
) throws MARSHAL
{
// Align after 1.2, but only once.
@@ -1161,7 +1167,7 @@ public class gnuRequest extends Request implements Cloneable
*/
public TaggedProfile effective_profile()
{
- cdrBufOutput buf = new cdrBufOutput(512);
+ BufferedCdrOutput buf = new BufferedCdrOutput(512);
buf.setOrb(orb);
ior.Internet.write(buf);
@@ -1176,7 +1182,7 @@ public class gnuRequest extends Request implements Cloneable
*/
public org.omg.CORBA.Object effective_target()
{
- return new IOR_contructed_object(orb, ior);
+ return new IorObject(orb, ior);
}
/**
@@ -1188,7 +1194,7 @@ public class gnuRequest extends Request implements Cloneable
if (id == TAG_CODE_SETS.value)
{
// Codesets are encoded separately.
- cdrBufOutput buf = new cdrBufOutput(512);
+ BufferedCdrOutput buf = new BufferedCdrOutput(512);
buf.setOrb(orb);
ior.Internet.CodeSets.write(buf);
@@ -1289,7 +1295,7 @@ public class gnuRequest extends Request implements Cloneable
return m_forwarding_target;
if (m_forward_ior != null)
- return new IOR_contructed_object(orb, m_forward_ior);
+ return new IorObject(orb, m_forward_ior);
else
return null;
}
diff --git a/gnu/CORBA/gnuValueHolder.java b/gnu/CORBA/gnuValueHolder.java
index 0b3826489..8263113ec 100644
--- a/gnu/CORBA/gnuValueHolder.java
+++ b/gnu/CORBA/gnuValueHolder.java
@@ -123,7 +123,7 @@ public class gnuValueHolder
try
{
Class helperClass =
- Class.forName(ObjectCreator.toHelperName(type.id()));
+ ObjectCreator.forName(ObjectCreator.toHelperName(type.id()));
helper = (BoxedValueHelper) helperClass.newInstance();
}
diff --git a/gnu/CORBA/interfaces/SocketFactory.java b/gnu/CORBA/interfaces/SocketFactory.java
new file mode 100644
index 000000000..7797dcbf9
--- /dev/null
+++ b/gnu/CORBA/interfaces/SocketFactory.java
@@ -0,0 +1,95 @@
+/* SocketFactory.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.interfaces;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * This class produces sockets for serving and submitting CORBA requests. The
+ * socket factory can be set using {@link gnuOrb.setSocketFactory()} for
+ * producting all sockets for that ORB. This is needed for using secure sockets,
+ * for implementing the desired timeout policies, for HTTP tunnels and in some
+ * other similar cases. While such functionality is provided by near all
+ * existing CORBA implementations, no standard mechanism is defined.
+ *
+ * The socket factory may need to put additional information to the IORs of the
+ * objects, released by the ORB. Because of this reason, this interface extends
+ * IORInterceptorOperations.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface SocketFactory
+{
+ /**
+ * The name of the ORB property that forces the ORB to use the socket
+ * factory class, the name of that (String) is the value of this property.
+ */
+ final String PROPERTY = "gnu.CORBA.SocketFactory";
+
+ /**
+ * Create a server socket that should serve remote invocations on the given
+ * port. The ORB may use this socket to serve either one or more objects.
+ *
+ * @param port the port, on that the socket should be listening for requests.
+ * The port policy can be controlled by {@link gnuPortManager}.
+ *
+ * @throws IOException if the socket cannot be created on the given port due
+ * any reasons. The ORB may try to open the socket on another port, calling
+ * this method with the different parameter.
+ */
+ ServerSocket createServerSocket(int port)
+ throws IOException;
+
+ /**
+ * Create a client socket that should send a request to the remote side. When
+ * returned, the socket should be opened and ready to communicate.
+ *
+ * @param port the port, on that the socket should be openend. The port is
+ * usually part of the internet profile.
+ *
+ * @throws IOException if the socket cannot be created on the given port due
+ * any reasons. The ORB may try to open the socket on another port, calling
+ * this method with the different parameter.
+ */
+ Socket createClientSocket(String host, int port)
+ throws IOException;
+
+}
diff --git a/gnu/CORBA/interfaces/gnuSocketFactory.java b/gnu/CORBA/interfaces/gnuSocketFactory.java
new file mode 100644
index 000000000..08057f5fa
--- /dev/null
+++ b/gnu/CORBA/interfaces/gnuSocketFactory.java
@@ -0,0 +1,95 @@
+/* gnuSocketFactory.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.CORBA.interfaces;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * This class produces sockets for serving and submitting CORBA requests. The
+ * socket factory can be set using {@link gnuOrb.setSocketFactory()} for
+ * producting all sockets for that ORB. This is needed for using secure sockets,
+ * for implementing the desired timeout policies, for HTTP tunnels and in some
+ * other similar cases. While such functionality is provided by near all
+ * existing CORBA implementations, no standard mechanism is defined.
+ *
+ * The socket factory may need to put additional information to the IORs of the
+ * objects, released by the ORB. Because of this reason, this interface extends
+ * IORInterceptorOperations.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface gnuSocketFactory
+{
+ /**
+ * The name of the ORB property that forces the ORB to use the socket
+ * factory class, the name of that (String) is the value of this property.
+ */
+ final String PROPERTY = "gnu.CORBA.SocketFactory";
+
+ /**
+ * Create a server socket that should serve remote invocations on the given
+ * port. The ORB may use this socket to serve either one or more objects.
+ *
+ * @param port the port, on that the socket should be listening for requests.
+ * The port policy can be controlled by {@link gnuPortManager}.
+ *
+ * @throws IOException if the socket cannot be created on the given port due
+ * any reasons. The ORB may try to open the socket on another port, calling
+ * this method with the different parameter.
+ */
+ ServerSocket createServerSocket(int port)
+ throws IOException;
+
+ /**
+ * Create a client socket that should send a request to the remote side. When
+ * returned, the socket should be opened and ready to communicate.
+ *
+ * @param port the port, on that the socket should be openend. The port is
+ * usually part of the internet profile.
+ *
+ * @throws IOException if the socket cannot be created on the given port due
+ * any reasons. The ORB may try to open the socket on another port, calling
+ * this method with the different parameter.
+ */
+ Socket createClientSocket(String host, int port)
+ throws IOException;
+
+}
diff --git a/gnu/CORBA/interfaces/package.html b/gnu/CORBA/interfaces/package.html
new file mode 100644
index 000000000..101475b2d
--- /dev/null
+++ b/gnu/CORBA/interfaces/package.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html -
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - gnu.CORBA.interfaces</title></head>
+
+<body>
+<p>This package contains Classpath specific interfaces that
+the user program may be forced to use in cases when no
+other, better solution of the problem is available. The
+existing classes and methods in this package should not
+be removed without the real need</p>
+</body>
+</html>
diff --git a/gnu/CORBA/aliasTypeCode.java b/gnu/CORBA/typecodes/AliasTypeCode.java
index 884663101..3cb8ebfb3 100644
--- a/gnu/CORBA/aliasTypeCode.java
+++ b/gnu/CORBA/typecodes/AliasTypeCode.java
@@ -1,4 +1,4 @@
-/* aliasTypeCode.java --
+/* AliasTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
@@ -47,9 +48,14 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class aliasTypeCode
- extends primitiveTypeCode
+public class AliasTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The typecode repository id.
*/
@@ -76,7 +82,7 @@ public class aliasTypeCode
*
* @param a_name the name of the newly created typecode.
*/
- public aliasTypeCode(TypeCode an_aliasFor, String an_id, String a_name)
+ public AliasTypeCode(TypeCode an_aliasFor, String an_id, String a_name)
{
super(TCKind.tk_alias);
aliasFor = an_aliasFor;
diff --git a/gnu/CORBA/primitiveArrayTypeCode.java b/gnu/CORBA/typecodes/ArrayTypeCode.java
index fc020bed7..bb798101a 100644
--- a/gnu/CORBA/primitiveArrayTypeCode.java
+++ b/gnu/CORBA/typecodes/ArrayTypeCode.java
@@ -1,4 +1,4 @@
-/* primitiveArrayTypeCode.java --
+/* ArrayTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
@@ -46,9 +47,15 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
* A TypeCode for arrays.
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class primitiveArrayTypeCode
- extends primitiveTypeCode
+public class ArrayTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+
/**
* The array components.
*/
@@ -67,10 +74,10 @@ public class primitiveArrayTypeCode
*
* @param array_of the sequence member type.
*/
- public primitiveArrayTypeCode(TCKind array_of)
+ public ArrayTypeCode(TCKind array_of)
{
super(TCKind.tk_sequence);
- of = new primitiveTypeCode(array_of);
+ of = new PrimitiveTypeCode(array_of);
}
/**
@@ -81,7 +88,7 @@ public class primitiveArrayTypeCode
* sequence of array).
* @param array_of the sequence member type.
*/
- public primitiveArrayTypeCode(TCKind this_type, TypeCode array_of)
+ public ArrayTypeCode(TCKind this_type, TypeCode array_of)
{
super(this_type);
of = array_of;
diff --git a/gnu/CORBA/fixedTypeCode.java b/gnu/CORBA/typecodes/FixedTypeCode.java
index eb610417b..c5fae63bd 100644
--- a/gnu/CORBA/fixedTypeCode.java
+++ b/gnu/CORBA/typecodes/FixedTypeCode.java
@@ -1,4 +1,4 @@
-/* fixedTypeCode.java --
+/* FixedTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import java.math.BigDecimal;
@@ -48,9 +49,15 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
* A typecode for CORBA <code>fixed</code>
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class fixedTypeCode
- extends primitiveTypeCode
+public class FixedTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+
/**
* The number of the used digits.
*/
@@ -64,7 +71,7 @@ public class fixedTypeCode
/**
* Creates the instance of the fixed type code.
*/
- public fixedTypeCode()
+ public FixedTypeCode()
{
super(TCKind.tk_fixed);
}
@@ -73,7 +80,7 @@ public class fixedTypeCode
* Creates the instance of the fixed type code,
* setting the digits and scale by example.
*/
- public fixedTypeCode(BigDecimal example)
+ public FixedTypeCode(BigDecimal example)
{
super(TCKind.tk_fixed);
if (example != null)
diff --git a/gnu/CORBA/generalTypeCode.java b/gnu/CORBA/typecodes/GeneralTypeCode.java
index 3b7914878..0a907844a 100644
--- a/gnu/CORBA/generalTypeCode.java
+++ b/gnu/CORBA/typecodes/GeneralTypeCode.java
@@ -1,4 +1,4 @@
-/* generalTypeCode.java --
+/* GeneralTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,9 +36,9 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import java.util.Arrays;
import java.util.BitSet;
@@ -56,9 +56,15 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class generalTypeCode
- extends primitiveTypeCode
+public class GeneralTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+
/**
* Indicates that the field value has not been previously set.
*/
@@ -87,21 +93,21 @@ public class generalTypeCode
/**
* Create a new instance, setting kind to the given kind.
- * @param kind
+ * @param a_kind the kind of the typecode being created.
*/
- public generalTypeCode(TCKind kind)
+ public GeneralTypeCode(TCKind a_kind)
{
- super(kind);
- if (!lengthAllowed.get(kind.value()))
+ super(a_kind);
+ if (!lengthAllowed.get(a_kind.value()))
len = UNSET;
}
/**
* Set this property.
*/
- public void setConcreteBase_type(TypeCode concrete_base_type)
+ public void setConcreteBase_type(TypeCode a_concrete_base_type)
{
- this.concrete_base_type = concrete_base_type;
+ this.concrete_base_type = a_concrete_base_type;
}
/**
@@ -115,9 +121,9 @@ public class generalTypeCode
/**
* Set this property.
*/
- public void setId(String id)
+ public void setId(String an_id)
{
- this.id = id;
+ this.id = an_id;
}
/**
@@ -132,9 +138,9 @@ public class generalTypeCode
/**
* Set this property.
*/
- public void setName(String name)
+ public void setName(String a_name)
{
- this.name = name;
+ this.name = a_name;
}
/**
@@ -179,8 +185,8 @@ public class generalTypeCode
if (kind() != other.kind())
return false;
- cdrBufOutput a = new cdrBufOutput(16);
- cdrBufOutput b = new cdrBufOutput(16);
+ BufferedCdrOutput a = new BufferedCdrOutput(16);
+ BufferedCdrOutput b = new BufferedCdrOutput(16);
a.write_TypeCode(this);
b.write_TypeCode(other);
diff --git a/gnu/CORBA/primitiveTypeCode.java b/gnu/CORBA/typecodes/PrimitiveTypeCode.java
index 4bf97d023..22d39a82c 100644
--- a/gnu/CORBA/primitiveTypeCode.java
+++ b/gnu/CORBA/typecodes/PrimitiveTypeCode.java
@@ -1,4 +1,4 @@
-/* primitiveTypeCode.java --
+/* PrimitiveTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
Copyright (C) 2005 Free Software Foundation, Inc.
@@ -37,17 +37,17 @@ 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 gnu.CORBA;
+package gnu.CORBA.typecodes;
import java.io.Serializable;
import org.omg.CORBA.Any;
-import org.omg.CORBA.IDLEntity;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.portable.IDLEntity;
/**
* An information about a primitive CORBA data type
@@ -60,16 +60,21 @@ import org.omg.CORBA.TypeCodePackage.Bounds;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class primitiveTypeCode
+public class PrimitiveTypeCode
extends TypeCode
implements IDLEntity, Serializable
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The kind of this TypeCode.
*/
protected final TCKind kind;
- public primitiveTypeCode(TCKind a_kind)
+ public PrimitiveTypeCode(TCKind a_kind)
{
kind = a_kind;
}
diff --git a/gnu/CORBA/recordTypeCode.java b/gnu/CORBA/typecodes/RecordTypeCode.java
index 8f2ecde7d..89f342546 100644
--- a/gnu/CORBA/recordTypeCode.java
+++ b/gnu/CORBA/typecodes/RecordTypeCode.java
@@ -1,4 +1,4 @@
-/* recordTypeCode.java --
+/* RecordTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,9 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
+import gnu.CORBA.CorbaList;
import org.omg.CORBA.Any;
import org.omg.CORBA.StructMember;
@@ -53,9 +55,14 @@ import org.omg.CORBA.ValueMember;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class recordTypeCode
- extends generalTypeCode
+public class RecordTypeCode
+ extends GeneralTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The individual field of the record.
*/
@@ -85,16 +92,16 @@ public class recordTypeCode
/**
* The members of this data structure.
*/
- protected corbaArrayList members = new corbaArrayList();
+ protected CorbaList members = new CorbaList();
private TypeCode discriminator_type;
private int default_index = UNSET;
/**
* Creates the type code of the given kind.
*/
- public recordTypeCode(TCKind kind)
+ public RecordTypeCode(TCKind a_kind)
{
- super(kind);
+ super(a_kind);
}
/**
diff --git a/gnu/CORBA/recursiveTypeCode.java b/gnu/CORBA/typecodes/RecursiveTypeCode.java
index 6bc672e6e..0e6ac375e 100644
--- a/gnu/CORBA/recursiveTypeCode.java
+++ b/gnu/CORBA/typecodes/RecursiveTypeCode.java
@@ -1,4 +1,4 @@
-/* recursiveTypeCode.java --
+/* RecursiveTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
@@ -44,9 +45,14 @@ import org.omg.CORBA.TCKind;
* The typecode, serving as a placeholder in defining
* typecodes, containing recursion.
*/
-public class recursiveTypeCode
- extends primitiveTypeCode
+public class RecursiveTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The id of the type for that this type serves as a
* placeholder.
@@ -60,7 +66,7 @@ public class recursiveTypeCode
* @param id the Id of the type for that this type serves as a
* placeholder.
*/
- public recursiveTypeCode(String an_id)
+ public RecursiveTypeCode(String an_id)
{
super(TCKind.tk_null);
the_id = an_id;
diff --git a/gnu/CORBA/stringTypeCode.java b/gnu/CORBA/typecodes/StringTypeCode.java
index 27aa119f3..2d1689b45 100644
--- a/gnu/CORBA/stringTypeCode.java
+++ b/gnu/CORBA/typecodes/StringTypeCode.java
@@ -1,4 +1,4 @@
-/* stringTypeCode.java --
+/* StringTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
@@ -44,9 +45,14 @@ import org.omg.CORBA.TCKind;
* The typecode for string and wide string.
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class stringTypeCode
- extends primitiveTypeCode
+public class StringTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
private int len = 0;
/**
@@ -55,7 +61,7 @@ public class stringTypeCode
* @param a_kind a kind of this typecode, normally
* either tk_string or tk_wstring.
*/
- public stringTypeCode(TCKind a_kind)
+ public StringTypeCode(TCKind a_kind)
{
super(a_kind);
}
diff --git a/gnu/CORBA/typecodes/package.html b/gnu/CORBA/typecodes/package.html
new file mode 100644
index 000000000..891b3b965
--- /dev/null
+++ b/gnu/CORBA/typecodes/package.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - gnu.CORBA.typecodes</title></head>
+
+<body>
+ Contains GNU Classpath specific typecode definitions.
+
+ @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html>
+
diff --git a/gnu/classpath/ByteArray.java b/gnu/classpath/ByteArray.java
index ec1646b64..6307b8abd 100644
--- a/gnu/classpath/ByteArray.java
+++ b/gnu/classpath/ByteArray.java
@@ -1,25 +1,22 @@
/* ByteArray.java -- wrapper around a byte array, with nice toString output.
Copyright (C) 2005 Free Software Foundation, Inc.
-This file is a part of GNU Classpath.
+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 of the License, or (at
-your option) any later version.
+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; if not, write to the
-
- Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301
- USA
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -29,14 +26,14 @@ 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. */
+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 gnu.classpath;
diff --git a/gnu/classpath/jdwp/event/filters/StepFilter.java b/gnu/classpath/jdwp/event/filters/StepFilter.java
index 75753cda0..d029e61e1 100644
--- a/gnu/classpath/jdwp/event/filters/StepFilter.java
+++ b/gnu/classpath/jdwp/event/filters/StepFilter.java
@@ -66,7 +66,7 @@ public class StepFilter
public StepFilter (ThreadId tid, int size, int depth)
throws InvalidThreadException
{
- if (tid == null | tid.getReference().get () == null)
+ if (tid.getReference().get () == null)
throw new InvalidThreadException (tid.getId ());
_tid = tid;
diff --git a/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java b/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
index 039b43721..83ad40946 100644
--- a/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
+++ b/gnu/classpath/jdwp/event/filters/ThreadOnlyFilter.java
@@ -66,7 +66,7 @@ public class ThreadOnlyFilter
public ThreadOnlyFilter (ThreadId tid)
throws InvalidThreadException
{
- if (tid == null | tid.getReference().get () == null)
+ if (tid.getReference().get () == null)
throw new InvalidThreadException (tid.getId ());
_tid = tid;
diff --git a/gnu/java/awt/peer/gtk/GdkFontMetrics.java b/gnu/java/awt/peer/gtk/GdkFontMetrics.java
index 7a439e83a..c79f403ed 100644
--- a/gnu/java/awt/peer/gtk/GdkFontMetrics.java
+++ b/gnu/java/awt/peer/gtk/GdkFontMetrics.java
@@ -1,5 +1,5 @@
/* GdkFontMetrics.java
- Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -62,15 +62,28 @@ public class GdkFontMetrics extends FontMetrics
static final int TEXT_METRICS_HEIGHT = 3;
static final int TEXT_METRICS_X_ADVANCE = 4;
static final int TEXT_METRICS_Y_ADVANCE = 5;
-
-
+
+ /**
+ * Makes sure to return a Font based on the given Font that has as
+ * peer a GdkFontPeer. Used in the initializer.
+ */
+ private static Font initFont(Font font)
+ {
+ if (font == null)
+ return new Font("Dialog", Font.PLAIN, 12);
+ else if (font.getPeer() instanceof GdkFontPeer)
+ return font;
+ else
+ {
+ ClasspathToolkit toolkit;
+ toolkit = (ClasspathToolkit) Toolkit.getDefaultToolkit();
+ return toolkit.getFont(font.getName(), font.getAttributes());
+ }
+ }
+
public GdkFontMetrics (Font font)
{
- super (font.getPeer() instanceof GdkFontPeer
- ? font
- : ((ClasspathToolkit)(Toolkit.getDefaultToolkit ()))
- .getFont (font.getName(), font.getAttributes ()));
-
+ super(initFont(font));
peer = (GdkFontPeer) this.font.getPeer();
font_metrics = new int[5];
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
index 7d8531bf1..cd3769736 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -68,7 +68,7 @@ public class GdkGraphics extends Graphics
Color color, xorColor;
GtkComponentPeer component;
- Font font;
+ Font font = new Font ("Dialog", Font.PLAIN, 12);
Rectangle clip;
GtkImage image;
@@ -88,6 +88,8 @@ public class GdkGraphics extends Graphics
color = g.color;
xorColor = g.xorColor;
font = g.font;
+ if (font == null)
+ font = new Font ("Dialog", Font.PLAIN, 12);
clip = new Rectangle (g.clip);
component = g.component;
@@ -115,9 +117,6 @@ public class GdkGraphics extends Graphics
GdkGraphics (GtkComponentPeer component)
{
this.component = component;
- font = component.awtComponent.getFont ();
- if (font == null)
- font = new Font ("Dialog", Font.PLAIN, 12);
color = Color.black;
if (component.isRealized ())
@@ -380,7 +379,8 @@ public class GdkGraphics extends Graphics
public void setFont (Font font)
{
- this.font = font;
+ if (font != null)
+ this.font = font;
}
native void setFunction (int gdk_func);
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
index 687c0c109..c9ed30126 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
@@ -154,7 +154,7 @@ public class GdkGraphics2D extends Graphics2D
public Graphics create(int x, int y, int width, int height)
{
- return new GdkGraphics2D(width, height);
+ return new GdkGraphics2D(this, x, y, width, height);
}
private void fail_g2d ()
@@ -209,6 +209,13 @@ public class GdkGraphics2D extends Graphics2D
stateStack = new Stack();
}
+ GdkGraphics2D(GdkGraphics2D g, int x, int y, int widht, int height)
+ {
+ this(g);
+ translate(x, y);
+ clipRect(0, 0, widht, height);
+ }
+
GdkGraphics2D(int width, int height)
{
if (!GtkToolkit.useGraphics2D ())
@@ -966,7 +973,10 @@ public class GdkGraphics2D extends Graphics2D
public Shape getClip()
{
- return clip.getBounds2D(); //getClipInDevSpace();
+ if (clip == null)
+ return null;
+ else
+ return clip.getBounds2D(); //getClipInDevSpace();
}
public Rectangle getClipBounds()
@@ -1065,8 +1075,9 @@ public class GdkGraphics2D extends Graphics2D
public void clearRect(int x, int y, int width, int height)
{
- cairoSetRGBAColor(bg.getRed() / 255.0, bg.getGreen() / 255.0,
- bg.getBlue() / 255.0, 1.0);
+ if (bg != null)
+ cairoSetRGBAColor(bg.getRed() / 255.0, bg.getGreen() / 255.0,
+ bg.getBlue() / 255.0, 1.0);
cairoNewPath();
cairoRectangle(x, y, width, height);
cairoFill();
@@ -1391,7 +1402,8 @@ public class GdkGraphics2D extends Graphics2D
public void copyArea(int x, int y, int width, int height, int dx, int dy)
{
- throw new java.lang.UnsupportedOperationException();
+ GdkGraphics2D g = (GdkGraphics2D) create(x, y, width, height);
+ gdkDrawDrawable(g, x + dx, y + dy);
}
public void drawArc(int x, int y, int width, int height, int startAngle,
@@ -1624,6 +1636,11 @@ public class GdkGraphics2D extends Graphics2D
public void setFont(Font f)
{
+ // Sun's JDK does not throw NPEs, instead it leaves the current setting
+ // unchanged. So do we.
+ if (f == null)
+ return;
+
if (f.getPeer() instanceof GdkFontPeer)
font = f;
else
diff --git a/gnu/java/awt/peer/gtk/GdkTextLayout.java b/gnu/java/awt/peer/gtk/GdkTextLayout.java
index ff51745f2..c3ae581b1 100644
--- a/gnu/java/awt/peer/gtk/GdkTextLayout.java
+++ b/gnu/java/awt/peer/gtk/GdkTextLayout.java
@@ -388,10 +388,7 @@ public class GdkTextLayout
throw new Error("not implemented");
}
- public Shape getOutline (AffineTransform tx)
- {
- throw new Error("not implemented");
- }
+ public native Shape getOutline (AffineTransform tx);
public Shape getVisualHighlightShape (TextHitInfo firstEndpoint,
TextHitInfo secondEndpoint,
diff --git a/gnu/java/awt/peer/gtk/GtkChoicePeer.java b/gnu/java/awt/peer/gtk/GtkChoicePeer.java
index c14074439..ed7dc74d2 100644
--- a/gnu/java/awt/peer/gtk/GtkChoicePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkChoicePeer.java
@@ -131,9 +131,6 @@ public class GtkChoicePeer extends GtkComponentPeer
protected void postChoiceItemEvent (String label, int stateChange)
{
- // Must set our state before notifying listeners
- if (stateChange == ItemEvent.SELECTED)
- ((Choice) awtComponent).select (label);
postItemEvent (label, stateChange);
}
}
diff --git a/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
index cfb54d6e9..f5ba3ad2c 100644
--- a/gnu/java/awt/peer/gtk/GtkDialogPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
@@ -44,6 +44,10 @@ import java.awt.Rectangle;
import java.awt.event.PaintEvent;
import java.awt.peer.DialogPeer;
+import javax.swing.JDialog;
+import javax.swing.JPopupMenu;
+import javax.swing.JToolTip;
+
public class GtkDialogPeer extends GtkWindowPeer
implements DialogPeer
{
@@ -82,11 +86,28 @@ public class GtkDialogPeer extends GtkWindowPeer
void create ()
{
- // Create a decorated dialog window.
- create (GDK_WINDOW_TYPE_HINT_DIALOG,
- !((Dialog) awtComponent).isUndecorated ());
-
Dialog dialog = (Dialog) awtComponent;
+ int type = GDK_WINDOW_TYPE_HINT_DIALOG;
+
+ if (dialog instanceof JDialog)
+ {
+ Class heavyWeightClass;
+ try
+ {
+ heavyWeightClass = Class.forName("javax.swing.Popup$JWindowPopup");
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new AssertionError(e);
+ }
+
+ if (dialog.getClass() == heavyWeightClass
+ || ((JDialog) dialog).getContentPane() instanceof JToolTip)
+ type = GDK_WINDOW_TYPE_HINT_MENU;
+ }
+
+ // Create a decorated dialog window.
+ create (type, !((Dialog) awtComponent).isUndecorated ());
gtkWindowSetModal (dialog.isModal ());
setTitle (dialog.getTitle ());
diff --git a/gnu/java/awt/peer/qt/QtToolkit.java b/gnu/java/awt/peer/qt/QtToolkit.java
index 54f4888cf..591b52803 100644
--- a/gnu/java/awt/peer/qt/QtToolkit.java
+++ b/gnu/java/awt/peer/qt/QtToolkit.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package gnu.java.awt.peer.qt;
+import gnu.classpath.Configuration;
import gnu.java.awt.EmbeddedWindow;
import gnu.java.awt.peer.ClasspathFontPeer;
import gnu.java.awt.peer.EmbeddedWindowPeer;
@@ -135,7 +136,8 @@ public class QtToolkit extends ClasspathToolkit
{
eventQueue = new EventQueue();
repaintThread = new QtRepaintThread();
- System.loadLibrary("qtpeer");
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("qtpeer");
String theme = null;
try
diff --git a/gnu/java/net/LineInputStream.java b/gnu/java/net/LineInputStream.java
index 5ca068618..81a3c7d1f 100644
--- a/gnu/java/net/LineInputStream.java
+++ b/gnu/java/net/LineInputStream.java
@@ -1,5 +1,5 @@
/* LineInputStream.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.net;
+import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FilterInputStream;
import java.io.IOException;
@@ -91,7 +92,8 @@ public class LineInputStream
buf = new ByteArrayOutputStream();
this.encoding = encoding;
eof = false;
- blockReads = in.markSupported();
+ // If it is already buffered, additional buffering gains nothing.
+ blockReads = !(in instanceof BufferedInputStream) && in.markSupported();
}
/**
@@ -109,11 +111,12 @@ public class LineInputStream
if (blockReads)
{
// Use mark and reset to read chunks of bytes
- final int MIN_LENGTH = 1024;
+ final int MAX_LENGTH = 1024;
int len, pos;
-
+
len = in.available();
- len = (len < MIN_LENGTH) ? MIN_LENGTH : len;
+ if (len == 0 || len > MAX_LENGTH)
+ len = MAX_LENGTH;
byte[] b = new byte[len];
in.mark(len);
// Read into buffer b
diff --git a/gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java b/gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java
deleted file mode 100644
index 680e45d3e..000000000
--- a/gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Authenticator.java --ByteArrayResponseBodyReader.java --
- Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.net.protocol.http;
-
-/**
- * Simple response body reader that stores content in a byte array.
- *
- * @author Chris Burdess (dog@gnu.org)
- */
-public class ByteArrayResponseBodyReader
- implements ResponseBodyReader
-{
-
- /**
- * The content.
- */
- protected byte[] content;
-
- /**
- * The position in the content at which the next write will occur.
- */
- protected int pos;
-
- /**
- * The length of the buffer.
- */
- protected int len;
-
- /**
- * Constructs a new byte array response body reader.
- */
- public ByteArrayResponseBodyReader()
- {
- this(4096);
- }
-
- /**
- * Constructs a new byte array response body reader with the specified
- * initial buffer size.
- * @param size the initial buffer size
- */
- public ByteArrayResponseBodyReader(int size)
- {
- content = new byte[size];
- pos = len = 0;
- }
-
- /**
- * This reader accepts all responses.
- */
- public boolean accept(Request request, Response response)
- {
- return true;
- }
-
- public void read(byte[] buffer, int offset, int length)
- {
- int l = length - offset;
- if (pos + l > content.length)
- {
- byte[] tmp = new byte[content.length * 2];
- System.arraycopy(content, 0, tmp, 0, pos);
- content = tmp;
- }
- System.arraycopy(buffer, offset, content, pos, l);
- pos += l;
- len = pos;
- }
-
- public void close()
- {
- pos = 0;
- }
-
- /**
- * Retrieves the content of this reader as a byte array.
- * The size of the returned array is the number of bytes read.
- */
- public byte[] toByteArray()
- {
- byte[] ret = new byte[len];
- System.arraycopy(content, 0, ret, 0, len);
- return ret;
- }
-
-}
-
diff --git a/gnu/java/net/protocol/http/ChunkedInputStream.java b/gnu/java/net/protocol/http/ChunkedInputStream.java
index c0706b708..a4487d146 100644
--- a/gnu/java/net/protocol/http/ChunkedInputStream.java
+++ b/gnu/java/net/protocol/http/ChunkedInputStream.java
@@ -110,7 +110,7 @@ public class ChunkedInputStream
// Read chunk header
int c, last = 0;
boolean seenSemi = false;
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
do
{
c = in.read();
diff --git a/gnu/java/net/protocol/http/Cookie.java b/gnu/java/net/protocol/http/Cookie.java
index 45e2f733f..0be7a097e 100644
--- a/gnu/java/net/protocol/http/Cookie.java
+++ b/gnu/java/net/protocol/http/Cookie.java
@@ -139,7 +139,7 @@ public class Cookie
public String toString(boolean showPath, boolean showDomain)
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(name);
buf.append('=');
buf.append(value);
diff --git a/gnu/java/net/protocol/http/HTTPConnection.java b/gnu/java/net/protocol/http/HTTPConnection.java
index 6d9f447a2..573a7918d 100644
--- a/gnu/java/net/protocol/http/HTTPConnection.java
+++ b/gnu/java/net/protocol/http/HTTPConnection.java
@@ -41,10 +41,6 @@ package gnu.java.net.protocol.http;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.java.net.EmptyX509TrustManager;
-import gnu.java.net.protocol.http.event.ConnectionEvent;
-import gnu.java.net.protocol.http.event.ConnectionListener;
-import gnu.java.net.protocol.http.event.RequestEvent;
-import gnu.java.net.protocol.http.event.RequestListener;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -57,6 +53,7 @@ import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -131,8 +128,6 @@ public class HTTPConnection
*/
protected int minorVersion;
- private final List connectionListeners;
- private final List requestListeners;
private final List handshakeCompletedListeners;
/**
@@ -165,6 +160,12 @@ public class HTTPConnection
*/
protected CookieManager cookieManager;
+
+ /**
+ * The pool that this connection is a member of (if any).
+ */
+ private LinkedHashMap pool;
+
/**
* Creates a new HTTP connection.
* @param hostname the name of the host to connect to
@@ -236,8 +237,6 @@ public class HTTPConnection
this.connectionTimeout = connectionTimeout;
this.timeout = timeout;
majorVersion = minorVersion = 1;
- connectionListeners = new ArrayList(4);
- requestListeners = new ArrayList(4);
handshakeCompletedListeners = new ArrayList(2);
}
@@ -332,6 +331,73 @@ public class HTTPConnection
}
/**
+ * The number of times this HTTPConnection has be used via keep-alive.
+ */
+ int useCount;
+
+ /**
+ * Generates a key for connections in the connection pool.
+ *
+ * @param h the host name.
+ * @param p the port.
+ * @param sec true if using https.
+ *
+ * @return the key.
+ */
+ static Object getPoolKey(String h, int p, boolean sec)
+ {
+ StringBuilder buf = new StringBuilder(sec ? "https://" : "http://");
+ buf.append(h);
+ buf.append(':');
+ buf.append(p);
+ return buf.toString();
+ }
+
+ /**
+ * Set the connection pool that this HTTPConnection is a member of.
+ * If left unset or set to null, it will not be a member of any pool
+ * and will not be a candidate for reuse.
+ *
+ * @param p the pool.
+ */
+ void setPool(LinkedHashMap p)
+ {
+ pool = p;
+ }
+
+ /**
+ * Signal that this HTTPConnection is no longer needed and can be
+ * returned to the connection pool.
+ *
+ */
+ void release()
+ {
+ if (pool != null)
+ {
+ synchronized (pool)
+ {
+ useCount++;
+ Object key = HTTPConnection.getPoolKey(hostname, port, secure);
+ pool.put(key, this);
+ while (pool.size() >= HTTPURLConnection.maxConnections)
+ {
+ // maxConnections must always be >= 1
+ Object lru = pool.keySet().iterator().next();
+ HTTPConnection c = (HTTPConnection)pool.remove(lru);
+ try
+ {
+ c.closeConnection();
+ }
+ catch (IOException ioe)
+ {
+ // Ignore it. We are just cleaning up.
+ }
+ }
+ }
+ }
+ }
+
+ /**
* Creates a new request using this connection.
* @param method the HTTP method to invoke
* @param path the URI-escaped RFC2396 <code>abs_path</code> with
@@ -367,7 +433,7 @@ public class HTTPConnection
Cookie[] cookies = cookieManager.getCookies(hostname, secure, path);
if (cookies != null && cookies.length > 0)
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append("$Version=1");
for (int i = 0; i < cookies.length; i++)
{
@@ -378,7 +444,6 @@ public class HTTPConnection
ret.setHeader("Cookie", buf.toString());
}
}
- fireRequestEvent(RequestEvent.REQUEST_CREATED, ret);
return ret;
}
@@ -388,14 +453,7 @@ public class HTTPConnection
public void close()
throws IOException
{
- try
- {
- closeConnection();
- }
- finally
- {
- fireConnectionEvent(ConnectionEvent.CONNECTION_CLOSED);
- }
+ closeConnection();
}
/**
@@ -534,7 +592,7 @@ public class HTTPConnection
*/
protected String getURI()
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append(secure ? "https://" : "http://");
buf.append(hostname);
if (secure)
@@ -584,84 +642,6 @@ public class HTTPConnection
// -- Events --
- public void addConnectionListener(ConnectionListener l)
- {
- synchronized (connectionListeners)
- {
- connectionListeners.add(l);
- }
- }
-
- public void removeConnectionListener(ConnectionListener l)
- {
- synchronized (connectionListeners)
- {
- connectionListeners.remove(l);
- }
- }
-
- protected void fireConnectionEvent(int type)
- {
- ConnectionEvent event = new ConnectionEvent(this, type);
- ConnectionListener[] l = null;
- synchronized (connectionListeners)
- {
- l = new ConnectionListener[connectionListeners.size()];
- connectionListeners.toArray(l);
- }
- for (int i = 0; i < l.length; i++)
- {
- switch (type)
- {
- case ConnectionEvent.CONNECTION_CLOSED:
- l[i].connectionClosed(event);
- break;
- }
- }
- }
-
- public void addRequestListener(RequestListener l)
- {
- synchronized (requestListeners)
- {
- requestListeners.add(l);
- }
- }
-
- public void removeRequestListener(RequestListener l)
- {
- synchronized (requestListeners)
- {
- requestListeners.remove(l);
- }
- }
-
- protected void fireRequestEvent(int type, Request request)
- {
- RequestEvent event = new RequestEvent(this, type, request);
- RequestListener[] l = null;
- synchronized (requestListeners)
- {
- l = new RequestListener[requestListeners.size()];
- requestListeners.toArray(l);
- }
- for (int i = 0; i < l.length; i++)
- {
- switch (type)
- {
- case RequestEvent.REQUEST_CREATED:
- l[i].requestCreated(event);
- break;
- case RequestEvent.REQUEST_SENDING:
- l[i].requestSent(event);
- break;
- case RequestEvent.REQUEST_SENT:
- l[i].requestSent(event);
- break;
- }
- }
- }
-
void addHandshakeCompletedListener(HandshakeCompletedListener l)
{
synchronized (handshakeCompletedListeners)
diff --git a/gnu/java/net/protocol/http/HTTPURLConnection.java b/gnu/java/net/protocol/http/HTTPURLConnection.java
index 9f2055fe6..d5da7d61a 100644
--- a/gnu/java/net/protocol/http/HTTPURLConnection.java
+++ b/gnu/java/net/protocol/http/HTTPURLConnection.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.java.net.protocol.http;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -75,7 +74,8 @@ public class HTTPURLConnection
/**
* Pool of reusable connections, used if keepAlive is true.
*/
- private static final Map connectionPool = new LinkedHashMap();
+ private static final LinkedHashMap connectionPool = new LinkedHashMap();
+ static int maxConnections;
/*
* The underlying connection.
@@ -87,7 +87,6 @@ public class HTTPURLConnection
int proxyPort;
String agent;
boolean keepAlive;
- int maxConnections;
private Request request;
private Headers requestHeaders;
@@ -95,8 +94,8 @@ public class HTTPURLConnection
private boolean requestMethodSetExplicitly;
private Response response;
- private ByteArrayInputStream responseSink;
- private ByteArrayInputStream errorSink;
+ private InputStream responseSink;
+ private InputStream errorSink;
private HandshakeCompletedEvent handshakeEvent;
@@ -202,34 +201,59 @@ public class HTTPURLConnection
}
connection.setProxy(proxyHostname, proxyPort);
}
- request = connection.newRequest(method, file);
- if (!keepAlive)
- {
- request.setHeader("Connection", "close");
- }
- if (agent != null)
- {
- request.setHeader("User-Agent", agent);
- }
- request.getHeaders().putAll(requestHeaders);
- if (requestSink != null)
+ try
{
- byte[] content = requestSink.toByteArray();
- RequestBodyWriter writer = new ByteArrayRequestBodyWriter(content);
- request.setRequestBodyWriter(writer);
+ request = connection.newRequest(method, file);
+ if (!keepAlive)
+ {
+ request.setHeader("Connection", "close");
+ }
+ if (agent != null)
+ {
+ request.setHeader("User-Agent", agent);
+ }
+ request.getHeaders().putAll(requestHeaders);
+ if (requestSink != null)
+ {
+ byte[] content = requestSink.toByteArray();
+ RequestBodyWriter writer = new ByteArrayRequestBodyWriter(content);
+ request.setRequestBodyWriter(writer);
+ }
+ if (creds != null)
+ {
+ request.setAuthenticator(new Authenticator() {
+ public Credentials getCredentials(String realm, int attempts)
+ {
+ return (attempts < 2) ? creds : null;
+ }
+ });
+ }
+ response = request.dispatch();
}
- ByteArrayResponseBodyReader reader = new ByteArrayResponseBodyReader();
- request.setResponseBodyReader(reader);
- if (creds != null)
+ catch (IOException ioe)
{
- request.setAuthenticator(new Authenticator() {
- public Credentials getCredentials(String realm, int attempts)
+ if (connection.useCount > 0)
+ {
+ // Connection re-use failed: Try a new connection.
+ try
+ {
+ connection.close();
+ }
+ catch (IOException _)
+ {
+ // Ignore.
+ }
+ connection = null;
+ retry = true;
+ continue;
+ }
+ else
{
- return (attempts < 2) ? creds : null;
+ // First time the connection was used: Hard failure.
+ throw ioe;
}
- });
}
- response = request.dispatch();
+
if (response.getCodeClass() == 3 && getInstanceFollowRedirects())
{
// Follow redirect
@@ -307,7 +331,8 @@ public class HTTPURLConnection
}
else
{
- responseSink = new ByteArrayInputStream(reader.toByteArray ());
+ responseSink = response.getBody();
+
if (response.getCode() == 404)
{
errorSink = responseSink;
@@ -328,27 +353,14 @@ public class HTTPURLConnection
HTTPConnection connection;
if (keepAlive)
{
- StringBuffer buf = new StringBuffer(secure ? "https://" : "http://");
- buf.append(Thread.currentThread().hashCode());
- buf.append('@');
- buf.append(host);
- buf.append(':');
- buf.append(port);
- String key = buf.toString();
+ Object key = HTTPConnection.getPoolKey(host, port, secure);
synchronized (connectionPool)
{
- connection = (HTTPConnection) connectionPool.get(key);
+ connection = (HTTPConnection) connectionPool.remove(key);
if (connection == null)
{
connection = new HTTPConnection(host, port, secure);
- // Good housekeeping
- if (connectionPool.size() == maxConnections)
- {
- // maxConnections must always be >= 1
- Object lru = connectionPool.keySet().iterator().next();
- connectionPool.remove(lru);
- }
- connectionPool.put(key, connection);
+ connection.setPool(connectionPool);
}
}
}
@@ -502,9 +514,9 @@ public class HTTPURLConnection
return null;
}
}
- Map headers = response.getHeaders();
- Map ret = new LinkedHashMap();
- ret.put("", Collections.singletonList(getStatusLine(response)));
+ Headers headers = response.getHeaders();
+ LinkedHashMap ret = new LinkedHashMap();
+ ret.put(null, Collections.singletonList(getStatusLine(response)));
for (Iterator i = headers.entrySet().iterator(); i.hasNext(); )
{
Map.Entry entry = (Map.Entry) i.next();
@@ -512,7 +524,7 @@ public class HTTPURLConnection
String value = (String) entry.getValue();
ret.put(key, Collections.singletonList(value));
}
- return ret;
+ return Collections.unmodifiableMap(ret);
}
String getStatusLine(Response response)
diff --git a/gnu/java/net/protocol/http/Headers.java b/gnu/java/net/protocol/http/Headers.java
index 847ebefc1..9306fc411 100644
--- a/gnu/java/net/protocol/http/Headers.java
+++ b/gnu/java/net/protocol/http/Headers.java
@@ -60,7 +60,7 @@ import java.util.Set;
* @author Chris Burdess (dog@gnu.org)
*/
public class Headers
- implements Map
+ extends LinkedHashMap
{
static final DateFormat dateFormat = new HTTPDateFormat();
@@ -143,36 +143,18 @@ public class Headers
}
- private LinkedHashMap headers;
-
public Headers()
{
- headers = new LinkedHashMap();
- }
-
- public int size()
- {
- return headers.size();
- }
-
- public boolean isEmpty()
- {
- return headers.isEmpty();
}
public boolean containsKey(Object key)
{
- return headers.containsKey(new Header((String) key));
- }
-
- public boolean containsValue(Object value)
- {
- return headers.containsValue(value);
+ return super.containsKey(new Header((String) key));
}
public Object get(Object key)
{
- return headers.get(new Header((String) key));
+ return super.get(new Header((String) key));
}
/**
@@ -180,7 +162,7 @@ public class Headers
*/
public String getValue(String header)
{
- return (String) headers.get(new Header(header));
+ return (String) super.get(new Header(header));
}
/**
@@ -205,6 +187,27 @@ public class Headers
}
/**
+ * Returns the value of the specified header as a long, or -1 if the
+ * header is not present or cannot be parsed as a long.
+ */
+ public long getLongValue(String header)
+ {
+ String val = getValue(header);
+ if (val == null)
+ {
+ return -1;
+ }
+ try
+ {
+ return Long.parseLong(val);
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ return -1;
+ }
+
+ /**
* Returns the value of the specified header as a date,
* or <code>null</code> if the header is not present or not a date.
*/
@@ -227,12 +230,12 @@ public class Headers
public Object put(Object key, Object value)
{
- return headers.put(new Header((String) key), value);
+ return super.put(new Header((String) key), value);
}
public Object remove(Object key)
{
- return headers.remove(new Header((String) key));
+ return super.remove(new Header((String) key));
}
public void putAll(Map t)
@@ -241,18 +244,13 @@ public class Headers
{
String key = (String) i.next();
String value = (String) t.get(key);
- headers.put(new Header(key), value);
+ put(key, value);
}
}
- public void clear()
- {
- headers.clear();
- }
-
public Set keySet()
{
- Set keys = headers.keySet();
+ Set keys = super.keySet();
Set ret = new LinkedHashSet();
for (Iterator i = keys.iterator(); i.hasNext(); )
{
@@ -261,14 +259,9 @@ public class Headers
return ret;
}
- public Collection values()
- {
- return headers.values();
- }
-
public Set entrySet()
{
- Set entries = headers.entrySet();
+ Set entries = super.entrySet();
Set ret = new LinkedHashSet();
for (Iterator i = entries.iterator(); i.hasNext(); )
{
@@ -278,16 +271,6 @@ public class Headers
return ret;
}
- public boolean equals(Object other)
- {
- return headers.equals(other);
- }
-
- public int hashCode()
- {
- return headers.hashCode();
- }
-
/**
* Parse the specified input stream, adding headers to this collection.
*/
@@ -298,7 +281,7 @@ public class Headers
(LineInputStream) in : new LineInputStream(in);
String name = null;
- StringBuffer value = new StringBuffer();
+ StringBuilder value = new StringBuilder();
while (true)
{
String line = lin.readLine();
@@ -354,14 +337,14 @@ public class Headers
private void addValue(String name, String value)
{
Header key = new Header(name);
- String old = (String) headers.get(key);
+ String old = (String) super.get(key);
if (old == null)
{
- headers.put(key, value);
+ super.put(key, value);
}
else
{
- headers.put(key, old + ", " + value);
+ super.put(key, old + ", " + value);
}
}
diff --git a/gnu/java/net/protocol/http/LimitedLengthInputStream.java b/gnu/java/net/protocol/http/LimitedLengthInputStream.java
new file mode 100644
index 000000000..16cf56a29
--- /dev/null
+++ b/gnu/java/net/protocol/http/LimitedLengthInputStream.java
@@ -0,0 +1,220 @@
+/* LimitedLengthInputStream.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.net.protocol.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * InputStream that limits the total number of bytes that can be read
+ * from an underlying stream. In addition to limiting the number of
+ * bytes read, close() is not propagated to the underlying stream.
+ *
+ * @author David Daney (ddaney@avtrex.com)
+ */
+class LimitedLengthInputStream
+ extends InputStream
+{
+ private long remainingLen;
+ private boolean restrictLen;
+ private HTTPConnection connection;
+ private boolean eof;
+ private InputStream in;
+ private boolean doClose;
+
+
+ private void handleClose()
+ throws IOException
+ {
+ eof = true;
+ if (doClose)
+ {
+ in.close();
+ }
+ else
+ {
+ connection.release();
+ }
+ in = null;
+ connection = null;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param in the underlying stream
+ *
+ * @param maxLen the maximum number of bytes to read
+ *
+ * @param restrictLen if true the number of bytes that can be read
+ * from this stream will be limited to maxLen, otherwise the number
+ * of bytes is not restricted.
+ *
+ * @param con the HTTPConnection associated with this stream
+ *
+ * @param doClose if true con will be closed when finished reading,
+ * else it will be placed back in the connection pool.
+ *
+ */
+ LimitedLengthInputStream(InputStream in,
+ long maxLen,
+ boolean restrictLen,
+ HTTPConnection con,
+ boolean doClose)
+ throws IOException
+
+ {
+ this.in = in;
+ this.remainingLen = maxLen;
+ this.restrictLen = restrictLen;
+ this.connection = con;
+ this.doClose = doClose;
+
+ if (restrictLen)
+ {
+ if (maxLen < 0)
+ throw new IllegalArgumentException();
+ else if (maxLen == 0)
+ handleClose(); // Nothing to do, release the connection.
+ }
+ }
+
+ public synchronized int read()
+ throws IOException
+ {
+ if (eof)
+ return -1; // EOF
+
+ int r;
+
+ if (restrictLen)
+ {
+ r = in.read();
+ if (-1 != r)
+ remainingLen--;
+
+ if (0 == remainingLen)
+ handleClose();
+ }
+ else
+ {
+ r = in.read();
+ if (r == -1)
+ handleClose();
+ }
+
+ return r;
+ }
+
+ public int read(byte[] buffer)
+ throws IOException
+ {
+ return read(buffer, 0, buffer.length);
+ }
+
+ public synchronized int read(byte[] buffer, int offset, int length)
+ throws IOException
+ {
+ if (eof)
+ return -1; // EOF
+
+ if (restrictLen && length > remainingLen)
+ length = (int) remainingLen;
+
+ int r = in.read(buffer, offset, length);
+
+ if (-1 == r)
+ handleClose();
+
+ if (restrictLen && r > 0)
+ {
+ remainingLen -= r;
+ if (0 == remainingLen)
+ handleClose();
+ }
+ return r;
+ }
+
+ public synchronized long skip(long n)
+ throws IOException
+ {
+
+ if (eof)
+ return 0;
+
+ if (restrictLen && n > remainingLen)
+ n = remainingLen;
+
+ long r = in.skip(n);
+
+ if (restrictLen)
+ {
+ remainingLen -= r;
+ if (0 == remainingLen)
+ handleClose();
+ }
+ return r;
+ }
+
+ public synchronized int available()
+ throws IOException
+ {
+ if (eof)
+ return 0;
+
+ int a = in.available();
+ if (restrictLen && a > remainingLen)
+ a = (int)remainingLen;
+ return a;
+ }
+
+ public synchronized void close()
+ throws IOException
+ {
+ if (eof)
+ return;
+
+ // If we get to here, the stream was not fully read. Just throw
+ // it away.
+
+ doClose = true;
+
+ handleClose();
+ }
+}
diff --git a/gnu/java/net/protocol/http/Request.java b/gnu/java/net/protocol/http/Request.java
index 21205e6bb..b9441b3f7 100644
--- a/gnu/java/net/protocol/http/Request.java
+++ b/gnu/java/net/protocol/http/Request.java
@@ -1,5 +1,5 @@
/* Request.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,7 +40,6 @@ package gnu.java.net.protocol.http;
import gnu.java.net.BASE64;
import gnu.java.net.LineInputStream;
-import gnu.java.net.protocol.http.event.RequestEvent;
import java.io.IOException;
import java.io.InputStream;
@@ -100,11 +99,6 @@ public class Request
protected int requestBodyNegotiationThreshold;
/**
- * The response body reader.
- */
- protected ResponseBodyReader responseBodyReader;
-
- /**
* Map of response header handlers.
*/
protected Map responseHeaderHandlers;
@@ -236,16 +230,6 @@ public class Request
}
/**
- * Sets the response body reader.
- * @param responseBodyReader the handler to receive notifications of
- * response body content
- */
- public void setResponseBodyReader(ResponseBodyReader responseBodyReader)
- {
- this.responseBodyReader = responseBodyReader;
- }
-
- /**
* Sets a callback handler to be invoked for the specified header name.
* @param name the header name
* @param handler the handler to receive the value for the header
@@ -324,13 +308,10 @@ public class Request
do
{
retry = false;
- // Send request
- connection.fireRequestEvent(RequestEvent.REQUEST_SENDING, this);
// Get socket output and input streams
OutputStream out = connection.getOutputStream();
- LineInputStream in =
- new LineInputStream(connection.getInputStream());
+
// Request line
String requestUri = path;
if (connection.isUsingProxy() &&
@@ -369,28 +350,42 @@ public class Request
count += len;
}
while (len > -1 && count < contentLength);
- out.write(CRLF.getBytes(US_ASCII));
}
out.flush();
- // Sent event
- connection.fireRequestEvent(RequestEvent.REQUEST_SENT, this);
// Get response
- response = readResponse(in);
- int sc = response.getCode();
- if (sc == 401 && authenticator != null)
- {
- if (authenticate(response, attempts++))
- {
- retry = true;
- }
- }
- else if (sc == 100 && expectingContinue)
- {
- requestHeaders.remove("Expect");
- setHeader("Content-Length", Integer.toString(contentLength));
- expectingContinue = false;
- retry = true;
- }
+ while(true)
+ {
+ response = readResponse(connection.getInputStream());
+ int sc = response.getCode();
+ if (sc == 401 && authenticator != null)
+ {
+ if (authenticate(response, attempts++))
+ {
+ retry = true;
+ }
+ }
+ else if (sc == 100)
+ {
+ if (expectingContinue)
+ {
+ requestHeaders.remove("Expect");
+ setHeader("Content-Length",
+ Integer.toString(contentLength));
+ expectingContinue = false;
+ retry = true;
+ }
+ else
+ {
+ // A conforming server can send an unsoliceted
+ // Continue response but *should* not (RFC 2616
+ // sec 8.2.3). Ignore the bogus Continue
+ // response and get the real response that
+ // should follow
+ continue;
+ }
+ }
+ break;
+ }
}
while (retry);
}
@@ -402,14 +397,16 @@ public class Request
return response;
}
- Response readResponse(LineInputStream in)
+ Response readResponse(InputStream in)
throws IOException
{
String line;
int len;
// Read response status line
- line = in.readLine();
+ LineInputStream lis = new LineInputStream(in);
+
+ line = lis.readLine();
if (line == null)
{
throw new ProtocolException("Peer closed connection");
@@ -438,30 +435,25 @@ public class Request
String message = line.substring(end + 1, len - 1);
// Read response headers
Headers responseHeaders = new Headers();
- responseHeaders.parse(in);
+ responseHeaders.parse(lis);
notifyHeaderHandlers(responseHeaders);
- // Construct response
- int codeClass = code / 100;
- Response ret = new Response(majorVersion, minorVersion, code,
- codeClass, message, responseHeaders);
+ InputStream body = null;
+
switch (code)
{
+ case 100:
case 204:
case 205:
case 304:
break;
default:
- // Does response body reader want body?
- boolean notify = (responseBodyReader != null);
- if (notify)
- {
- if (!responseBodyReader.accept(this, ret))
- {
- notify = false;
- }
- }
- readResponseBody(ret, in, notify);
+ body = createResponseBodyStream(responseHeaders, majorVersion,
+ minorVersion, in);
}
+
+ // Construct response
+ Response ret = new Response(majorVersion, minorVersion, code,
+ message, responseHeaders, body);
return ret;
}
@@ -487,25 +479,40 @@ public class Request
}
}
- void readResponseBody(Response response, InputStream in,
- boolean notify)
+ private InputStream createResponseBodyStream(Headers responseHeaders,
+ int majorVersion,
+ int minorVersion,
+ InputStream in)
throws IOException
{
- byte[] buffer = new byte[4096];
- int contentLength = -1;
+ long contentLength = -1;
Headers trailer = null;
- String transferCoding = response.getHeader("Transfer-Encoding");
+ // Persistent connections are the default in HTTP/1.1
+ boolean doClose = "close".equalsIgnoreCase(getHeader("Connection")) ||
+ "close".equalsIgnoreCase(responseHeaders.getValue("Connection")) ||
+ (connection.majorVersion == 1 && connection.minorVersion == 0) ||
+ (majorVersion == 1 && minorVersion == 0);
+
+ String transferCoding = responseHeaders.getValue("Transfer-Encoding");
if ("chunked".equalsIgnoreCase(transferCoding))
{
- trailer = new Headers();
- in = new ChunkedInputStream(in, trailer);
+ in = new LimitedLengthInputStream(in, -1, false, connection, doClose);
+
+ in = new ChunkedInputStream(in, responseHeaders);
}
else
{
- contentLength = response.getIntHeader("Content-Length");
+ contentLength = responseHeaders.getLongValue("Content-Length");
+
+ if (contentLength < 0)
+ doClose = true; // No Content-Length, must close.
+
+ in = new LimitedLengthInputStream(in, contentLength,
+ contentLength >= 0,
+ connection, doClose);
}
- String contentCoding = response.getHeader("Content-Encoding");
+ String contentCoding = responseHeaders.getValue("Content-Encoding");
if (contentCoding != null && !"identity".equals(contentCoding))
{
if ("gzip".equals(contentCoding))
@@ -522,51 +529,7 @@ public class Request
contentCoding);
}
}
-
- // Persistent connections are the default in HTTP/1.1
- boolean doClose = "close".equalsIgnoreCase(getHeader("Connection")) ||
- "close".equalsIgnoreCase(response.getHeader("Connection")) ||
- (connection.majorVersion == 1 && connection.minorVersion == 0) ||
- (response.majorVersion == 1 && response.minorVersion == 0);
-
- int count = contentLength;
- int len = (count > -1) ? count : buffer.length;
- len = (len > buffer.length) ? buffer.length : len;
- while (len > -1)
- {
- len = in.read(buffer, 0, len);
- if (len < 0)
- {
- // EOF
- connection.closeConnection();
- break;
- }
- if (notify)
- {
- responseBodyReader.read(buffer, 0, len);
- }
- if (count > -1)
- {
- count -= len;
- if (count < 1)
- {
- if (doClose)
- {
- connection.closeConnection();
- }
- break;
- }
- }
- }
- if (notify)
- {
- responseBodyReader.close();
- }
- if (trailer != null)
- {
- response.getHeaders().putAll(trailer);
- notifyHeaderHandlers(trailer);
- }
+ return in;
}
boolean authenticate(Response response, int attempts)
@@ -686,7 +649,7 @@ public class Request
{
int len = text.length();
String key = null;
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
Properties ret = new Properties();
boolean inQuote = false;
for (int i = 0; i < len; i++)
@@ -739,7 +702,7 @@ public class Request
{
int nc = connection.getNonceCount(nonce);
String hex = Integer.toHexString(nc);
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 8 - hex.length(); i > 0; i--)
{
buf.append('0');
@@ -810,7 +773,7 @@ public class Request
int len = text.length();
String attr = null;
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
boolean inQuote = false;
for (int i = 0; i <= len; i++)
{
diff --git a/gnu/java/net/protocol/http/Response.java b/gnu/java/net/protocol/http/Response.java
index 29dc28b17..58d74542c 100644
--- a/gnu/java/net/protocol/http/Response.java
+++ b/gnu/java/net/protocol/http/Response.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.net.protocol.http;
+import java.io.InputStream;
import java.util.Date;
/**
@@ -64,19 +65,6 @@ public class Response
protected final int code;
/**
- * The class of the response. This is the most significant digit of the
- * status code.
- * <dl>
- * <dt><code>1xx</code></dt> <dd>Informational response</dd>
- * <dt><code>2xx</code></dt> <dd>Success</dd>
- * <dt><code>3xx</code></dt> <dd>Redirection</dd>
- * <dt><code>4xx</code></dt> <dd>Client error</dd>
- * <dt><code>5xx</code></dt> <dd>Server error</dd>
- * </dl>
- */
- protected final int codeClass;
-
- /**
* Human-readable text of the response.
*/
protected final String message;
@@ -87,18 +75,22 @@ public class Response
protected final Headers headers;
/**
+ * An InputStream that returns the body of the response.
+ */
+ protected final InputStream body;
+
+ /**
* Constructs a new response with the specified parameters.
*/
protected Response(int majorVersion, int minorVersion, int code,
- int codeClass, String message,
- Headers headers)
+ String message, Headers headers, InputStream body)
{
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
this.code = code;
- this.codeClass = codeClass;
this.message = message;
this.headers = headers;
+ this.body = body;
}
/**
@@ -129,12 +121,19 @@ public class Response
}
/**
- * Returns the class of the response.
- * @see #codeClass
+ * Returns the class of the response. This is the most significant
+ * digit of the status code.
+ * <dl>
+ * <dt><code>1xx</code></dt> <dd>Informational response</dd>
+ * <dt><code>2xx</code></dt> <dd>Success</dd>
+ * <dt><code>3xx</code></dt> <dd>Redirection</dd>
+ * <dt><code>4xx</code></dt> <dd>Client error</dd>
+ * <dt><code>5xx</code></dt> <dd>Server error</dd>
+ * </dl>
*/
public int getCodeClass()
{
- return codeClass;
+ return code / 100;
}
/**
@@ -173,6 +172,15 @@ public class Response
}
/**
+ * Returns the header value for the specified name as a long.
+ * @param name the header name
+ */
+ public long getLongHeader(String name)
+ {
+ return headers.getLongValue(name);
+ }
+
+ /**
* Returns the header value for the specified name as a date.
* @param name the header name
*/
@@ -181,5 +189,14 @@ public class Response
return headers.getDateValue(name);
}
+ /**
+ * Returns an InputStream that returns the body of the response.
+ *
+ * @return the body of the response
+ */
+ public InputStream getBody()
+ {
+ return body;
+ }
}
diff --git a/gnu/java/net/protocol/http/ResponseBodyReader.java b/gnu/java/net/protocol/http/ResponseBodyReader.java
deleted file mode 100644
index 49e1b376f..000000000
--- a/gnu/java/net/protocol/http/ResponseBodyReader.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ResponseBodyReader.java --
- Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.net.protocol.http;
-
-/**
- * Callback interface for receiving notification of response body content.
- *
- * @author Chris Burdess (dog@gnu.org)
- */
-public interface ResponseBodyReader
-{
-
- /**
- * Indicate whether this reader is interested in the specified response.
- * If it returns false, it will not receive body content notifications for
- * that response.
- */
- boolean accept(Request request, Response response);
-
- /**
- * Receive notification of body content.
- * @param buffer the content buffer
- * @param offset the offset within the buffer that content starts
- * @param length the length of the content
- */
- void read(byte[] buffer, int offset, int length);
-
- /**
- * Notifies the reader that the end of the content was reached.
- */
- void close();
-
-}
-
diff --git a/gnu/java/net/protocol/jar/Connection.java b/gnu/java/net/protocol/jar/Connection.java
index bd7a80da7..e85487420 100644
--- a/gnu/java/net/protocol/jar/Connection.java
+++ b/gnu/java/net/protocol/jar/Connection.java
@@ -69,13 +69,17 @@ public final class Connection extends JarURLConnection
private static Hashtable cache = new Hashtable();
private static final int READBUFSIZE = 4*1024;
- public static synchronized JarFile get (URL url) throws IOException
+ public static synchronized JarFile get (URL url, boolean useCaches)
+ throws IOException
{
- JarFile jf = (JarFile) cache.get (url);
+ JarFile jf;
+ if (useCaches)
+ {
+ jf = (JarFile) cache.get (url);
+ if (jf != null)
+ return jf;
+ }
- if (jf != null)
- return jf;
-
if ("file".equals (url.getProtocol()))
{
File f = new File (url.getFile());
@@ -100,9 +104,10 @@ public final class Connection extends JarURLConnection
jf = new JarFile (f, true,
ZipFile.OPEN_READ | ZipFile.OPEN_DELETE);
}
-
- cache.put (url, jf);
-
+
+ if (useCaches)
+ cache.put (url, jf);
+
return jf;
}
}
@@ -120,7 +125,7 @@ public final class Connection extends JarURLConnection
return;
jar_url = getJarFileURL();
- jar_file = JarFileCache.get (jar_url);
+ jar_file = JarFileCache.get (jar_url, useCaches);
String entry_name = getEntryName();
if (entry_name != null
diff --git a/gnu/java/rmi/server/RMIClassLoaderImpl.java b/gnu/java/rmi/server/RMIClassLoaderImpl.java
new file mode 100644
index 000000000..2e1e78055
--- /dev/null
+++ b/gnu/java/rmi/server/RMIClassLoaderImpl.java
@@ -0,0 +1,350 @@
+/* RMIClassLoaderImpl.java -- FIXME: briefly describe file purpose
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.rmi.server;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.server.RMIClassLoaderSpi;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * The default implementation of {@link java.rmi.server.RMIClassLoaderSpi}.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class RMIClassLoaderImpl extends RMIClassLoaderSpi
+{
+ private static class MyClassLoader extends URLClassLoader
+ {
+ // Package-private to avoid a trampoline constructor.
+ MyClassLoader (URL[] urls, ClassLoader parent, String annotation)
+ {
+ super (urls, parent);
+ this.annotation = annotation;
+ }
+
+ private MyClassLoader (URL[] urls, ClassLoader parent)
+ {
+ super (urls, parent);
+ this.annotation = urlToAnnotation (urls);
+ }
+
+ public static String urlToAnnotation (URL[] urls)
+ {
+ if (urls.length == 0)
+ return null;
+
+ StringBuffer annotation = new StringBuffer (64 * urls.length);
+
+ for (int i = 0; i < urls.length; i++)
+ {
+ annotation.append (urls [i].toExternalForm());
+ annotation.append (' ');
+ }
+
+ return annotation.toString();
+ }
+
+ public final String getClassAnnotation()
+ {
+ return annotation;
+ }
+
+ private final String annotation;
+ }
+
+ /**
+ * This class is used to identify a cached classloader by its codebase and
+ * the context classloader that is its parent.
+ */
+ private static class CacheKey
+ {
+ private String mCodeBase;
+ private ClassLoader mContextClassLoader;
+
+ public CacheKey (String theCodebase, ClassLoader theContextClassLoader)
+ {
+ mCodeBase = theCodebase;
+ mContextClassLoader = theContextClassLoader;
+ }
+
+ /**
+ * @return true if the codebase and the context classloader are equal
+ */
+ public boolean equals (Object theOther)
+ {
+ if (theOther instanceof CacheKey)
+ {
+ CacheKey key = (CacheKey) theOther;
+
+ return (equals (this.mCodeBase,key.mCodeBase)
+ && equals (this.mContextClassLoader, key.mContextClassLoader));
+ }
+ return false;
+ }
+
+ /**
+ * Test if the two objects are equal or both null.
+ * @param theOne
+ * @param theOther
+ * @return
+ */
+ private boolean equals (Object theOne, Object theOther)
+ {
+ return theOne != null ? theOne.equals (theOther) : theOther == null;
+ }
+
+ /**
+ * @return hashCode
+ */
+ public int hashCode()
+ {
+ return ((mCodeBase != null ? mCodeBase.hashCode() : 0)
+ ^(mContextClassLoader != null ? mContextClassLoader.hashCode() : -1));
+ }
+
+ public String toString()
+ {
+ return "[" + mCodeBase + "," + mContextClassLoader + "]";
+ }
+
+ }
+
+ private static RMIClassLoaderImpl instance = null;
+
+ private static Map cacheLoaders; //map annotations to loaders
+ private static Map cacheAnnotations; //map loaders to annotations
+ //class loader for defaultAnnotation
+ private static MyClassLoader defaultClassLoader;
+
+ //defaultAnnotation is got from system property
+ // "java.rmi.server.defaultAnnotation"
+ private static String defaultAnnotation;
+
+ //URL object for defaultAnnotation
+ private static URL defaultCodebase;
+
+ static
+ {
+ // 89 is a nice prime number for Hashtable initial capacity
+ cacheLoaders = new Hashtable (89);
+ cacheAnnotations = new Hashtable (89);
+
+ defaultAnnotation = System.getProperty ("java.rmi.server.defaultAnnotation");
+
+ try
+ {
+ if (defaultAnnotation != null)
+ defaultCodebase = new URL (defaultAnnotation);
+ }
+ catch (Exception _)
+ {
+ defaultCodebase = null;
+ }
+
+ if (defaultCodebase != null)
+ {
+ defaultClassLoader = new MyClassLoader (new URL[] { defaultCodebase }, null,
+ defaultAnnotation);
+ cacheLoaders.put (new CacheKey (defaultAnnotation,
+ Thread.currentThread().getContextClassLoader()),
+ defaultClassLoader);
+ }
+ }
+
+ /**
+ * This is a singleton class and may only be instantiated once from within
+ * the {@link #getInstance} method.
+ */
+ private RMIClassLoaderImpl()
+ {
+ }
+
+ /**
+ * Returns an instance of RMIClassLoaderImpl.
+ *
+ * @return an instance of RMIClassLoaderImpl
+ */
+ public static RMIClassLoaderSpi getInstance()
+ {
+ if (instance == null)
+ instance = new RMIClassLoaderImpl();
+ return instance;
+ }
+
+ public Class loadClass(String codeBase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ ClassLoader loader;
+ if (defaultLoader == null)
+ loader = Thread.currentThread().getContextClassLoader();
+ else
+ loader = defaultLoader;
+
+ //try context class loader first
+ try
+ {
+ return Class.forName(name, false, loader);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // class not found in the local classpath
+ }
+
+ if (codeBase.length() == 0) //==""
+ {
+ loader = defaultClassLoader;
+ }
+ else
+ {
+ loader = getClassLoader(codeBase);
+ }
+
+ if (loader == null)
+ {
+ //do not throw NullPointerException
+ throw new ClassNotFoundException ("Could not find class (" + name +
+ ") at codebase (" + codeBase + ")");
+ }
+
+ return Class.forName(name, false, loader);
+ }
+
+ public Class loadProxyClass(String codeBase, String[] interfaces,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ // FIXME: Implement this.
+ return null;
+ }
+
+ /**
+ * Gets a classloader for the given codebase and with the current
+ * context classloader as parent.
+ *
+ * @param codebase
+ *
+ * @return a classloader for the given codebase
+ *
+ * @throws MalformedURLException if the codebase contains a malformed URL
+ */
+ public ClassLoader getClassLoader(String codebase)
+ throws MalformedURLException
+ {
+ ClassLoader loader;
+ CacheKey loaderKey = new CacheKey
+ (codebase, Thread.currentThread().getContextClassLoader());
+ loader = (ClassLoader) cacheLoaders.get (loaderKey);
+
+ if (loader == null)
+ {
+ //create an entry in cacheLoaders mapping a loader to codebases.
+ // codebases are separated by " "
+ StringTokenizer tok = new StringTokenizer (codebase, " ");
+ ArrayList urls = new ArrayList();
+
+ while (tok.hasMoreTokens())
+ urls.add (new URL(tok.nextToken()));
+
+ loader = new MyClassLoader((URL[]) urls.toArray(new URL [urls.size()]),
+ Thread.currentThread().getContextClassLoader(),
+ codebase);
+ cacheLoaders.put (loaderKey, loader);
+ }
+
+ return loader;
+ }
+
+ /**
+ * Returns a string representation of the network location where a remote
+ * endpoint can get the class-definition of the given class.
+ *
+ * @param cl
+ *
+ * @return a space seperated list of URLs where the class-definition
+ * of cl may be found
+ */
+ public String getClassAnnotation(Class cl)
+ {
+ ClassLoader loader = cl.getClassLoader();
+
+ if (loader == null
+ || loader == ClassLoader.getSystemClassLoader())
+ {
+ return System.getProperty ("java.rmi.server.codebase");
+ }
+
+ if (loader instanceof MyClassLoader)
+ {
+ return ((MyClassLoader) loader).getClassAnnotation();
+ }
+
+ String s = (String) cacheAnnotations.get (loader);
+
+ if (s != null)
+ return s;
+
+ if (loader instanceof URLClassLoader)
+ {
+ URL[] urls = ((URLClassLoader) loader).getURLs();
+
+ if (urls.length == 0)
+ return null;
+
+ StringBuffer annotation = new StringBuffer (64 * urls.length);
+
+ for (int i = 0; i < urls.length; i++)
+ {
+ annotation.append (urls [i].toExternalForm());
+ annotation.append (' ');
+ }
+
+ s = annotation.toString();
+ cacheAnnotations.put (loader, s);
+ return s;
+ }
+
+ return System.getProperty ("java.rmi.server.codebase");
+ }
+}
diff --git a/gnu/java/rmi/server/UnicastServer.java b/gnu/java/rmi/server/UnicastServer.java
index 065ef8c77..a8da72563 100644
--- a/gnu/java/rmi/server/UnicastServer.java
+++ b/gnu/java/rmi/server/UnicastServer.java
@@ -51,13 +51,16 @@ import java.rmi.RemoteException;
import java.rmi.ServerError;
import java.rmi.server.ObjID;
import java.rmi.server.UID;
+import java.util.Collections;
+import java.util.Map;
import java.util.Hashtable;
+import java.util.IdentityHashMap;
public class UnicastServer
implements ProtocolConstants {
static private Hashtable objects = new Hashtable(); //mapping OBJID to server ref
-static private Hashtable refcache = new Hashtable(); //mapping obj itself to server ref
+static private Map refcache = Collections.synchronizedMap(new IdentityHashMap()); //mapping obj itself to server ref
static private DGCImpl dgc;
public static void exportObject(UnicastServerRef obj) {
diff --git a/gnu/java/security/der/BitString.java b/gnu/java/security/der/BitString.java
index b88b14541..02b1c0377 100644
--- a/gnu/java/security/der/BitString.java
+++ b/gnu/java/security/der/BitString.java
@@ -286,6 +286,19 @@ public class BitString implements Cloneable, Comparable
return 0; // not reached.
}
+ public int hashCode()
+ {
+ int result = 0;
+ for (int i = 0; i < bytes.length - 1; ++i)
+ result = result * 31 + bytes[i];
+ if (bytes.length > 0)
+ {
+ int lastByte = bytes[bytes.length - 1] & ~ ((1 << ignoredBits) - 1);
+ result = result * 31 + lastByte;
+ }
+ return result;
+ }
+
public boolean equals(Object o)
{
if (!(o instanceof BitString))
diff --git a/gnu/java/security/provider/DiffieHellmanKeyFactoryImpl.java b/gnu/java/security/provider/DiffieHellmanKeyFactoryImpl.java
new file mode 100644
index 000000000..591fc688c
--- /dev/null
+++ b/gnu/java/security/provider/DiffieHellmanKeyFactoryImpl.java
@@ -0,0 +1,123 @@
+/* DiffieHellmanKeyFactoryImpl.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.provider;
+
+import gnu.javax.crypto.GnuDHPrivateKey;
+
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyFactorySpi;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+
+import javax.crypto.spec.DHParameterSpec;
+import javax.crypto.spec.DHPrivateKeySpec;
+import javax.crypto.spec.DHPublicKeySpec;
+
+import javax.crypto.interfaces.DHPrivateKey;
+import javax.crypto.interfaces.DHPublicKey;
+
+public class DiffieHellmanKeyFactoryImpl extends KeyFactorySpi
+{
+ protected PrivateKey engineGeneratePrivate (final KeySpec spec)
+ throws InvalidKeySpecException
+ {
+ if (spec instanceof DHPrivateKeySpec)
+ {
+ DHPrivateKeySpec dh = (DHPrivateKeySpec) spec;
+ return new GnuDHPrivateKey (dh.getX (),
+ new DHParameterSpec (dh.getP (), dh.getG ()));
+ }
+ throw new InvalidKeySpecException ();
+ }
+
+ protected PublicKey engineGeneratePublic (final KeySpec spec)
+ throws InvalidKeySpecException
+ {
+ if (spec instanceof DHPublicKeySpec)
+ {
+ DHPublicKeySpec dh = (DHPublicKeySpec) spec;
+ return new GnuDHPublicKey (new DHParameterSpec (dh.getP (), dh.getG ()),
+ dh.getY(), null);
+ }
+ throw new InvalidKeySpecException ();
+ }
+
+ protected KeySpec engineGetKeySpec (final Key key, final Class specClass)
+ throws InvalidKeySpecException
+ {
+ if (key instanceof DHPrivateKey)
+ {
+ if (DHPrivateKeySpec.class.isAssignableFrom (specClass))
+ {
+ DHParameterSpec params = ((DHPrivateKey) key).getParams ();
+ return new DHPrivateKeySpec (((DHPrivateKey) key).getX (),
+ params.getP (), params.getG ());
+ }
+ }
+ if (key instanceof DHPublicKey)
+ {
+ if (DHPublicKeySpec.class.isAssignableFrom (specClass))
+ {
+ DHParameterSpec params = ((DHPublicKey) key).getParams ();
+ return new DHPublicKeySpec (((DHPublicKey) key).getY (),
+ params.getP (), params.getG ());
+ }
+ }
+ throw new InvalidKeySpecException ();
+ }
+
+ protected Key engineTranslateKey (final Key key)
+ throws InvalidKeyException
+ {
+ if (key instanceof DHPrivateKey)
+ {
+ return new GnuDHPrivateKey (((DHPrivateKey) key).getX (),
+ ((DHPrivateKey) key).getParams ());
+ }
+ if (key instanceof DHPublicKey)
+ {
+ return new GnuDHPublicKey (((DHPublicKey) key).getParams (),
+ ((DHPublicKey) key).getY (), null);
+ }
+ throw new InvalidKeyException ();
+ }
+}
diff --git a/gnu/java/security/provider/DiffieHellmanKeyPairGeneratorImpl.java b/gnu/java/security/provider/DiffieHellmanKeyPairGeneratorImpl.java
new file mode 100644
index 000000000..1b68d274f
--- /dev/null
+++ b/gnu/java/security/provider/DiffieHellmanKeyPairGeneratorImpl.java
@@ -0,0 +1,86 @@
+/* DiffieHellmanKeyPairGeneratorImpl.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.provider;
+
+import gnu.javax.crypto.GnuDHPrivateKey;
+
+import java.math.BigInteger;
+
+import java.security.KeyPair;
+import java.security.KeyPairGeneratorSpi;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+
+import javax.crypto.spec.DHParameterSpec;
+
+public class DiffieHellmanKeyPairGeneratorImpl extends KeyPairGeneratorSpi
+{
+ private SecureRandom random;
+ private DHParameterSpec params;
+
+ public KeyPair generateKeyPair ()
+ {
+ if (params == null || random == null)
+ throw new IllegalStateException ("not initialized");
+ byte[] buf = new byte[(params.getP ().bitLength() >>> 3)];
+ random.nextBytes (buf);
+ BigInteger x = new BigInteger (1, buf);
+ BigInteger y = params.getG ().modPow (x, params.getP ());
+ GnuDHPublicKey pub = new GnuDHPublicKey (params, y, null);
+ GnuDHPrivateKey priv = new GnuDHPrivateKey (x, params);
+
+ return new KeyPair (pub, priv);
+ }
+
+ public void initialize (final int keysize, final SecureRandom random)
+ {
+ throw new UnsupportedOperationException ("key generation without parameters not supported");
+ }
+
+ public void initialize (final AlgorithmParameterSpec params,
+ final SecureRandom random)
+ {
+ if (!(params instanceof DHParameterSpec))
+ throw new IllegalArgumentException ("expecting Diffie-Hellman parameters");
+ this.params = (DHParameterSpec) params;
+ this.random = random;
+ if (this.random == null)
+ this.random = new SecureRandom ();
+ }
+}
diff --git a/gnu/java/security/provider/Gnu.java b/gnu/java/security/provider/Gnu.java
index 47c774538..e553bbcbd 100644
--- a/gnu/java/security/provider/Gnu.java
+++ b/gnu/java/security/provider/Gnu.java
@@ -46,7 +46,7 @@ public final class Gnu extends Provider
{
public Gnu()
{
- super("GNU", 1.0, "GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 Certificates and CRLs, PKIX certificate path validators, Collection cert stores, Diffie-Hellman key agreement");
+ super("GNU", 1.0, "GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 Certificates and CRLs, PKIX certificate path validators, Collection cert stores, Diffie-Hellman key agreement and key pair generator");
AccessController.doPrivileged (new PrivilegedAction()
{
@@ -100,10 +100,12 @@ public final class Gnu extends Provider
// Key Pair Generator
put("KeyPairGenerator.DSA",
gnu.java.security.provider.DSAKeyPairGenerator.class.getName());
+ put("KeyPairGenerator.DiffieHellman", DiffieHellmanKeyPairGeneratorImpl.class.getName ());
put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSA");
put("Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1", "DSA");
put("Alg.Alias.KeyPairGenerator.1.3.14.3.2.12", "DSA");
+ put("Alg.Alias.KeyPairGenerator.DH", "DiffieHellman");
// Key Factory
put("KeyFactory.DSA",
@@ -122,6 +124,9 @@ public final class Gnu extends Provider
put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSA");
+ put("KeyFactory.DiffieHellman", DiffieHellmanKeyFactoryImpl.class.getName());
+ put("Alg.Alias.KeyFactory.DH", "DiffieHellman");
+
// Message Digests
put("MessageDigest.SHA", gnu.java.security.provider.SHA.class.getName());
put("MessageDigest.MD5", gnu.java.security.provider.MD5.class.getName());
diff --git a/gnu/java/security/x509/ext/Extension.java b/gnu/java/security/x509/ext/Extension.java
index ee2aa073a..97097a2f3 100644
--- a/gnu/java/security/x509/ext/Extension.java
+++ b/gnu/java/security/x509/ext/Extension.java
@@ -274,6 +274,14 @@ public class Extension
return (byte[]) encoded;
}
+ public int hashCode()
+ {
+ int result = 0;
+ for (int i = 0; i < encoded.length; ++i)
+ result = result * 31 + encoded[i];
+ return result;
+ }
+
public boolean equals(Object o)
{
if (!(o instanceof Value))
diff --git a/gnu/java/text/BaseBreakIterator.java b/gnu/java/text/BaseBreakIterator.java
index c28a2089a..4afd8ae66 100644
--- a/gnu/java/text/BaseBreakIterator.java
+++ b/gnu/java/text/BaseBreakIterator.java
@@ -68,12 +68,15 @@ public abstract class BaseBreakIterator extends BreakIterator
return iter.getBeginIndex();
}
+ /**
+ * Return the first boundary after <code>pos</code>.
+ * This has the side effect of setting the index of the
+ * CharacterIterator.
+ */
public int following (int pos)
{
- int save = iter.getIndex();
iter.setIndex(pos);
int r = next ();
- iter.setIndex(save);
return r;
}
diff --git a/gnu/javax/crypto/DiffieHellmanImpl.java b/gnu/javax/crypto/DiffieHellmanImpl.java
index 670b2fe1c..4797af7cf 100644
--- a/gnu/javax/crypto/DiffieHellmanImpl.java
+++ b/gnu/javax/crypto/DiffieHellmanImpl.java
@@ -67,9 +67,6 @@ public final class DiffieHellmanImpl extends KeyAgreementSpi
/** The private key being used for this agreement. */
private DHPrivateKey key;
- /** The random-number generator used to generate secrets. */
- private SecureRandom random;
-
/** The current result. */
private BigInteger result;
@@ -80,7 +77,6 @@ public final class DiffieHellmanImpl extends KeyAgreementSpi
public DiffieHellmanImpl ()
{
key = null;
- random = null;
result = null;
last_phase_done = false;
}
@@ -99,23 +95,20 @@ public final class DiffieHellmanImpl extends KeyAgreementSpi
throw new InvalidKeyException ("expecting javax.crypto.interfaces.DHPublicKey");
DHPublicKey pub = (DHPublicKey) incoming;
DHParameterSpec s1 = key.getParams();
- DHParameterSpec s2 = key.getParams();
+ DHParameterSpec s2 = pub.getParams();
if (!s1.getG().equals (s2.getG())
|| !s1.getP().equals (s2.getP())
|| s1.getL() != s2.getL())
throw new InvalidKeyException ("supplied key is not compatible");
- BigInteger randval = new BigInteger (s1.getL(), random);
- BigInteger out = s1.getG().modPow (key.getX(), s1.getP());
- if (result == null)
- result = s1.getG();
- result = result.modPow (pub.getY(), s1.getP());
+ result = pub.getY().modPow (key.getX(), s1.getP());
if (lastPhase)
{
last_phase_done = true;
return null;
}
- return new GnuDHPublicKey (s1, out, null);
+
+ throw new IllegalArgumentException ("only supports two-party Diffie Hellman");
}
protected byte[] engineGenerateSecret ()
@@ -153,10 +146,6 @@ public final class DiffieHellmanImpl extends KeyAgreementSpi
if (!(key instanceof DHPrivateKey))
throw new InvalidKeyException ("not a javax.crypto.interfaces.DHPrivateKey");
this.key = (DHPrivateKey) key;
- if (random != null)
- this.random = random;
- else if (this.random == null)
- this.random = new SecureRandom();
result = null;
last_phase_done = false;
}
diff --git a/gnu/javax/imageio/bmp/BMPDecoder.java b/gnu/javax/imageio/bmp/BMPDecoder.java
new file mode 100644
index 000000000..c4a582bfa
--- /dev/null
+++ b/gnu/javax/imageio/bmp/BMPDecoder.java
@@ -0,0 +1,169 @@
+/* BMPDecoder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.awt.image.ColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.image.BufferedImage;
+
+public abstract class BMPDecoder {
+
+ protected BMPInfoHeader infoHeader;
+ protected BMPFileHeader fileHeader;
+ protected long offset;
+
+ public BMPDecoder(BMPFileHeader fh, BMPInfoHeader ih){
+ fileHeader = fh;
+ infoHeader = ih;
+ offset = BMPFileHeader.SIZE + BMPInfoHeader.SIZE;
+ }
+
+ /**
+ * Determines the coding type of the bitmap and returns the corresponding
+ * decoder.
+ */
+ public static BMPDecoder getDecoder(BMPFileHeader fh, BMPInfoHeader ih){
+ switch(ih.getCompression()){
+ case BMPInfoHeader.BI_RGB: // uncompressed RGB
+ switch(ih.getBitCount()){
+ case 32:
+ return new DecodeBF32(fh, ih, true);
+
+ case 24:
+ return new DecodeRGB24(fh, ih);
+
+ case 16:
+ return new DecodeBF16(fh, ih, true);
+
+ case 8:
+ return new DecodeRGB8(fh, ih);
+
+ case 4:
+ return new DecodeRGB4(fh, ih);
+
+ case 1:
+ return new DecodeRGB1(fh, ih);
+
+ default:
+ return null;
+ }
+
+ case BMPInfoHeader.BI_RLE8:
+ return new DecodeRLE8(fh, ih);
+
+ case BMPInfoHeader.BI_RLE4:
+ return new DecodeRLE4(fh, ih);
+
+ case BMPInfoHeader.BI_BITFIELDS:
+ switch(ih.getBitCount()){
+ case 16:
+ return new DecodeBF16(fh, ih, false);
+
+ case 32:
+ return new DecodeBF32(fh, ih, false);
+
+ default:
+ return null;
+ }
+
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * The image decoder.
+ */
+ public abstract BufferedImage decode(ImageInputStream in)
+ throws IOException, BMPException;
+
+ /**
+ * Reads r,g,b bit masks from an inputstream
+ */
+ protected int[] readBitMasks(ImageInputStream in) throws IOException {
+ int[] bitmasks = new int[3];
+ byte[] temp = new byte[12];
+ if(in.read(temp) != 12)
+ throw new IOException("Couldn't read bit masks.");
+ offset += 12;
+
+ ByteBuffer buf = ByteBuffer.wrap(temp);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+ bitmasks[0] = buf.getInt();
+ bitmasks[1] = buf.getInt();
+ bitmasks[2] = buf.getInt();
+ return bitmasks;
+ }
+
+ /**
+ * Reads an N-color palette from an inputstream in RGBQUAD format and
+ * returns an equivalent ColorModel object
+ */
+ protected IndexColorModel readPalette(ImageInputStream in) throws IOException {
+ int N = infoHeader.getNumberOfPaletteEntries();
+ byte[] r = new byte[N];
+ byte[] g = new byte[N];
+ byte[] b = new byte[N];
+ for(int i=0;i<N;i++){
+ byte[] RGBquad = new byte[4];
+ if(in.read(RGBquad) != 4)
+ throw new IOException("Error reading palette information.");
+ // RGBQUAD structure is b,g,r,0
+ r[i] = RGBquad[2];
+ g[i] = RGBquad[1];
+ b[i] = RGBquad[0];
+ }
+
+ offset += 4*N;
+ return new IndexColorModel(8, N, r, g, b);
+ }
+
+ /**
+ * Read bytes to the start of the image data
+ */
+ protected void skipToImage(ImageInputStream in) throws IOException {
+ byte[] d = new byte[1];
+ long n = fileHeader.getOffset() - offset;
+ for(int i=0;i<n;i++)
+ in.read(d);
+ }
+}
diff --git a/gnu/javax/imageio/bmp/BMPException.java b/gnu/javax/imageio/bmp/BMPException.java
new file mode 100644
index 000000000..d3c62e759
--- /dev/null
+++ b/gnu/javax/imageio/bmp/BMPException.java
@@ -0,0 +1,47 @@
+/* BMPException.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import javax.imageio.IIOException;
+
+public class BMPException extends IIOException {
+
+ public BMPException(String message){
+ super(message);
+ }
+}
diff --git a/gnu/javax/imageio/bmp/BMPFileHeader.java b/gnu/javax/imageio/bmp/BMPFileHeader.java
new file mode 100644
index 000000000..246e0eacf
--- /dev/null
+++ b/gnu/javax/imageio/bmp/BMPFileHeader.java
@@ -0,0 +1,128 @@
+/* BMPFileHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class BMPFileHeader {
+ /** Header signature, always 'BM' */
+ private final static short bfType = 0x424d;
+
+ /** Bitmap file size, in bytes. */
+ private long bfSize;
+
+ /** Offset from the beginning of the file to the bitmap data */
+ private long bfOffBits;
+
+ /** BITMAPFILEHEADER is 14 bytes */
+ public static final int SIZE = 14;
+
+ /**
+ * Creates the header from an input stream, which is not closed.
+ * @throws IOException if an I/O error occured.
+ * @throws BMPException if the header was invalid
+ */
+ public BMPFileHeader(ImageInputStream in) throws IOException, BMPException {
+ byte[] data = new byte[SIZE];
+
+ if (in.read(data) != SIZE)
+ throw new IOException("Couldn't read header.");
+ ByteBuffer buf = ByteBuffer.wrap(data);
+
+ if(buf.getShort(0) != bfType)
+ throw new BMPException("Not a BMP file.");
+
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+
+ // get size (keep unsigned)
+ bfSize = ((long)buf.getInt(2) & (0xFFFFFFFF));
+
+ // Two reserved shorts are here, and should be zero,
+ // perhaps they should be tested to be zero, but I don't
+ // feel this strictness is necessary.
+
+ bfOffBits = ((long)buf.getInt(10) & (0xFFFFFFFF));
+ }
+
+ /**
+ * Writes the header to an output stream, which is not closed or flushed.
+ * @throws IOException if an I/O error occured.
+ */
+ public void write(OutputStream out) throws IOException {
+ ByteBuffer buf = ByteBuffer.allocate(SIZE);
+ buf.putShort(0, bfType); // ID
+ buf.putInt(2, (int)(bfSize & (0xFFFFFFFF))); // size
+ buf.putInt(6, 0); // 4 reserved bytes set to zero
+ buf.putInt(2, (int)(bfOffBits & (0xFFFFFFFF))); // size
+ out.write(buf.array());
+ }
+
+ /**
+ * Sets the file size
+ */
+ public void setSize(long size){
+ bfSize = size;
+ }
+
+ /**
+ * Sets the bitmap offset within the file
+ */
+ public void setOffset(long offset){
+ bfOffBits = offset;
+ }
+
+ /**
+ * Gets the file size
+ */
+ public long getSize(){
+ return bfSize;
+ }
+
+ /**
+ * Gets the bitmap offset within the file
+ */
+ public long getOffset(){
+ return bfOffBits;
+ }
+}
+
+
diff --git a/gnu/javax/imageio/bmp/BMPImageReader.java b/gnu/javax/imageio/bmp/BMPImageReader.java
new file mode 100644
index 000000000..3341d4b4a
--- /dev/null
+++ b/gnu/javax/imageio/bmp/BMPImageReader.java
@@ -0,0 +1,153 @@
+/* BMPImageReader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.*;
+import javax.imageio.spi.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.ImageInputStream;
+import java.util.Iterator;
+import java.awt.image.BufferedImage;
+
+public class BMPImageReader extends ImageReader {
+ private BMPInfoHeader infoHeader;
+ private BMPFileHeader fileHeader;
+ private BMPDecoder decoder;
+
+ protected BMPImageReader(ImageReaderSpi originatingProvider){
+ super(originatingProvider);
+ infoHeader = null;
+ fileHeader = null;
+ decoder = null;
+ }
+
+ private void validateIndex(int imageIndex)
+ throws IndexOutOfBoundsException {
+ if (imageIndex != 0)
+ throw new IndexOutOfBoundsException("Invalid image index.");
+ }
+
+ public void setInput(Object input) {
+ super.setInput(input);
+ }
+
+ public void setInput(Object input,
+ boolean seekForwardOnly,
+ boolean ignoreMetadata) {
+ super.setInput(input, seekForwardOnly, ignoreMetadata);
+ }
+
+ public void setInput(Object input, boolean isStreamable) {
+ super.setInput(input, isStreamable);
+
+ if (!(input instanceof ImageInputStream))
+ throw new IllegalArgumentException("Input not an ImageInputStream.");
+ }
+
+ private void checkStream() throws IOException {
+ if (!(input instanceof ImageInputStream))
+ throw new IllegalStateException("Input not an ImageInputStream.");
+ if(input == null)
+ throw new IllegalStateException("No input stream.");
+
+ }
+
+ private void readHeaders() throws IOException, IIOException {
+ if(fileHeader != null)
+ return;
+
+ checkStream();
+
+ fileHeader = new BMPFileHeader((ImageInputStream)input);
+ infoHeader = new BMPInfoHeader((ImageInputStream)input);
+ decoder = BMPDecoder.getDecoder(fileHeader, infoHeader);
+ }
+
+ public int getWidth(int imageIndex) throws IOException {
+ validateIndex(imageIndex);
+ readHeaders();
+ return infoHeader.getWidth();
+ }
+
+ public int getHeight(int imageIndex) throws IOException {
+ validateIndex(imageIndex);
+ readHeaders();
+ return infoHeader.getHeight();
+ }
+
+ public Iterator getImageTypes(int imageIndex){
+ validateIndex(imageIndex);
+ return null;
+ }
+
+ /**
+ * Returns the number of images. BMP files can only contain a single one.
+ */
+ public int getNumImages(boolean allowSearch){
+ return 1;
+ }
+
+
+ // FIXME: Support metadata
+ public IIOMetadata getImageMetadata(int imageIndex){
+ validateIndex(imageIndex);
+ return null;
+ }
+
+ // FIXME: Support metadata
+ public IIOMetadata getStreamMetadata(){
+ return null;
+ }
+
+ /**
+ * Reads the image indexed by imageIndex and returns it as
+ * a complete BufferedImage, using a supplied ImageReadParam.
+ */
+ public BufferedImage read(int imageIndex, ImageReadParam param)
+ throws IOException, IIOException {
+ validateIndex(imageIndex);
+ readHeaders();
+ return decoder.decode((ImageInputStream)input);
+ }
+
+
+}
+
+
+
diff --git a/gnu/javax/imageio/bmp/BMPImageReaderSpi.java b/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
new file mode 100644
index 000000000..b175c7d07
--- /dev/null
+++ b/gnu/javax/imageio/bmp/BMPImageReaderSpi.java
@@ -0,0 +1,123 @@
+/* BMPImageReaderSpi.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import java.util.Locale;
+import javax.imageio.ImageReader;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.stream.ImageInputStream;
+
+public class BMPImageReaderSpi extends ImageReaderSpi {
+
+ static final String vendorName = "GNU";
+ static final String version = "0.1";
+ static final String readerClassName =
+ "gnu.javax.imageio.bmp.BMPImageReader";
+ static final String[] names = { "Microsoft Windows BMP" };
+ static final String[] suffixes = { ".bmp", ".bm" };
+ static final String[] MIMETypes = {
+ "image/bmp",
+ "image/x-windows-bmp"};
+
+ static final String[] writerSpiNames = null;
+ //{"com.mycompany.imageio.MyFormatImageWriterSpi" };
+
+ static final boolean supportsStandardStreamMetadataFormat = false;
+ static final String nativeStreamMetadataFormatName = null;
+ static final String nativeStreamMetadataFormatClassName = null;
+ static final String[] extraStreamMetadataFormatNames = null;
+ static final String[] extraStreamMetadataFormatClassNames = null;
+ static final boolean supportsStandardImageMetadataFormat = false;
+ static final String nativeImageMetadataFormatName = null;
+ static final String nativeImageMetadataFormatClassName = null;
+ static final String[] extraImageMetadataFormatNames = null;
+ static final String[] extraImageMetadataFormatClassNames = null;
+
+ public BMPImageReaderSpi() {
+ super(vendorName, version,
+ names, suffixes, MIMETypes,
+ readerClassName,
+ STANDARD_INPUT_TYPE, // Accept ImageImageInputStreams
+ writerSpiNames,
+ supportsStandardStreamMetadataFormat,
+ nativeStreamMetadataFormatName,
+ nativeStreamMetadataFormatClassName,
+ extraStreamMetadataFormatNames,
+ extraStreamMetadataFormatClassNames,
+ supportsStandardImageMetadataFormat,
+ nativeImageMetadataFormatName,
+ nativeImageMetadataFormatClassName,
+ extraImageMetadataFormatNames,
+ extraImageMetadataFormatClassNames);
+ }
+
+ public String getDescription(Locale locale) {
+ return "Microsoft BMP v3";
+ }
+
+ public boolean canDecodeInput(Object input)
+ throws IOException {
+ if (!(input instanceof ImageInputStream))
+ return false;
+
+ ImageInputStream in = (ImageInputStream)input;
+ boolean retval;
+
+ in.mark();
+ try {
+ new BMPFileHeader(in);
+ retval = true;
+ } catch(BMPException e){
+ retval = false;
+ }
+ in.reset();
+
+ return retval;
+ }
+
+ public ImageReader createReaderInstance(Object extension) {
+ return new BMPImageReader(this);
+ }
+}
+
+
+
+
+
+
diff --git a/gnu/javax/imageio/bmp/BMPInfoHeader.java b/gnu/javax/imageio/bmp/BMPInfoHeader.java
new file mode 100644
index 000000000..edcb4e644
--- /dev/null
+++ b/gnu/javax/imageio/bmp/BMPInfoHeader.java
@@ -0,0 +1,201 @@
+/* BMPInfoHeader.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.awt.Dimension;
+
+public class BMPInfoHeader {
+ /** Size of the bitmap info header*/
+ private int biSize;
+
+ /** Pixel width of the bitmap */
+ private int biWidth;
+
+ /** Pixel height of the bitmap */
+ private int biHeight;
+
+ /** Number of bitplanes = 1 */
+ private short biPlanes;
+
+ /** Number of bpp = 1,4,8,24 */
+ private short biBitCount;
+
+ /** Compression type, RGB8, RLE8, RLE4, BITFIELDS */
+ private int biCompression;
+
+ /** Byte size of the uncompressed bitmap, can be 0. */
+ private int biSizeImage;
+
+ /** X resolution, dots per meter */
+ private int biXPelsPerMeter;
+
+ /** Y resolution, dots per meter */
+ private int biYPelsPerMeter;
+
+ /** Number of colors used (palette only, can be 0 for all) */
+ private int biClrUsed;
+
+ /** Number of 'important' colors, 0 for all */
+ private int biClrImportant;
+
+ /** BITMAPINFOHEADER is 40 bytes */
+ public static final int SIZE = 40;
+
+ /**
+ * Compression types
+ */
+ public static final int BI_RGB = 0;
+ public static final int BI_RLE8 = 1;
+ public static final int BI_RLE4 = 2;
+ public static final int BI_BITFIELDS = 3;
+
+ /**
+ * Creates the header from an input stream, which is not closed.
+ * @throws IOException if an I/O error occured.
+ * @throws BMPException if the header was invalid
+ */
+ public BMPInfoHeader(ImageInputStream in) throws IOException, BMPException {
+ byte[] data = new byte[SIZE];
+
+ if (in.read(data) != SIZE)
+ throw new IOException("Couldn't read header.");
+ ByteBuffer buf = ByteBuffer.wrap(data);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+
+ int n;
+ if((n=buf.getInt()) != SIZE)
+ throw new BMPException("Invalid BITMAPINFOHEADER size: "+n);
+
+ biWidth = buf.getInt();
+ biHeight = buf.getInt();
+ biPlanes = buf.getShort();
+ setBitCount(buf.getShort());
+ setCompression(buf.getInt());
+ biSizeImage = buf.getInt();
+ biXPelsPerMeter = buf.getInt();
+ biYPelsPerMeter = buf.getInt();
+ biClrUsed = buf.getInt();
+ biClrImportant = buf.getInt();
+ }
+
+ public void setBitCount(short bitcount) throws BMPException {
+ switch(bitcount){
+ case 1:
+ case 4:
+ case 8:
+ case 16:
+ case 24:
+ case 32:
+ biBitCount = bitcount;
+ break;
+
+ default:
+ throw new BMPException("Invalid number of bits per pixel: "+
+ bitcount);
+ }
+ }
+
+ public short getBitCount() { return biBitCount; }
+
+ public void setCompression(int compression) throws BMPException {
+ switch(compression){
+ case BI_RLE8:
+ if(getBitCount() != 8)
+ throw new BMPException("Invalid number of bits per pixel.");
+ biCompression = compression;
+ break;
+ case BI_RLE4:
+ if(getBitCount() != 4)
+ throw new BMPException("Invalid number of bits per pixel.");
+ biCompression = compression;
+ break;
+
+ case BI_RGB:
+ case BI_BITFIELDS:
+ biCompression = compression;
+ break;
+
+ default:
+ throw new BMPException("Unknown bitmap compression type.");
+ }
+ }
+
+ public int getNumberOfPaletteEntries(){
+ if(biClrUsed == 0)
+ switch(biBitCount){
+ case 1:
+ return 2;
+ case 4:
+ return 16;
+ case 8:
+ return 256;
+
+ default: // should not happen
+ return 0;
+ }
+
+ return biClrUsed;
+ }
+
+ public int getCompression(){
+ return biCompression;
+ }
+
+ public Dimension getSize(){
+ return new Dimension(biWidth, biHeight);
+ }
+
+ public int getWidth(){
+ return biWidth;
+ }
+
+ public int getHeight(){
+ return biHeight;
+ }
+
+ public void setSize(Dimension d){
+ biWidth = (int)d.getWidth();
+ biHeight = (int)d.getHeight();
+ }
+
+}
diff --git a/gnu/javax/imageio/bmp/DecodeBF16.java b/gnu/javax/imageio/bmp/DecodeBF16.java
new file mode 100644
index 000000000..702c93ab3
--- /dev/null
+++ b/gnu/javax/imageio/bmp/DecodeBF16.java
@@ -0,0 +1,104 @@
+/* DecodeBF16.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferUShort;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.Dimension;
+
+public class DecodeBF16 extends BMPDecoder {
+ private int[] bitmasks;
+ private boolean useDefaultMasks;
+
+ public DecodeBF16(BMPFileHeader fh, BMPInfoHeader ih,
+ boolean udm){
+ super(fh,ih);
+
+ useDefaultMasks = udm;
+ if(useDefaultMasks) // 5-6-5 mask, B,G,R
+ bitmasks = new int[] { 0x00F800, 0x0007E0, 0x00001F };
+ }
+
+ public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
+ if(!useDefaultMasks)
+ bitmasks = readBitMasks(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ // BMP scanlines are padded to dword offsets
+ int scansize = (w + (w&1)) << 1;
+ short[] data = new short[w*h];
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<w;x++)
+ data[x + y*w] = (short)((scanline[x*2] & (0xFF)) |
+ ((scanline[x*2+1] & (0xFF)) << 8));
+ }
+
+ ColorModel cm = new DirectColorModel(16,
+ bitmasks[0], bitmasks[1], bitmasks[2]);
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT,
+ w, h,
+ bitmasks);
+ DataBuffer db = new DataBufferUShort(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+ return new BufferedImage(cm, raster, false, null);
+ }
+
+}
+
+
+
diff --git a/gnu/javax/imageio/bmp/DecodeBF32.java b/gnu/javax/imageio/bmp/DecodeBF32.java
new file mode 100644
index 000000000..ee64f4b0e
--- /dev/null
+++ b/gnu/javax/imageio/bmp/DecodeBF32.java
@@ -0,0 +1,108 @@
+/* DecodeBF32.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.Dimension;
+
+public class DecodeBF32 extends BMPDecoder {
+ private int[] bitmasks;
+ private boolean useDefaultMasks;
+
+ public DecodeBF32(BMPFileHeader fh, BMPInfoHeader ih,
+ boolean udm){
+ super(fh,ih);
+
+ useDefaultMasks = udm;
+ if(useDefaultMasks)
+ bitmasks = new int[] { 0x00FF0000, 0x0000FF00, 0x000000FF };
+ }
+
+ public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
+ if(!useDefaultMasks)
+ bitmasks = readBitMasks(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ // BMP scanlines are padded to dword offsets
+ int scansize = w << 2;
+ int[] data = new int[w*h];
+
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<w;x++)
+ data[x + y*w] = ((scanline[x<<2] & (0xFF)) |
+ ((scanline[(x<<2)+1] & (0xFF)) << 8) |
+ ((scanline[(x<<2)+2] & (0xFF)) << 16) |
+ ((scanline[(x<<2)+3] & (0xFF)) << 24));
+ }
+
+ ColorModel cm = new DirectColorModel(32,
+ bitmasks[0], bitmasks[1], bitmasks[2]);
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
+ w, h,
+ bitmasks);
+ DataBuffer db = new DataBufferInt(data, w*h);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(cm, raster, false, null);
+ }
+
+}
+
+
+
diff --git a/gnu/javax/imageio/bmp/DecodeRGB1.java b/gnu/javax/imageio/bmp/DecodeRGB1.java
new file mode 100644
index 000000000..9ca82d9ee
--- /dev/null
+++ b/gnu/javax/imageio/bmp/DecodeRGB1.java
@@ -0,0 +1,96 @@
+/* DecodeRGB1.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.Dimension;
+
+public class DecodeRGB1 extends BMPDecoder {
+
+ public DecodeRGB1(BMPFileHeader fh, BMPInfoHeader ih){
+ super(fh, ih);
+ }
+
+ public BufferedImage decode(ImageInputStream in)
+ throws IOException, BMPException {
+
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+ int size = (w*h)>>3;
+
+ int scansize = w>>3;
+ byte[] data = new byte[size];
+
+ for(int y=h-1;y>=0;y--){
+ // Scanlines are padded to dword boundries
+ int readsize = scansize;
+ if((readsize & 3) != 0) readsize += (4 - (scansize & 3));
+
+ byte[] scanline = new byte[readsize];
+ if(in.read(scanline) != readsize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<scansize;x++)
+ data[x + y*scansize] = scanline[x];
+ }
+
+ SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h, 1);
+
+ DataBuffer db = new DataBufferByte(data, size, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
+ }
+
+}
+
+
diff --git a/gnu/javax/imageio/bmp/DecodeRGB24.java b/gnu/javax/imageio/bmp/DecodeRGB24.java
new file mode 100644
index 000000000..2a910cb30
--- /dev/null
+++ b/gnu/javax/imageio/bmp/DecodeRGB24.java
@@ -0,0 +1,77 @@
+/* DecodeRGB24.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.image.BufferedImage;
+import java.awt.Dimension;
+
+public class DecodeRGB24 extends BMPDecoder {
+
+ public DecodeRGB24(BMPFileHeader fh, BMPInfoHeader ih){
+ super(fh, ih);
+ }
+
+ public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+ BufferedImage image = new BufferedImage(w, h,
+ BufferedImage.TYPE_INT_RGB);
+ // BMP scanlines are padded to dword offsets
+ int scansize = ((w*3 & 3) != 0)? w*3 + 4 - (w*3 & 3): w*3;
+ int[] data = new int[w*h];
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<w;x++)
+ data[x + y*w] = scanline[x*3] +
+ (scanline[x*3+1] << 8) +
+ (scanline[x*3+2] << 16);
+ }
+ image.setRGB(0, 0, w, h, data, 0, w);
+ return image;
+ }
+
+}
diff --git a/gnu/javax/imageio/bmp/DecodeRGB4.java b/gnu/javax/imageio/bmp/DecodeRGB4.java
new file mode 100644
index 000000000..a10d390ab
--- /dev/null
+++ b/gnu/javax/imageio/bmp/DecodeRGB4.java
@@ -0,0 +1,92 @@
+/* DecodeRGB4.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.Dimension;
+
+public class DecodeRGB4 extends BMPDecoder {
+
+ public DecodeRGB4(BMPFileHeader fh, BMPInfoHeader ih){
+ super(fh, ih);
+ }
+
+ public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+ int size = (w*h) >> 1;
+
+ // Scanline padded to dword offsets
+ int wbytes = (w + (w & 1)) >> 1;
+ int scansize = ((wbytes & 3) != 0)? (wbytes + 4 - (wbytes&3)) : wbytes;
+
+ byte[] data = new byte[wbytes*h];
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<wbytes;x++)
+ data[x + y*wbytes] = scanline[x];
+ }
+ SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h, 4);
+
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
+ }
+
+}
+
+
diff --git a/gnu/javax/rmi/CORBA/ValueHandlerImpl.java b/gnu/javax/imageio/bmp/DecodeRGB8.java
index 906381fe4..dfe4a19e8 100644
--- a/gnu/javax/rmi/CORBA/ValueHandlerImpl.java
+++ b/gnu/javax/imageio/bmp/DecodeRGB8.java
@@ -1,5 +1,5 @@
-/* ValueHandlerImpl.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* DecodeRGB8.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,48 +35,56 @@ 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 gnu.javax.imageio.bmp;
-package gnu.javax.rmi.CORBA;
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.Dimension;
-import java.io.*;
-//import org.omg.CORBA.portable.InputStream;
-//import org.omg.CORBA.portable.OutputStream;
-//import org.omg.SendingContext.RunTime;
-import javax.rmi.CORBA.ValueHandler;
+public class DecodeRGB8 extends BMPDecoder {
-public class ValueHandlerImpl
- implements ValueHandler
-{
+ public DecodeRGB8(BMPFileHeader fh, BMPInfoHeader ih){
+ super(fh, ih);
+ }
- public String getRMIRepositoryID(Class clz)
- {
- throw new Error("Not implemented for ValueHandler");
- }
+ public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
- // XXX - Runtime -> RunTime
- public Runtime getRunTimeCodeBase()
- {
- throw new Error("Not implemented for ValueHandler");
- }
-
- public boolean isCustomMarshaled(Class clz)
- {
- throw new Error("Not implemented for ValueHandler");
- }
-
- // XXX - Runtime -> RunTime
- public Serializable readValue(InputStream in, int offset, Class clz, String repositoryID, Runtime sender)
- {
- throw new Error("Not implemented for ValueHandler");
- }
-
- public Serializable writeReplace(Serializable value)
- {
- throw new Error("Not implemented for ValueHandler");
- }
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ // BMP scanlines are padded to dword offsets
+ int scansize = ((w & 3) != 0)? w + 4 - (w & 3): w;
+ byte[] data = new byte[w*h];
+
+ for(int y=h-1;y>=0;y--){
+ byte[] scanline = new byte[scansize];
+ if(in.read(scanline) != scansize)
+ throw new IOException("Couldn't read image data.");
+
+ for(int x=0;x<w;x++)
+ data[x + y*w] = scanline[x];
+ }
+
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h,
+ new int[] {0xFF});
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
- public void writeValue(OutputStream out, Serializable value)
- {
- throw new Error("Not implemented for ValueHandler");
- }
+ return new BufferedImage(palette, raster, false, null);
+ }
+
}
+
+
diff --git a/gnu/javax/imageio/bmp/DecodeRLE4.java b/gnu/javax/imageio/bmp/DecodeRLE4.java
new file mode 100644
index 000000000..55d314f05
--- /dev/null
+++ b/gnu/javax/imageio/bmp/DecodeRLE4.java
@@ -0,0 +1,176 @@
+/* DecodeRLE4.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.Dimension;
+
+public class DecodeRLE4 extends BMPDecoder {
+
+ public DecodeRLE4(BMPFileHeader fh, BMPInfoHeader ih){
+ super(fh, ih);
+ }
+
+ /**
+ * RLE control codes
+ */
+ private static final byte ESCAPE = (byte)0;
+ private static final byte EOL = (byte)0; // end of line
+ private static final byte EOB = (byte)1; // end of bitmap
+ private static final byte DELTA = (byte)2; // delta
+
+ public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ byte[] data = uncompress(w, h, in);
+ SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h, 4);
+
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
+ }
+
+ private byte[] uncompress(int w, int h, ImageInputStream in)
+ throws BMPException, IOException {
+ byte[] cmd = new byte[2];
+ byte[] data = new byte[w*h>>1];
+ int offIn = 0;
+ int x=0,y=0;
+
+ // width in bytes
+ w += (w&1);
+ w = w >> 1;
+
+ try {
+ while(((x>>1) + y*w) < w*h){
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+
+ if(cmd[0] == ESCAPE){
+ switch(cmd[1]){
+ case EOB: // end of bitmap
+ return data;
+ case EOL: // end of line
+ x = 0;
+ y++;
+ break;
+ case DELTA: // delta
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+ int dx = cmd[0] & (0xFF);
+ int dy = cmd[1] & (0xFF);
+ x += dx;
+ y += dy;
+ break;
+
+ default:
+ // decode a literal run
+ int length = cmd[1] & (0xFF);
+
+ // size of run, which is word aligned.
+ int bytesize = length;
+ bytesize += (bytesize & 1);
+ bytesize >>= 1;
+ bytesize += (bytesize & 1);
+
+ byte[] run = new byte[bytesize];
+ if(in.read(run) != bytesize)
+ throw new IOException("Error reading compressed data.");
+
+ if((x&1) == 0){
+ length += (length&1);
+ length >>= 1;
+ System.arraycopy(run, 0, data, ((x>>1) + w*(h-y-1)),
+ length);
+ } else {
+ for(int i=0;i<length;i++){
+ if((i&1) == 0) // copy high to low
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((run[i>>1]&0xF0) >> 4);
+ else // copy low to high
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((run[i>>1]&0x0F) << 4);
+ }
+ }
+ x += cmd[1] & (0xFF);
+ break;
+ }
+ } else {
+ // decode a byte run
+ int length = cmd[0] & (0xFF);
+ if((x&1) == 0){
+ length += (length&1);
+ length >>= 1;
+ for(int i=0;i<length;i++)
+ data[(h-y-1)*w + i + (x >> 1)] = cmd[1];
+ } else {
+ for(int i=0;i<length;i++){
+ if((i&1) == 0) // copy high to low
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((cmd[1]&0xF0) >> 4);
+ else // copy low to high
+ data[((x+i)>>1) + w*(h-y-1)]
+ |= ((cmd[1]&0x0F) << 4);
+ }
+ }
+ x += cmd[0] & (0xFF);
+ }
+ }
+ return data;
+ } catch(ArrayIndexOutOfBoundsException e){
+ throw new BMPException("Invalid RLE data.");
+ }
+ }
+}
+
diff --git a/gnu/javax/imageio/bmp/DecodeRLE8.java b/gnu/javax/imageio/bmp/DecodeRLE8.java
new file mode 100644
index 000000000..1d00e6751
--- /dev/null
+++ b/gnu/javax/imageio/bmp/DecodeRLE8.java
@@ -0,0 +1,143 @@
+/* DecodeRLE8.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.javax.imageio.bmp;
+
+import java.io.IOException;
+import javax.imageio.stream.ImageInputStream;
+import java.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.Dimension;
+
+public class DecodeRLE8 extends BMPDecoder {
+
+ public DecodeRLE8(BMPFileHeader fh, BMPInfoHeader ih){
+ super(fh, ih);
+ }
+
+ /**
+ * RLE control codes
+ */
+ private static final byte ESCAPE = (byte)0;
+ private static final byte EOL = (byte)0; // end of line
+ private static final byte EOB = (byte)1; // end of bitmap
+ private static final byte DELTA = (byte)2; // delta
+
+ public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
+ IndexColorModel palette = readPalette(in);
+ skipToImage(in);
+
+ Dimension d = infoHeader.getSize();
+ int h = (int)d.getHeight();
+ int w = (int)d.getWidth();
+
+ byte[] data = uncompress(w, h, in);
+ SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ w, h,
+ new int[] {0xFF});
+ DataBuffer db = new DataBufferByte(data, w*h, 0);
+ WritableRaster raster = Raster.createWritableRaster(sm, db, null);
+
+ return new BufferedImage(palette, raster, false, null);
+ }
+
+ private byte[] uncompress(int w, int h, ImageInputStream in)
+ throws BMPException, IOException {
+ byte[] cmd = new byte[2];
+ byte[] data = new byte[w*h];
+ int offIn = 0;
+ int x=0,y=0;
+
+ try {
+ while((x + y*w) < w*h){
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+
+ if(cmd[0] == ESCAPE){
+ switch(cmd[1]){
+ case EOB: // end of bitmap
+ return data;
+ case EOL: // end of line
+ x = 0;
+ y++;
+ break;
+ case DELTA: // delta
+ if(in.read(cmd) != 2)
+ throw new IOException("Error reading compressed data.");
+ int dx = cmd[0] & (0xFF);
+ int dy = cmd[1] & (0xFF);
+ x += dx;
+ y += dy;
+ break;
+
+ default:
+ // decode a literal run
+ int length = cmd[1] & (0xFF);
+ int copylength = length;
+
+ // absolute mode must be word-aligned
+ length += (length & 1);
+
+ byte[] run = new byte[length];
+ if(in.read(run) != length)
+ throw new IOException("Error reading compressed data.");
+
+ System.arraycopy(run, 0, data, (x+w*(h-y-1)),
+ copylength);
+ x += copylength;
+ break;
+ }
+ } else {
+ // decode a byte run
+ int length = cmd[0] & (0xFF);
+ for(int i=0;i<length;i++)
+ data[(h-y-1)*w + x++] = cmd[1];
+ }
+ }
+ return data;
+ } catch(ArrayIndexOutOfBoundsException e){
+ throw new BMPException("Invalid RLE data.");
+ }
+ }
+}
+
diff --git a/gnu/javax/rmi/CORBA/CorbaInput.java b/gnu/javax/rmi/CORBA/CorbaInput.java
new file mode 100644
index 000000000..e80cabf6b
--- /dev/null
+++ b/gnu/javax/rmi/CORBA/CorbaInput.java
@@ -0,0 +1,297 @@
+/* CorbaInput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.CDR.gnuRuntime;
+
+import org.omg.CORBA_2_3.portable.InputStream;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+/**
+ * Converts calls on java ObjectOutputStream to calls on CORBA OutputStream. A
+ * class to substitute for objects using readObject method.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class CorbaInput
+ extends ObjectInputStream
+ implements ObjectInput
+{
+
+ /**
+ * The underlying CORBA stream from where the actual input is taken.
+ */
+ public InputStream stream;
+
+ /**
+ * The utility class to write the object fields in default way.
+ */
+ final RmiUtilities util;
+
+ /**
+ * The object currently being read.
+ */
+ Object current;
+
+ /**
+ * The offset of the object currently being read.
+ */
+ int offset;
+
+ /**
+ * The repository id of the object currently being read.
+ */
+ String rid;
+
+ /**
+ * The runtime, related to the object currently being read.
+ */
+ gnuRuntime runtime;
+
+ /**
+ * Create an instance, delegating calls to the given CORBA stream.
+ */
+ public CorbaInput(InputStream an_input, Object firstObject,
+ RmiUtilities an_util, int an_offset, String a_rid,
+ gnuRuntime a_runtime)
+ throws Exception
+ {
+ stream = an_input;
+ current = firstObject;
+ util = an_util;
+
+ offset = an_offset;
+ rid = a_rid;
+ runtime = a_runtime;
+ }
+
+ /** @inheritDoc */
+ public int available()
+ throws IOException
+ {
+ return stream.available();
+ }
+
+ /**
+ * No action.
+ */
+ public void close()
+ throws IOException
+ {
+ }
+
+ /** @inheritDoc */
+ public void defaultReadObject()
+ throws IOException, ClassNotFoundException
+ {
+ util.readFields(offset, rid, (Serializable) current, stream, runtime);
+ }
+
+ /** @inheritDoc */
+ public void mark(int readlimit)
+ {
+ stream.mark(readlimit);
+ }
+
+ /** @inheritDoc */
+ public boolean markSupported()
+ {
+ return stream.markSupported();
+ }
+
+ /** @inheritDoc */
+ public int read()
+ throws IOException
+ {
+ return stream.read();
+ }
+
+ /** @inheritDoc */
+ public int read(byte[] buf, int off, int len)
+ throws IOException
+ {
+ return stream.read(buf, off, len);
+ }
+
+ /** @inheritDoc */
+ public int read(byte[] b)
+ throws IOException
+ {
+ return stream.read(b);
+ }
+
+ /** @inheritDoc */
+ public boolean readBoolean()
+ throws IOException
+ {
+ return stream.read_boolean();
+ }
+
+ /** @inheritDoc */
+ public byte readByte()
+ throws IOException
+ {
+ return (byte) stream.read();
+ }
+
+ /** @inheritDoc */
+ public char readChar()
+ throws IOException
+ {
+ return stream.read_char();
+ }
+
+ /** @inheritDoc */
+ public double readDouble()
+ throws IOException
+ {
+ return stream.read_double();
+ }
+
+ /** @inheritDoc */
+ public float readFloat()
+ throws IOException
+ {
+ return stream.read_float();
+ }
+
+ /** @inheritDoc */
+ public void readFully(byte[] buf, int off, int len)
+ throws IOException
+ {
+ // This class only reads from the buffered streams.
+ stream.read(buf, off, len);
+ }
+
+ /** @inheritDoc */
+ public void readFully(byte[] buf)
+ throws IOException
+ {
+ // This class only reads from the buffered streams.
+ stream.read(buf);
+ }
+
+ /** @inheritDoc */
+ public int readInt()
+ throws IOException
+ {
+ return stream.read_long();
+ }
+
+ /** @inheritDoc */
+ public String readLine()
+ throws IOException
+ {
+ return new DataInputStream(this).readLine();
+ }
+
+ /** @inheritDoc */
+ public long readLong()
+ throws IOException
+ {
+ return stream.read_longlong();
+ }
+
+ /** @inheritDoc */
+ public short read_short()
+ throws IOException
+ {
+ return stream.read_short();
+ }
+
+ /** @inheritDoc */
+ public int readUnsignedByte()
+ throws IOException
+ {
+ return (stream.read() & 0xFF);
+ }
+
+ /** @inheritDoc */
+ public int readUnsignedShort()
+ throws IOException
+ {
+ return (stream.read_short() & 0xFFFF);
+ }
+
+ /**
+ * Read as wide string (not as UTF).
+ */
+ public String readUTF()
+ throws IOException
+ {
+ return stream.read_wstring();
+ }
+
+ /** @inheritDoc */
+ public void reset()
+ throws IOException
+ {
+ stream.reset();
+ }
+
+ /** @inheritDoc */
+ public long skip(long n)
+ throws IOException
+ {
+ return stream.skip(n);
+ }
+
+ /** @inheritDoc */
+ public int skipBytes(int len)
+ throws IOException
+ {
+ return (int) stream.skip(len);
+ }
+
+ /**
+ * Objects are read as abstract interfaces.
+ */
+ protected Object readObjectOverride()
+ throws IOException, ClassNotFoundException
+ {
+ current = stream.read_abstract_interface();
+ return current;
+ }
+
+}
diff --git a/gnu/javax/rmi/CORBA/CorbaOutput.java b/gnu/javax/rmi/CORBA/CorbaOutput.java
new file mode 100644
index 000000000..1c7234079
--- /dev/null
+++ b/gnu/javax/rmi/CORBA/CorbaOutput.java
@@ -0,0 +1,219 @@
+/* CorbaOutput.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * A class to substitute as an ObjectOutputStream for objects using writeObject
+ * method.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class CorbaOutput
+ extends ObjectOutputStream
+ implements ObjectOutput
+{
+ /**
+ * A CORBA stream where the output is forwarded.
+ */
+ final OutputStream stream;
+
+ /**
+ * The utility class to write the object fields in default way.
+ */
+ final RmiUtilities util;
+
+ /**
+ * The object currently being written.
+ */
+ Object current;
+
+ /**
+ * Create an instance, delegating calls to the given CORBA stream.
+ */
+ public CorbaOutput(OutputStream an_output, Object firstObject,
+ RmiUtilities an_util)
+ throws Exception
+ {
+ stream = an_output;
+ current = firstObject;
+ util = an_util;
+ }
+
+ /**
+ * No action.
+ */
+ public void close()
+ throws IOException
+ {
+ }
+
+ /** @inheritDoc */
+ public void flush()
+ throws IOException
+ {
+ stream.flush();
+ }
+
+ /** @inheritDoc */
+ public void write(byte[] buf, int off, int len)
+ throws IOException
+ {
+ stream.write(buf, off, len);
+ }
+
+ /** @inheritDoc */
+ public void write(byte[] buf)
+ throws IOException
+ {
+ stream.write(buf);
+ }
+
+ /** @inheritDoc */
+ public void write(int val)
+ throws IOException
+ {
+ stream.write(val);
+ }
+
+ /** @inheritDoc */
+ public void writeBoolean(boolean val)
+ throws IOException
+ {
+ stream.write_boolean(val);
+ }
+
+ /** @inheritDoc */
+ public void writeByte(int val)
+ throws IOException
+ {
+ stream.write(val);
+ }
+
+ /** @inheritDoc */
+ public void writeBytes(String str)
+ throws IOException
+ {
+ stream.write_string(str);
+ }
+
+ /** @inheritDoc */
+ public void writeChar(int val)
+ throws IOException
+ {
+ stream.write_wchar((char) val);
+ }
+
+ /** @inheritDoc */
+ public void writeChars(String str)
+ throws IOException
+ {
+ stream.write_char_array(str.toCharArray(), 0, str.length());
+ }
+
+ /** @inheritDoc */
+ public void writeDouble(double val)
+ throws IOException
+ {
+ stream.write_double(val);
+ }
+
+ /** @inheritDoc */
+ public void writeFloat(float val)
+ throws IOException
+ {
+ stream.write_float(val);
+ }
+
+ /** @inheritDoc */
+ public void writeInt(int val)
+ throws IOException
+ {
+ stream.write_long(val);
+ }
+
+ /** @inheritDoc */
+ public void writeLong(long val)
+ throws IOException
+ {
+ stream.write_longlong(val);
+ }
+
+ /**
+ * Objects are written as abstract interfaces.
+ */
+ protected void writeObjectOverride(Object obj)
+ throws IOException
+ {
+ current = obj;
+ stream.write_abstract_interface(obj);
+ }
+
+ /** @inheritDoc */
+ public void writeShort(int val)
+ throws IOException
+ {
+ stream.write_short((short) val);
+ }
+
+ /**
+ * Such strings are written as wide strings, not as UTF.
+ */
+ public void writeUTF(String str)
+ throws IOException
+ {
+ stream.write_wstring(str);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public void defaultWriteObject()
+ throws IOException
+ {
+ util.writeFields(stream, (Serializable) current);
+ }
+
+}
diff --git a/gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java b/gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java
new file mode 100644
index 000000000..5bdf7dac9
--- /dev/null
+++ b/gnu/javax/rmi/CORBA/DefaultWriteObjectTester.java
@@ -0,0 +1,85 @@
+/* DefaultWriteObjectTester.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.CDR.BufferedCdrOutput;
+
+import java.io.IOException;
+
+/**
+ * Tests if the defaultWriteObject method has been called.
+ * This information is required by RMI-IIOP header.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class DefaultWriteObjectTester
+ extends CorbaOutput
+{
+ /**
+ * The flag, indicating, that the defaultWriteObject method was called.
+ */
+ public boolean dwo_called;
+
+ /**
+ * Create an instance, delegating calls to the given CORBA stream.
+ */
+ public DefaultWriteObjectTester(Object firstObject)
+ throws Exception
+ {
+ super(new BufferedCdrOutput(), firstObject, null);
+ }
+
+ /**
+ * Set the flag that defaultWriteObject was called.
+ */
+ public void defaultWriteObject()
+ throws IOException
+ {
+ dwo_called = true;
+ }
+
+ /**
+ * Do not write other objects.
+ */
+ protected void writeObjectOverride(Object obj)
+ throws IOException
+ {
+ }
+
+}
diff --git a/gnu/javax/rmi/CORBA/DelegateFactory.java b/gnu/javax/rmi/CORBA/DelegateFactory.java
index d71546d75..0607c9f96 100644
--- a/gnu/javax/rmi/CORBA/DelegateFactory.java
+++ b/gnu/javax/rmi/CORBA/DelegateFactory.java
@@ -1,5 +1,5 @@
/* DelegateFactory.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,38 +38,70 @@ exception statement from your version. */
package gnu.javax.rmi.CORBA;
-import java.util.HashMap;
+import gnu.CORBA.ObjectCreator;
+
+/**
+ * This class produces delegates, using the system properties. If not
+ * corresponding property is specified, returns default implementations.
+ *
+ * @author Wu Gansha (gansha.wu@intel.com)
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
public class DelegateFactory
{
- private static HashMap cache = new HashMap(4);
-
- public static synchronized Object getInstance(String type)
- throws GetDelegateInstanceException
+ /**
+ * The name to get a stub delegate.
+ */
+ public static final String STUB = "Stub";
+
+ /**
+ * The name to get the util delegate.
+ */
+ public static final String UTIL = "Util";
+
+ /**
+ * The name to get the ValueHandler delegate.
+ */
+ public static final String VALUEHANDLER = "ValueHandler";
+
+ /**
+ * The name to get the PortableRemoteObject delegate.
+ */
+ public static final String PORTABLE_REMOTE_OBJECT = "PortableRemoteObject";
+
+ /**
+ * Get an instance of the given delegate. As in all cases the singleton
+ * instance is used, the caching here would be redundant.
+ *
+ * @param type a delegate type.
+ *
+ * @return the associated delegate.
+ *
+ * @throws InternalError if the delegate class, indicated in the system
+ * properties, cannot be instantiated.
+ */
+ public static Object getInstance(String type)
+ throws InternalError
{
- Object r = cache.get(type);
- if (r != null)
- return r;
- String dcname = System.getProperty("javax.rmi.CORBA." + type + "Class");
+ String propertyName = "javax.rmi.CORBA." + type + "Class";
+ String dcname = System.getProperty(propertyName);
if (dcname == null)
{
- //throw new DelegateException
- // ("no javax.rmi.CORBA.XXXClass property sepcified.");
- dcname = "gnu.javax.rmi.CORBA." + type + "DelegateImpl";
+ // // No javax.rmi.CORBA.XXXClass property sepcified.
+ dcname = "gnu.javax.rmi.CORBA." + type + "DelegateImpl";
}
try
{
- Class dclass = Class.forName(dcname,
- true,
- Thread.currentThread().getContextClassLoader());
- r = dclass.newInstance();
- cache.put(type, r);
- return r;
+ Class dclass = ObjectCreator.forName(dcname);
+ return dclass.newInstance();
}
- catch(Exception e)
+ catch (Exception e)
{
- throw new GetDelegateInstanceException
- ("Exception when trying to get delegate instance:" + dcname, e);
+ InternalError ierr = new InternalError("Exception when trying to get "
+ + type + "delegate instance:" + dcname);
+ ierr.initCause(e);
+ throw ierr;
}
}
}
diff --git a/gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java b/gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java
index 6a7e6b746..ea4f73811 100644
--- a/gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java
+++ b/gnu/javax/rmi/CORBA/PortableRemoteObjectDelegateImpl.java
@@ -1,5 +1,5 @@
/* PortableRemoteObjectDelegateImpl.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,99 +38,325 @@ exception statement from your version. */
package gnu.javax.rmi.CORBA;
-import gnu.javax.rmi.PortableServer;
+import gnu.CORBA.SimpleDelegate;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.Poa.LocalDelegate;
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Poa.AOM;
import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
+import java.rmi.server.RMIClassLoader;
import javax.rmi.CORBA.PortableRemoteObjectDelegate;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
+
+/**
+ * Implements PortableRemoteObjectDelegate.
+ *
+ * @author Wu Gansha (gansha.wu@intel.com) (stub)
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) (implementation)
+ */
public class PortableRemoteObjectDelegateImpl
implements PortableRemoteObjectDelegate
{
-
- public PortableRemoteObjectDelegateImpl()
- {
- }
-
- public void connect(Remote remote, Remote remote1)
+ /**
+ * <p>
+ * Makes the remote object <code>a_target</code> ready for remote
+ * communication using the same communications runtime as for the passed
+ * <code>a_source</code> parameter. The a_target is connected to the same
+ * ORB (and, if applicable, to the same POA) as the a_source.
+ *
+ * @param a_target the target to connect to ORB, must be an instance of either
+ * {@link ObjectImpl} (Stubs and old-style ties) or {@link Servant} (POA-bases
+ * ties).
+ *
+ * @param a_source the object, providing the connection information, must be
+ * an instance of either {@link ObjectImpl} (Stubs and old-style ties) or
+ * {@link Servant} (POA-bases ties).
+ *
+ * @throws RemoteException if the target is already connected to another ORB.
+ */
+ public void connect(Remote a_target, Remote a_source)
throws RemoteException
{
- throw new Error("Not implemented for PortableRemoteObjectDelegateImpl");
- }
-
- public void exportObject(Remote obj)
- throws RemoteException
- {
- PortableServer.exportObject(obj);
+ ORB orb = null;
+ POA poa = null;
+ boolean ok = false;
+
+ try
+ {
+ if (a_source instanceof Servant)
+ {
+ Servant s = (Servant) a_source;
+ orb = s._orb();
+ poa = s._poa();
+ ok = true;
+ }
+
+ if (!ok && a_source instanceof ObjectImpl)
+ {
+ ObjectImpl o = (ObjectImpl) a_source;
+ orb = o._orb();
+ ok = true;
+ try
+ {
+ if (orb instanceof ORB_1_4)
+ {
+ // POA information available.
+ ORB_1_4 xorb = (ORB_1_4) orb;
+ Delegate d = o._get_delegate();
+
+ if (d instanceof LocalDelegate)
+ {
+ LocalDelegate l = (LocalDelegate) d;
+ poa = l.poa;
+ }
+ else if (d instanceof SimpleDelegate)
+ {
+ byte[] ior_key = ((SimpleDelegate) d).getIor().key;
+ AOM.Obj ref = xorb.rootPOA.findIorKey(ior_key);
+ if (ref != null)
+ poa = ref.poa;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ // OK, POA info is not available, but as ORB is available, we
+ // will connect in a default way.
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ RuntimeException rex = new RuntimeException("Unable to get info from "
+ + a_source);
+ rex.initCause(ex);
+ throw rex;
+ }
+
+ if (!ok && a_source instanceof Tie)
+ {
+ Tie t = (Tie) a_source;
+ orb = t.orb();
+ poa = null;
+ ok = true;
+ }
+
+ if (orb == null)
+ throw new RemoteException("Unable to determine ORB from " + a_source);
+
+ if (a_target instanceof Stub)
+ {
+ StubDelegateImpl.connect((Stub) a_target, orb, poa);
+ }
+ else if (a_target instanceof Servant)
+ {
+ try
+ {
+ if (poa == null)
+ {
+ poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+ // Activate if not active.
+ if (poa.the_POAManager().get_state().value() == State._HOLDING)
+ poa.the_POAManager().activate();
+ }
+ poa.servant_to_reference((Servant) a_target);
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ else if (a_target instanceof org.omg.CORBA.Object)
+ {
+ // Connect as object.
+ orb.connect((org.omg.CORBA.Object) a_target);
+ }
+ else if (a_target instanceof Tie)
+ {
+ // We avoid calling this because it will aways connect to the root poa.
+ ((Tie) a_target).orb(orb);
+ }
}
+ /**
+ * Narrow the given object to the instance of the given class. The currently
+ * supported narrowing types are:
+ *
+ * 1. Simple widening conversion.<br>
+ * 2. ObjectImpl -> RMI interface.<br>
+ * 3. ObjectImpl -> ObjectImpl.<br>
+ * 4. Tie -> Remote (implementation)<br>
+ * 5. Remote (implementation) -> Tie.<br>
+ *
+ * The narrowing has sense only for derived classes.
+ */
public Object narrow(Object narrowFrom, Class narrowTo)
throws ClassCastException
{
if (narrowTo == null)
throw new ClassCastException("Can't narrow to null class");
- if (narrowFrom == null)
+ else if (narrowFrom == null)
return null;
+ else
+ // Simple narrowing case.
+ if (narrowTo.isAssignableFrom(narrowFrom.getClass()))
+ return narrowFrom;
+ else if (narrowTo.isInterface() || narrowFrom instanceof ObjectImpl)
+ {
+ // Narrow CORBA object to passed interface.
+
+ String interf = narrowTo.getName();
+ String stubClassName;
- Class fromClass = narrowFrom.getClass();
- Object result = null;
-
+ stubClassName = getStubClassName(interf);
+
+ try
+ {
+ // Replace the interface class by the stub class.
+ narrowTo = Util.loadClass(stubClassName, null,
+ narrowTo.getClassLoader());
+ }
+ catch (ClassNotFoundException e)
+ {
+ ClassCastException cex = new ClassCastException("Class not found: "
+ + stubClassName);
+ cex.initCause(e);
+ throw cex;
+ }
+ }
+ else if (narrowFrom instanceof Tie)
+ {
+ // Try to substitute the return tie target as a return value.
+ Remote target = ((Tie) narrowFrom).getTarget();
+ if (target != null && narrowTo.isAssignableFrom(target.getClass()))
+ return target;
+ }
+
+ Object narrowed;
try
{
- if (narrowTo.isAssignableFrom(fromClass))
- result = narrowFrom;
- else
- {
- System.out.println("We still haven't implement this case: narrow "
- + narrowFrom + " of type " + fromClass + " to "
- + narrowTo);
- Class[] cs = fromClass.getInterfaces();
- for (int i = 0; i < cs.length; i++)
- System.out.println(cs[i]);
- Exception e1 = new Exception();
- try
- {
- throw e1;
- }
- catch(Exception ee)
- {
- ee.printStackTrace();
- }
- System.exit(2);
- //throw new Error("We still haven't implement this case: narrow "
- // + narrowFrom + " of type " + fromClass + " to "
- // + narrowTo);
- /*
- ObjectImpl objimpl = (ObjectImpl)narrowFrom;
- if(objimpl._is_a(PortableServer.getTypeName(narrowTo)))
- result = PortableServer.getStubFromObjectImpl(objimpl, narrowTo);
- */
- }
- }
- catch(Exception e)
- {
- result = null;
- }
-
- if (result == null)
- throw new ClassCastException("Can't narrow from "
- + fromClass + " to " + narrowTo);
-
- return result;
+ narrowed = narrowTo.newInstance();
+ }
+ catch (Exception e)
+ {
+ ClassCastException cex = new ClassCastException("Cannot instantiate "
+ + narrowTo.getName());
+ cex.initCause(e);
+ throw cex;
+ }
+
+ if (narrowed instanceof ObjectImpl)
+ {
+ // This also works for the instances of the Stub.
+ ObjectImpl target = (ObjectImpl) narrowed;
+ // Set the delegate, as is done in *Helper.narrow(..).
+ target._set_delegate(((ObjectImpl) narrowFrom)._get_delegate());
+ }
+ else if (narrowed instanceof Tie && narrowFrom instanceof Remote)
+ {
+ // Try to set the narrowing object as a target for the Tie.
+ ((Tie) narrowed).setTarget((Remote) narrowFrom);
+ }
+ else
+ throw new ClassCastException("Narrowing of " + narrowFrom.getClass()
+ + " to " + narrowTo + " is either not possible or not implemented.");
+
+ return narrowed;
}
-
- public Remote toStub(Remote obj)
+
+ /**
+ * Get the Stub class name for the name, representing the given interface.
+ */
+ static String getStubClassName(String interf)
+ {
+ String stubClassName;
+ int p = interf.lastIndexOf('.');
+
+ if (p < 0)
+ // The interface is defined in the default package.
+ stubClassName = "_" + interf + "_Stub";
+ else
+ stubClassName = interf.substring(0, p + 1) + "_"
+ + interf.substring(p + 1) + "_Stub";
+ return stubClassName;
+ }
+
+ /**
+ * Get stub for the given implementation, searching by class name pattern. The
+ * found stub must implement Remote for this method to succeed.
+ */
+ public Remote toStub(Remote ObjImpl)
throws NoSuchObjectException
{
- return PortableServer.toStub(obj);
+ String icn = ObjImpl.getClass().getName();
+ if (!icn.endsWith("Impl"))
+ throw new BAD_PARAM("Invalid class name '" + icn
+ + "', must end with 'Impl'");
+
+ String sn = "_" + icn.substring(0, icn.length() - "Impl".length())
+ + "_Stub";
+
+ Class stubClass;
+ Object o_stub;
+
+ try
+ {
+ stubClass = RMIClassLoader.loadClass(sn);
+ o_stub = stubClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ NoSuchObjectException n = new NoSuchObjectException(sn);
+ n.initCause(e);
+ throw n;
+ }
+
+ if (!Remote.class.isAssignableFrom(stubClass))
+ throw new ClassCastException(stubClass.getName()
+ + " exists but cannot be returned as it does not inherit from "
+ + Remote.class.getName());
+
+ return (Remote) o_stub;
}
+ /**
+ * If the object tie is no longer in use, disconnet it from the orb.
+ */
public void unexportObject(Remote obj)
throws NoSuchObjectException
{
- PortableServer.unexportObject(obj);
+ Util.unexportObject(obj);
+ }
+
+ /**
+ * Find or create a tie for this target and mark it as being used by the given
+ * object.
+ */
+ public void exportObject(Remote obj)
+ throws RemoteException
+ {
+ if (obj instanceof Stub)
+ Util.registerTarget(StubDelegateImpl.getTieFromStub((Stub) obj), obj);
+ else if (obj instanceof Tie)
+ {
+ Tie t = (Tie) obj;
+ Util.registerTarget(t, null);
+ }
}
}
diff --git a/gnu/javax/rmi/CORBA/RmiUtilities.java b/gnu/javax/rmi/CORBA/RmiUtilities.java
new file mode 100644
index 000000000..91bfa3776
--- /dev/null
+++ b/gnu/javax/rmi/CORBA/RmiUtilities.java
@@ -0,0 +1,946 @@
+/* RmiUtilities.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.OrbFunctional;
+import gnu.CORBA.Minor;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.CDR.Vio;
+import gnu.CORBA.CDR.gnuRuntime;
+import gnu.CORBA.CDR.gnuValueStream;
+import gnu.CORBA.CDR.HeadlessInput;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.StringValueHelper;
+import org.omg.CORBA.WStringValueHelper;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ValueBase;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
+import org.omg.SendingContext.RunTime;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.rmi.Remote;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.TreeSet;
+import java.util.WeakHashMap;
+
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+
+/**
+ * Defines methods that must be accessible in several derived classes.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class RmiUtilities
+{
+ /**
+ * The currently used RMI-IIOP version format.
+ */
+ public static byte VERSION = 1;
+
+ /**
+ * The non - writable class fields.
+ */
+ static final int NON_WRITABLE = Modifier.STATIC | Modifier.TRANSIENT;
+
+ /**
+ * The standard String repository Id.
+ */
+ public static final String RMI_STRING_ID = StringValueHelper.id();
+
+ /**
+ * The standard Class repository Id.
+ */
+ public static final String RMI_CLASS_ID = "RMI:javax.rmi.CORBA.ClassDesc:2BABDA04587ADCCC:CFBF02CF5294176B";
+
+ /**
+ * The standard string array repository Id.
+ */
+ public static final String RMI_STRING_ARRAY_ID = "RMI:[Ljava.lang.String;:071DA8BE7F971128:A0F0A4387A3BB342";
+
+ /**
+ * An instance of the wide string value helper for writing strings.
+ */
+ static WStringValueHelper wStringValueHelper = new WStringValueHelper();
+
+ /**
+ * Set of serializable classes that have .writeObject and .readObject defined.
+ * Contains weak references to ensure that the classes will be unloadable.
+ */
+ WeakHashMap io_format = new WeakHashMap();
+
+ /**
+ * The standard IO format with no .writeObject and .readObject defined.
+ */
+ static final Object STANDARD = new Object();
+
+ /**
+ * The custom IO format with .writeObject and .readObject defined,
+ * defaultWriteObject called.
+ */
+ static final Object CUSTOM_DWO = new Object();
+
+ /**
+ * The custom IO format with .writeObject and .readObject defined,
+ * defaultWriteObject has not been called.
+ */
+ static final Object CUSTOM_NO_DWO = new Object();
+
+ /**
+ * The arguments for readObject.
+ */
+ static final Class[] READ_OBJECT_ARGS = new Class[] { ObjectInputStream.class };
+
+ /**
+ * The arguments for writeObject.
+ */
+ static final Class[] WRITE_OBJECT_ARGS = new Class[] { ObjectOutputStream.class };
+
+ /**
+ * The undocumented field that is heading the Sun's object data, written with
+ * writeObject.
+ */
+ static final int S_X = 16908034;
+
+ /**
+ * Write all fields of the passed value.
+ */
+ void writeFields(OutputStream an_output, Serializable object)
+ {
+ org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+ try
+ {
+ Class o_class = object.getClass();
+ Field[] fields = getWritableFields(o_class);
+ Field f;
+
+ Class fc;
+
+ for (int i = 0; i < fields.length; i++)
+ {
+ f = fields[i];
+ fc = f.getType();
+ Object v = f.get(object);
+
+ if (fc == String.class)
+ {
+ output.write_value((Serializable) v, wStringValueHelper);
+ }
+ else if (fc == int.class)
+ output.write_long(((Integer) v).intValue());
+ else if (fc == long.class)
+ output.write_longlong(((Number) v).longValue());
+ else if (fc == double.class)
+ output.write_double(((Number) v).doubleValue());
+ else if (fc == float.class)
+ output.write_float(((Number) v).floatValue());
+ else if (fc == boolean.class)
+ output.write_boolean(((Boolean) v).booleanValue());
+ else if (fc == short.class)
+ output.write_short(((Number) v).shortValue());
+ else if (fc == byte.class)
+ output.write_octet(((Number) v).byteValue());
+ else if (fc == char.class)
+ output.write_wchar(((Character) v).charValue());
+ else
+ {
+ if (!fc.isInterface() && Remote.class.isAssignableFrom(fc))
+ fc = getExportedInterface(fc);
+ writeMember(output, v, fc);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Cannot write " + object);
+ m.minor = Minor.ValueFields;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Write a memeber (field) of the data structure.
+ */
+ void writeMember(org.omg.CORBA_2_3.portable.OutputStream output,
+ Object object, Class xClass)
+ {
+ if (output instanceof gnuValueStream)
+ {
+ gnuRuntime g = ((gnuValueStream) output).getRunTime();
+ // Reset the target as we are already beyond the critical point
+ // where is must have the value being written.
+ if (g != null)
+ g.target = null;
+ }
+ if (Serializable.class.isAssignableFrom(xClass)
+ || Remote.class.isAssignableFrom(xClass))
+ {
+ // Object handles null reference on its own.
+ if (org.omg.CORBA.Object.class.isAssignableFrom(xClass)
+ || Remote.class.isAssignableFrom(xClass))
+ {
+ if (object == null)
+ output.write_Object(null);
+ else if (isTieRequired(object))
+ exportTie(output, object, xClass);
+ else
+ writeValue(output, (Serializable) object);
+ }
+ else
+ output.write_value((Serializable) object, xClass);
+ }
+ else
+ {
+ MARSHAL m = new MARSHAL(xClass + " is not Serializable");
+ m.minor = Minor.NonSerializable;
+ throw m;
+ }
+ }
+
+ /**
+ * Check if the object must be wrapped into Tie, connected to the ORB and then
+ * the corresponding Stub be written.
+ */
+ public boolean isTieRequired(Object object)
+ {
+ return object instanceof Remote && !(object instanceof Stub);
+ }
+
+ /**
+ * Get the interface under that the class of this object must be exposed. The
+ * interface must be derived from Remote.
+ */
+ Class getExportedInterface(Object object)
+ throws MARSHAL
+ {
+ Class fc = null;
+ Class[] interfaces = object.getClass().getInterfaces();
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ if (!Remote.class.equals(interfaces[i]))
+ if (Remote.class.isAssignableFrom(interfaces[i]))
+ {
+ if (fc == null)
+ fc = interfaces[i];
+ else
+ {
+ MARSHAL m = new MARSHAL("Both " + fc + " and " + interfaces[i]
+ + " extends Remote");
+ m.minor = Minor.TargetConversion;
+ throw m;
+ }
+ }
+ }
+ if (fc == null)
+ {
+ MARSHAL m = new MARSHAL(object.getClass()
+ + " does not implement any interface, derived from Remote");
+ m.minor = Minor.TargetConversion;
+ throw m;
+ }
+ return fc;
+ }
+
+ /**
+ * Get the persistent hash code for the given class, as defined by OMG
+ * standard. The inheritance, field names and types (but not the visibility)
+ * are taken into consideration as well as the presence of the writeObject
+ * method are taken into consideration. The class name and methods, if any,
+ * are not taken into consideration.
+ */
+ public static long getHashCode(Class c)
+ {
+ Class of = c.isArray() ? c.getComponentType() : null;
+ if (c.isArray()
+ && ((!Serializable.class.isAssignableFrom(of) || of.isPrimitive() || Remote.class.isAssignableFrom(of))))
+ return 0;
+ if (!Serializable.class.isAssignableFrom(c))
+ return 0;
+ try
+ {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ DataOutputStream out = new DataOutputStream(bout);
+
+ Class superClass = c.getSuperclass();
+ if (superClass != null)
+ out.writeLong(getHashCode(superClass));
+
+ int writeObjectPresentCode;
+ try
+ {
+ c.getDeclaredMethod("writeObject",
+ new Class[] { ObjectOutputStream.class });
+ writeObjectPresentCode = 2; // Exists.
+ }
+ catch (NoSuchMethodException e)
+ {
+ writeObjectPresentCode = 1; // Missing.
+ }
+ out.writeInt(writeObjectPresentCode);
+
+ Field[] fields = c.getDeclaredFields();
+
+ Arrays.sort(fields, new Comparator()
+ {
+ public int compare(Object a, Object b)
+ {
+ Field fa = (Field) a;
+ Field fb = (Field) b;
+ return fa.getName().compareTo(fb.getName());
+ }
+ });
+
+ Field f;
+ for (int i = 0; i < fields.length; i++)
+ {
+ f = fields[i];
+ if ((f.getModifiers() & NON_WRITABLE) == 0)
+ {
+ out.writeUTF(f.getName());
+ out.writeUTF(getDescriptor(f.getType()));
+ }
+ }
+
+ out.flush();
+ out.close();
+ MessageDigest shaDigest;
+ try
+ {
+ shaDigest = MessageDigest.getInstance("SHA");
+ }
+ catch (Exception ex)
+ {
+ throw new InternalError("SHA digesting algorithm is not available");
+ }
+
+ // Return the digest value to the calling
+ // method as an array of bytes.
+ byte[] sha = shaDigest.digest(bout.toByteArray());
+
+ long hash = 0;
+ for (int i = 0; i < Math.min(8, sha.length); i++)
+ {
+ hash += (long) (sha[i] & 255) << (i * 8);
+ }
+ return hash;
+ }
+ catch (IOException ioex)
+ {
+ throw new Unexpected(ioex);
+ }
+ }
+
+ /**
+ * Converts to hexadecimal string, supplementing leading zeros.
+ */
+ public static String toHex(long l)
+ {
+ StringBuffer b = new StringBuffer();
+ b.append(Long.toHexString(l).toUpperCase());
+ while (b.length() < 16)
+ b.insert(0, '0');
+ return b.toString();
+ }
+
+ /**
+ * Returns a <code>String</code> representing the type-encoding of a class.
+ */
+ static String getDescriptor(Class type)
+ {
+ if (type.equals(boolean.class))
+ return "Z";
+ if (type.equals(byte.class))
+ return "B";
+ if (type.equals(short.class))
+ return "S";
+ if (type.equals(char.class))
+ return "C";
+ if (type.equals(int.class))
+ return "I";
+ if (type.equals(long.class))
+ return "J";
+ if (type.equals(float.class))
+ return "F";
+ if (type.equals(double.class))
+ return "D";
+ if (type.equals(void.class))
+ return "V";
+ else if (type.isArray())
+ {
+ StringBuffer l = new StringBuffer("[");
+ Class component = type.getComponentType();
+
+ while (component.isArray())
+ {
+ l.append('[');
+ component = component.getComponentType();
+ }
+
+ l.append('L');
+ l.append(component.getName().replace('.', '/'));
+ l.append(';');
+ return l.toString();
+ }
+ else
+ return "L" + type.getName().replace('.', '/') + ';';
+ }
+
+ public static Field[] getWritableFields(Class c)
+ {
+ TreeSet set = new TreeSet(new Comparator()
+ {
+ public int compare(Object a, Object b)
+ {
+ return ((Field) a).getName().compareTo(((Field) b).getName());
+ }
+ });
+
+ while (!c.equals(Object.class))
+ {
+ Field[] f = c.getDeclaredFields();
+ for (int i = 0; i < f.length; i++)
+ {
+ if ((f[i].getModifiers() & NON_WRITABLE) == 0)
+ {
+ f[i].setAccessible(true);
+ set.add(f[i]);
+ }
+ }
+ c = c.getSuperclass();
+ }
+
+ Field[] r = new Field[set.size()];
+ int p = 0;
+ Iterator it = set.iterator();
+ while (it.hasNext())
+ {
+ r[p++] = (Field) it.next();
+ }
+ return r;
+ }
+
+ /**
+ * The method is called for Remotes that are not Stubs. It is assumed, that
+ * the Remote is an implementation. The method searches for the suitable tie
+ * and, if found, exports it by creating and connecting the stub. Such export
+ * is supported since jdk 1.5.
+ */
+ void exportTie(org.omg.CORBA_2_3.portable.OutputStream output,
+ Object implementation, Class interfaceClass)
+ {
+ try
+ {
+ // Remote, but non - stub class (implementation)
+ // must be replaced by stub.
+ Tie t = Util.getTie((Remote) implementation);
+ if (t instanceof Servant)
+ {
+ POA rootPoa = POAHelper.narrow(output.orb().resolve_initial_references(
+ "RootPOA"));
+ org.omg.CORBA.Object co = rootPoa.servant_to_reference((Servant) t);
+ Stub stub = (Stub) PortableRemoteObject.narrow(co, interfaceClass);
+ writeRemoteObject(output, stub);
+
+ if (rootPoa.the_POAManager().get_state().value() == State._HOLDING)
+ rootPoa.the_POAManager().activate();
+ }
+ else if (t instanceof org.omg.CORBA.Object)
+ {
+ org.omg.CORBA.Object co = (org.omg.CORBA.Object) t;
+ output.orb().connect(co);
+
+ Stub stub = (Stub) PortableRemoteObject.narrow(co, interfaceClass);
+ writeRemoteObject(output, stub);
+ }
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Unable to export " + implementation);
+ m.minor = Minor.TargetConversion;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Start the ORB, if it is not already runnning.
+ */
+ void ensureOrbRunning(org.omg.CORBA_2_3.portable.OutputStream output)
+ {
+ // Ensure ORB is running.
+ if (output.orb() instanceof OrbFunctional)
+ {
+ ((OrbFunctional) output.orb()).ensureRunning();
+ }
+ }
+
+ /**
+ * Write data to the CORBA output stream. Writes the object contents only; the
+ * header must be already written. For object, containing objects, may be
+ * called recursively.
+ *
+ * @param an_output a stream to write to, must be
+ * org.omg.CORBA_2_3.portable.OutputStream
+ * @param object an object to write.
+ */
+ public void writeRemoteObject(OutputStream an_output, Object object)
+ {
+ org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+
+ if (isTieRequired(object))
+ {
+ // Find the interface that is implemented by the object and extends
+ // Remote.
+ Class fc = getExportedInterface(object);
+ exportTie(output, object, fc);
+ }
+ else if (object instanceof org.omg.CORBA.Object)
+ {
+ ensureOrbRunning(output);
+ an_output.write_Object((org.omg.CORBA.Object) object);
+ }
+ else if (object != null && object instanceof Serializable)
+ writeFields(an_output, (Serializable) object);
+ }
+
+ /**
+ * Write data to the CORBA output stream. Writes the object contents only; the
+ * header must be already written. For object, containing objects, may be
+ * called recursively.
+ *
+ * @param an_output a stream to write to, must be
+ * org.omg.CORBA_2_3.portable.OutputStream
+ * @param object an object to write.
+ */
+ public void writeValue(OutputStream an_output, Serializable object)
+ {
+ org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+
+ if (isTieRequired(object))
+ {
+ // Find the interface that is implemented by the object and extends
+ // Remote.
+ Class fc = getExportedInterface(object);
+ exportTie(output, object, fc);
+ }
+ else if (object instanceof org.omg.CORBA.Object)
+ {
+ ensureOrbRunning(output);
+ an_output.write_Object((org.omg.CORBA.Object) object);
+ }
+ else if (object instanceof Externalizable)
+ {
+ try
+ {
+ ObjectOutputStream stream = new CorbaOutput(output, object,
+ this);
+ stream.write(VERSION);
+ ((Externalizable) object).writeExternal(stream);
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("writeExternal failed");
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ else if (object instanceof Serializable)
+ {
+ Object mode = null;
+ synchronized (io_format)
+ {
+ mode = io_format.get(object.getClass());
+ if (mode == STANDARD)
+ {
+ writeFields(an_output, (Serializable) object);
+ return;
+ }
+ }
+ try
+ {
+ Method m = object.getClass().getDeclaredMethod("writeObject",
+ WRITE_OBJECT_ARGS);
+ m.setAccessible(true); // May be private.
+
+ try
+ {
+ ObjectOutputStream stream = new CorbaOutput(output,
+ object, this);
+
+ // Write version.
+ stream.write(VERSION);
+
+ if (mode == CUSTOM_DWO)
+ // Write true, supposing that the defaultWriteObject
+ // has been called.
+ stream.write(1);
+ else if (mode == CUSTOM_NO_DWO)
+ // Write false (has not been called)
+ stream.write(0);
+ else
+ {
+ // Measure.
+ DefaultWriteObjectTester tester = new DefaultWriteObjectTester(object);
+ m.invoke(object, new Object[] { tester });
+
+ synchronized (io_format)
+ {
+ io_format.put(object.getClass(),
+ tester.dwo_called ? CUSTOM_DWO : CUSTOM_NO_DWO);
+ stream.write(tester.dwo_called ? 1 : 0);
+ }
+ }
+
+ m.invoke(object, new Object[] { stream });
+ stream.flush();
+ }
+ catch (Exception ex)
+ {
+ MARSHAL mx = new MARSHAL(object.getClass().getName()
+ + ".writeObject failed");
+ mx.initCause(ex);
+ throw mx;
+ }
+ }
+ catch (NoSuchMethodException e)
+ {
+ // Write in a standard way.
+ writeFields(an_output, (Serializable) object);
+ synchronized (io_format)
+ {
+ io_format.put(object.getClass(), STANDARD);
+ }
+ }
+ }
+ }
+
+ /**
+ * Read data from the CDR input stream. Reads the object contents only; the
+ * header must be already read (the repository id or ids ara passed). For
+ * object, containing objects, may be called recursively.
+ *
+ * @param an_input the stream to read from, must be
+ * org.omg.CORBA_2_3.portable.InputStream
+ * @param object the instance of the object being read.
+ * @param id the repository Id from the stream in the case when single id was
+ * specified.
+ * @param ids the repository Ids from the stream in the case when multiple ids
+ * were specified.
+ * @param codebase the codebase, if it was included in the header of the value
+ * type. Null if not codebase was included.
+ *
+ * @return the object, extracted from the stream.
+ */
+ /**
+ * Read value from the input stream in the case when the value is not
+ * Streamable or CustomMarshalled.
+ */
+ public Serializable readValue(InputStream in, int offset, Class clz,
+ String repositoryID, RunTime sender)
+ {
+ if (in instanceof HeadlessInput)
+ ((HeadlessInput) in).subsequentCalls = true;
+
+ gnuRuntime g;
+ Serializable object = null;
+
+ try
+ {
+ g = (gnuRuntime) sender;
+ object = g.target;
+ }
+ catch (ClassCastException e)
+ {
+ // Working with the other CORBA implementation.
+ g = null;
+ }
+
+ org.omg.CORBA_2_3.portable.InputStream input = (org.omg.CORBA_2_3.portable.InputStream) in;
+
+ if (Remote.class.isAssignableFrom(clz)
+ || ValueBase.class.isAssignableFrom(clz))
+ {
+ // Interface is narrowed into Stub.
+ if (clz.isInterface())
+ try
+ {
+ clz = Util.loadClass(
+ PortableRemoteObjectDelegateImpl.getStubClassName(clz.getName()),
+ null, clz.getClassLoader());
+ }
+ catch (ClassNotFoundException e)
+ {
+ MARSHAL m = new MARSHAL("Cannot get stub from interface "
+ + clz.getClass().getName());
+ m.minor = Minor.TargetConversion;
+ m.initCause(e);
+ throw m;
+ }
+
+ // Remote needs special handling.
+ if (ObjectImpl.class.isAssignableFrom(clz))
+ {
+ // First read CORBA object reference.
+ Object ro = input.read_Object();
+
+ ObjectImpl obj = (ObjectImpl) ro;
+ if (obj == null)
+ return null;
+
+ Delegate delegate = obj._get_delegate();
+ object = instantiate(offset, clz, g);
+ ((ObjectImpl) object)._set_delegate(delegate);
+ }
+ // The object - specific data follows.
+ }
+ else if (org.omg.CORBA.Object.class.isAssignableFrom(clz))
+ object = (Serializable) input.read_Object();
+
+ if (object == null)
+ object = instantiate(offset, clz, g);
+
+ // The sentence below prevents attempt to read the internal fields of the
+ // ObjectImpl (or RMI Stub) that might follow the object definition.
+ // Sun's jre 1.5 does not write this information. The stubs, generated
+ // by rmic, does not contain such fields.
+ if (object instanceof ObjectImpl)
+ return object;
+
+ if (object instanceof Externalizable)
+ {
+ try
+ {
+ CorbaInput stream = new CorbaInput(input, object, this,
+ offset, repositoryID, g);
+
+ byte version = stream.readByte();
+ if (version != 1)
+ throw new MARSHAL("Unsuported RMI-IIOP version " + version);
+
+ ((Externalizable) object).readExternal(stream);
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("readExternal failed");
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ else
+ {
+ Object mode = null;
+ synchronized (io_format)
+ {
+ mode = io_format.get(object.getClass());
+ }
+
+ if (mode == STANDARD)
+ {
+ readFields(offset, repositoryID, object, input, g);
+ }
+ else
+ {
+ try
+ {
+ Method m = object.getClass().getDeclaredMethod("readObject",
+ READ_OBJECT_ARGS);
+ try
+ {
+ m.setAccessible(true); // May be private.
+
+ CorbaInput stream = new CorbaInput(input,
+ object, this, offset, repositoryID, g);
+
+ byte version = stream.readByte();
+ if (version != 1)
+ throw new MARSHAL("Unsuported RMI-IIOP version "
+ + version);
+
+ // This would indicate is defaultWriteObject has been
+ // called,
+ // but the readObject method normally takes care about this.
+ boolean dwo = stream.readByte() != 0;
+
+ m.invoke(object, new Object[] { stream });
+ synchronized (io_format)
+ {
+ io_format.put(object.getClass(), dwo ? CUSTOM_DWO
+ : CUSTOM_NO_DWO);
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ MARSHAL mx = new MARSHAL(object.getClass().getName()
+ + ".readObject failed");
+ mx.initCause(ex);
+ throw mx;
+ }
+ }
+ catch (NoSuchMethodException e)
+ {
+ // Read in a standard way.
+ synchronized (io_format)
+ {
+ io_format.put(object.getClass(), STANDARD);
+ readFields(offset, repositoryID, object, input, g);
+ }
+ }
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Create an instance.
+ */
+ Serializable instantiate(int offset, Class clz, gnuRuntime g)
+ throws MARSHAL
+ {
+ Serializable object;
+ try
+ {
+ object = (Serializable) Vio.instantiateAnyWay(clz);
+ g.objectWritten(object, offset);
+ }
+ catch (Exception e)
+ {
+ MARSHAL m = new MARSHAL("Unable to instantiate " + clz);
+ m.minor = Minor.Instantiation;
+ m.initCause(e);
+ throw m;
+ }
+ return object;
+ }
+
+ /**
+ * Read fields of the object.
+ */
+ void readFields(int offset, String repositoryID, Serializable object,
+ org.omg.CORBA_2_3.portable.InputStream input, gnuRuntime r)
+ throws MARSHAL
+ {
+ Field f = null;
+ Class o_class = object.getClass();
+
+ try
+ {
+ // The returned field array must already be in canonical order.
+ Field[] fields = getWritableFields(o_class);
+
+ Class fc;
+
+ for (int i = 0; i < fields.length; i++)
+ {
+ // Full value type header expected ahead.
+ if (input instanceof HeadlessInput)
+ ((HeadlessInput) input).subsequentCalls = true;
+
+ f = fields[i];
+ fc = f.getType();
+
+ Object v;
+
+ if (fc == String.class)
+ {
+ v = input.read_value(wStringValueHelper);
+ }
+ else if (fc == int.class)
+ v = new Integer(input.read_long());
+ else if (fc == long.class)
+ v = new Long(input.read_longlong());
+ else if (fc == double.class)
+ v = new Double(input.read_double());
+ else if (fc == float.class)
+ v = new Float(input.read_float());
+ else if (fc == boolean.class)
+ v = input.read_boolean() ? Boolean.TRUE : Boolean.FALSE;
+ else if (fc == short.class)
+ v = new Short(input.read_short());
+ else if (fc == byte.class)
+ v = new Byte(input.read_octet());
+ else if (fc == char.class)
+ v = new Character(input.read_char());
+ else if (org.omg.CORBA.Object.class.isAssignableFrom(fc)
+ || Remote.class.isAssignableFrom(fc))
+ {
+ v = readValue(input, offset, fc, null, r);
+ }
+ else
+ {
+ v = Vio.read(input, fc);
+ }
+
+ f.set(object, v);
+ }
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Cannot read " + o_class.getName() + " field "
+ + f);
+ m.initCause(ex);
+ m.minor = Minor.ValueFields;
+ throw m;
+ }
+ }
+
+}
diff --git a/gnu/javax/rmi/CORBA/StubDelegateImpl.java b/gnu/javax/rmi/CORBA/StubDelegateImpl.java
index 998d59e33..afc254ddb 100644
--- a/gnu/javax/rmi/CORBA/StubDelegateImpl.java
+++ b/gnu/javax/rmi/CORBA/StubDelegateImpl.java
@@ -1,5 +1,5 @@
-/* StubDelegateImpl.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* StubDelegateImpl.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,67 +38,273 @@ exception statement from your version. */
package gnu.javax.rmi.CORBA;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.rmi.Remote;
import java.rmi.RemoteException;
+
+import javax.rmi.PortableRemoteObject;
import javax.rmi.CORBA.Stub;
import javax.rmi.CORBA.StubDelegate;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAHelper;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
+
+/**
+ * The default stub delegate.
+ *
+ * @author Wu Gansha (gansha.wu@intel.com) (stub)
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) (implementation)
+ */
public class StubDelegateImpl
implements StubDelegate
{
-
- private int hashCode;
-
- public StubDelegateImpl(){
- hashCode = 0;
+ /**
+ * <p>
+ * Finds the suitable {@link Tie} for this Stub and connects it to the given
+ * ORB. The tie is found by the name pattern. If the found tie is derived from
+ * {@link org.omg.CORBA.PortableServer.Servant}, it is connected to the root
+ * POA, also activating it (if not already active).
+ * </p>
+ * <p>
+ * This method does not allow to specify, to which POA the found Tie must be
+ * connected and requires to use the deprecated method {@link ORB#connect}.
+ * Many useful POA features remain unaccessible. A better alternative it might
+ * be to generate a {@link org.omg.CORBA.PortableServer.Servant} - derived Tie
+ * (-poa key in rmic) and connect it to POA in one of the many ways, listed in
+ * the description of the {@link orb.omg.PortableServer} package). The
+ * obtained CORBA object can be narrowed into stub using
+ * {@link PortableRemoteObject#narrow}.
+ * </p>
+ *
+ * @param orb the ORB where the Stub must be connected.
+ *
+ * @throws RemoteException if the stub is already connected to some other ORB.
+ * If the stub is already connected to the ORB that was passed as parameter,
+ * the method returns without action.
+ *
+ * @throws BAD_PARAM if the name of this stub does not match the stub name
+ * pattern, "_*_Stub" or if the Tie class, "_*Impl_Tie", does not exists or an
+ * instance of this class cannot be instantiated.
+ */
+ public void connect(Stub self, ORB orb)
+ throws RemoteException
+ {
+ connect(self, orb, null);
}
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- public void connect(Stub self, javax.rmi.ORB orb)
+
+ /**
+ * Connect when the POA is specified.
+ */
+ public static void connect(Stub self, ORB orb, POA poa)
throws RemoteException
{
- throw new Error("Not implemented for StubDelegate");
+ ORB oorb = null;
+ try
+ {
+ Delegate d = self._get_delegate();
+ if (d != null)
+ oorb = d.orb(self);
+ }
+ catch (Exception e)
+ {
+ // Failed to get Delegate or ORB.
+ // (possible ony for user-written Stubs).
+ }
+
+ if (oorb != null)
+ {
+ if (!oorb.equals(orb))
+ throw new RemoteException("Stub " + self
+ + " is connected to another ORB, " + orb);
+ else
+ return;
+ }
+
+ Tie t = null;
+ if (self instanceof Remote)
+ t = Util.getTie((Remote) self);
+
+ // Find by name pattern.
+ if (t == null)
+ t = getTieFromStub(self);
+
+ Delegate delegate;
+
+ if (t instanceof Servant)
+ {
+ try
+ {
+ if (poa == null)
+ {
+ poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
+ // Activate if not active.
+ if (poa.the_POAManager().get_state().value() == State._HOLDING)
+ poa.the_POAManager().activate();
+ }
+
+ ObjectImpl obj = (ObjectImpl) poa.servant_to_reference((Servant) t);
+ delegate = obj._get_delegate();
+ }
+ catch (Exception ex)
+ {
+ throw new Unexpected(ex);
+ }
+ }
+ else if (t instanceof ObjectImpl)
+ {
+ ObjectImpl o = (ObjectImpl) t;
+ orb.connect(o);
+ delegate = o._get_delegate();
+ }
+ else
+ throw new BAD_PARAM("The Tie must be either Servant or ObjectImpl");
+
+ self._set_delegate(delegate);
}
- public boolean equals(Stub self, Object obj)
+ /**
+ * Locate a tie class, appropriate to the given stub class, by the name
+ * pattern.
+ */
+ public static Tie getTieFromStub(java.lang.Object self)
{
- if(self == null || obj == null)
- return self == obj;
- if(!(obj instanceof Stub))
- return false;
- return self.hashCode() == ((Stub)obj).hashCode();
+ Tie t;
+ String sn = self.getClass().getName();
+ if (!sn.endsWith("_Stub"))
+ throw new BAD_PARAM("The stub name, " + sn
+ + ", does not match _*_Stub pattern");
+
+ String tn = sn.substring(0, sn.length() - "_Stub".length()) + "Impl_Tie";
+ Class tieClass = null;
+
+ try
+ {
+ tieClass = ObjectCreator.forName(tn);
+ t = (Tie) tieClass.newInstance();
+ if (self instanceof Remote)
+ Util.registerTarget(t, (Remote) self);
+ }
+ catch (Exception e)
+ {
+ BAD_PARAM bad = new BAD_PARAM("Unable to instantiate '" + tn + "'");
+ bad.initCause(e);
+ throw bad;
+ }
+ return t;
+ }
+
+ /**
+ * Compare two stubs for equality.
+ */
+ public boolean equals(Stub self, java.lang.Object obj)
+ {
+ if (obj instanceof ObjectImpl)
+ {
+ ObjectImpl other = (ObjectImpl) obj;
+ Delegate d1 = other._get_delegate();
+ Delegate d2 = self._get_delegate();
+ if (d1 == null || d2 == null)
+ return d1 == d2;
+ else
+ return d1.equals(d2);
+ }
+ else return false;
}
+ /**
+ * Get the hash code (from IOR reference).
+ */
public int hashCode(Stub self)
{
- //FIX ME
- return hashCode;
+ Delegate d = self._get_delegate();
+ return d==null?0:d.hashCode();
}
+ /**
+ * Returns the IOR reference of the connected ORB.
+ *
+ * @see ORB#object_to_string(org.omg.CORBA.Object);
+ */
public String toString(Stub self)
{
try
{
- return self._orb().object_to_string(self);
+ return self._orb().object_to_string(self);
}
- // XXX javax.rmi.BAD_OPERATION -> org.omg.CORBA.BAD_OPERATION
- catch(javax.rmi.BAD_OPERATION bad_operation)
+ catch (Exception ex)
{
- return null;
+ return null;
}
}
- public void readObject(Stub self, ObjectInputStream s)
+ /**
+ * This should never be called. The ORB must be supplied.
+ *
+ * @see #connect
+ */
+ public void readObject(Stub self, ObjectInputStream input)
throws IOException, ClassNotFoundException
{
- throw new Error("Not implemented for StubDelegate");
+ readObject(self, input, null);
}
- public void writeObject(Stub self, ObjectOutputStream s)
+ /**
+ * Read as CORBA object when the ORB is known. The ORB must be set under the
+ * previous call of Stub.connect. The Stub is automatically registered with
+ * this ORB.
+ */
+ public void readObject(Stub self, ObjectInputStream input, ORB orb)
+ throws IOException, ClassNotFoundException
+ {
+ byte[] b = (byte[]) input.readObject();
+ BufferredCdrInput in = new BufferredCdrInput(b);
+
+ if (orb != null)
+ in.setOrb(orb);
+
+ ObjectImpl r = (ObjectImpl) in.read_Object();
+
+ self._set_delegate(r._get_delegate());
+ }
+
+ /**
+ * Write as CORBA object. The ORB is taken from the
+ * org.omg.CORBA.portable.Delegate. The Stub is automatically registered with
+ * this ORB (if not already done).
+ */
+ public void writeObject(Stub self, ObjectOutputStream output)
+ throws IOException
+ {
+ writeObject(self, output, null);
+ }
+
+ /**
+ * Write as CORBA object. The ORB must be either set under the previous call
+ * of Stub.connect or it is taken from the org.omg.CORBA.portable.Delegate.
+ * The Stub is automatically registered with this ORB (if not already done).
+ */
+ public void writeObject(Stub self, ObjectOutputStream output, ORB orb)
throws IOException
{
- throw new Error("Not implemented for StubDelegate");
+ BufferedCdrOutput out = new BufferedCdrOutput();
+ out.setOrb(orb == null ? self._orb() : orb);
+ out.write_Object(self);
+
+ output.writeObject(out.buffer.toByteArray());
}
-
-}
+} \ No newline at end of file
diff --git a/gnu/javax/rmi/CORBA/TieTargetRecord.java b/gnu/javax/rmi/CORBA/TieTargetRecord.java
new file mode 100644
index 000000000..70e751a6f
--- /dev/null
+++ b/gnu/javax/rmi/CORBA/TieTargetRecord.java
@@ -0,0 +1,93 @@
+/* TieTargetRecord.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import java.util.HashSet;
+
+import javax.rmi.CORBA.Tie;
+
+/**
+ * Represents a Tie, connected to possibly multiple invocation targets.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class TieTargetRecord
+{
+ /**
+ * The associated Tie.
+ */
+ public final Tie tie;
+
+ /**
+ * The objects, exposing the tie.
+ */
+ public HashSet targets = new HashSet();
+
+ /**
+ * Create a new record.
+ */
+ public TieTargetRecord(Tie a_tie)
+ {
+ tie = a_tie;
+ }
+
+ /**
+ * Add a target.
+ */
+ public void add(Object target)
+ {
+ targets.add(target);
+ }
+
+ /**
+ * Remove target.
+ */
+ public void remove(Object target)
+ {
+ targets.remove(target);
+ }
+
+ /**
+ * Return true if the tie has no associated invocation targets.
+ */
+ public boolean unused()
+ {
+ return targets.size() == 0;
+ }
+}
diff --git a/gnu/javax/rmi/CORBA/UtilDelegateImpl.java b/gnu/javax/rmi/CORBA/UtilDelegateImpl.java
index 7bed2aa22..f37f18c24 100644
--- a/gnu/javax/rmi/CORBA/UtilDelegateImpl.java
+++ b/gnu/javax/rmi/CORBA/UtilDelegateImpl.java
@@ -1,5 +1,5 @@
-/* UtilDelegateImpl.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* UtilDelegateImpl.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,115 +38,717 @@ exception statement from your version. */
package gnu.javax.rmi.CORBA;
+import gnu.CORBA.Minor;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Poa.AOM;
+import gnu.CORBA.Poa.gnuPOA;
+import gnu.CORBA.typecodes.GeneralTypeCode;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.COMM_FAILURE;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.INVALID_TRANSACTION;
+import org.omg.CORBA.INV_OBJREF;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_PERMISSION;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.OMGVMCID;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TRANSACTION_REQUIRED;
+import org.omg.CORBA.TRANSACTION_ROLLEDBACK;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UNKNOWN;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.AccessException;
+import java.rmi.MarshalException;
+import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
+import java.rmi.ServerError;
+import java.rmi.ServerException;
+import java.rmi.UnexpectedException;
import java.rmi.server.RMIClassLoader;
-import java.net.MalformedURLException;
-import java.io.*;
-//import org.omg.CORBA.ORB;
-//import org.omg.CORBA.SystemException;
-//import org.omg.CORBA.portable.InputStream;
-//import org.omg.CORBA.portable.OutputStream;
-import javax.rmi.CORBA.*;
+import java.util.Hashtable;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+import javax.rmi.CORBA.UtilDelegate;
+import javax.rmi.CORBA.ValueHandler;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.TransactionRequiredException;
+import javax.transaction.TransactionRolledbackException;
+/**
+ * The implementation of UtilDelegate.
+ *
+ * @author Wu Gansha (gansha.wu@intel.com) (stub)
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) (implementation)
+ */
public class UtilDelegateImpl
+ extends RmiUtilities
implements UtilDelegate
{
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- public Object copyObject(Object obj, javax.rmi.ORB orb)
+ /**
+ * The instance of the value handler, requested once.
+ */
+ static ValueHandler m_ValueHandler;
+
+ /**
+ * The global map of all ties to they records.
+ */
+ static Hashtable m_Ties = new Hashtable();
+
+ /**
+ * The global map of all targets to they records.
+ */
+ static Hashtable m_Targets = new Hashtable();
+
+ /**
+ * The standard package for that the exception names are omitted.
+ */
+ static final String m_StandardPackage = "org.omg.CORBA.";
+
+ /**
+ * Make a deep copy of the object.
+ */
+ public Object copyObject(Object obj, ORB orb)
throws RemoteException
{
- throw new Error("Not implemented for UtilDelegate");
+ // Strings are immutable, can be shared.
+ if (obj instanceof String)
+ return obj;
+ else if (obj == null)
+ return null;
+ else if (obj instanceof String[] || obj instanceof String[][]
+ || obj instanceof String[][][])
+ {
+ // String arrays can be just cloned.
+ return ((Object[]) obj).clone();
+ }
+ else if (obj instanceof Serializable)
+ {
+ try
+ {
+ ByteArrayOutputStream a = new ByteArrayOutputStream();
+ ObjectOutputStream ou = new ObjectOutputStream(a);
+ ou.writeObject(obj);
+ ou.close();
+ ObjectInputStream input = new ObjectInputStream(
+ new ByteArrayInputStream(a.toByteArray()));
+ return input.readObject();
+ }
+ catch (Exception ex)
+ {
+ RemoteException rex = new RemoteException("Cannot copy " + obj);
+ throw rex;
+ }
+ }
+ else
+ return obj;
}
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- public Object[] copyObjects(Object obj[], javax.rmi.ORB orb)
+ /**
+ * Make a deep copy of the object array.
+ */
+ public Object[] copyObjects(Object[] obj, ORB orb)
throws RemoteException
{
- throw new Error("Not implemented for UtilDelegate");
+ return (Object[]) copyObject(obj, orb);
}
public ValueHandler createValueHandler()
{
- throw new Error("Not implemented for UtilDelegate");
+ if (m_ValueHandler == null)
+ m_ValueHandler = (ValueHandler) DelegateFactory.getInstance(DelegateFactory.VALUEHANDLER);
+ return m_ValueHandler;
}
-
+
+ /**
+ * Returns the codebase of the given class.
+ */
public String getCodebase(Class clz)
{
- throw new Error("Not implemented for UtilDelegate");
+ return RMIClassLoader.getClassAnnotation(clz);
}
-
+
+ /**
+ * Get the Tie that handles invocations on the given target. If the target/Tie
+ * pair has not been previously registered using {@link #registerTarget},
+ * this method tries to locate a tie class by the name pattern. If this
+ * succeeds, the tie-target pair is also registered.
+ *
+ * @return the Tie.
+ */
public Tie getTie(Remote target)
{
- throw new Error("Not implemented for UtilDelegate");
+ synchronized (m_Targets)
+ {
+ Tie tie;
+ TieTargetRecord r = ((TieTargetRecord) m_Targets.get(target));
+ if (r == null)
+ {
+ if (target instanceof Stub)
+ {
+ tie = StubDelegateImpl.getTieFromStub(target);
+ registerTarget(tie, target);
+ }
+ else
+ {
+ // Treat this as implementation.
+ String tieClassName = getTieClassName(target.getClass().getName());
+ try
+ {
+ Class tieClass = Util.loadClass(tieClassName, null,
+ target.getClass().getClassLoader());
+ tie = (Tie) tieClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ MARSHAL m = new MARSHAL("Unable to instantiate "
+ + tieClassName);
+ m.minor = Minor.TargetConversion;
+ m.initCause(e);
+ throw m;
+ }
+ tie.setTarget(target);
+ registerTarget(tie, target);
+ }
+ }
+ else
+ tie = r.tie;
+ return tie;
+ }
+ }
+
+ /**
+ * Get the Stub class name for the name, representing the given interface.
+ */
+ private String getTieClassName(String interf)
+ {
+ String stubClassName;
+ int p = interf.lastIndexOf('.');
+
+ if (p < 0)
+ // The interface is defined in the default package.
+ stubClassName = "_" + interf + "_Tie";
+ else
+ stubClassName = interf.substring(0, p + 1) + "_"
+ + interf.substring(p + 1) + "_Tie";
+ return stubClassName;
}
-
+
+ /**
+ * Register the Tie-target pair. As the Tie is a Servant, it can potentially
+ * be connected to several objects and hence may be registered with several
+ * targets.
+ */
+ public void registerTarget(Tie tie, Remote target)
+ {
+ synchronized (m_Ties)
+ {
+ synchronized (m_Targets)
+ {
+ TieTargetRecord r = (TieTargetRecord) m_Ties.get(tie);
+ if (r == null)
+ {
+ // First registration for this Tie.
+ r = new TieTargetRecord(tie);
+ m_Ties.put(tie, r);
+ }
+ if (target != null)
+ {
+ r.add(target);
+ m_Targets.put(target, r);
+ }
+ }
+ }
+ }
+
+ /**
+ * Deactivate the associated Tie, if it is found and is not connected to other
+ * registered targets. Independing from the POA policies, the transparent
+ * reactivation will not be possible.
+ */
+ public void unexportObject(Remote target)
+ throws NoSuchObjectException
+ {
+ synchronized (m_Ties)
+ {
+ synchronized (m_Targets)
+ {
+ TieTargetRecord r = ((TieTargetRecord) m_Targets.get(target));
+ if (r != null)
+ {
+ if (target instanceof org.omg.CORBA.Object)
+ r.tie.orb().disconnect((org.omg.CORBA.Object) target);
+
+ if (r.unused())
+ {
+ m_Targets.remove(target);
+ m_Ties.remove(r.tie);
+ r.tie.deactivate();
+
+ if (r.tie.orb() instanceof ORB_1_4)
+ {
+ // Standard case, when more deep cleanup is possible.
+ // Independing from the POA policies, the object will
+ // not be activable transparently.
+ ORB_1_4 orb = (ORB_1_4) r.tie.orb();
+
+ if (target instanceof org.omg.CORBA.Object)
+ {
+ AOM.Obj record = orb.rootPOA.findObject((org.omg.CORBA.Object) target);
+
+ if (record != null && record.servant == r.tie
+ && record.poa instanceof gnuPOA)
+ {
+ ((gnuPOA) record.poa).aom.remove(record.key);
+ record.deactivated = true;
+ record.servant = null;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if the given stub is local.
+ *
+ * @param stub a stub to check.
+ * @return true if the stub is local, false otherwise.
+ */
public boolean isLocal(Stub stub)
throws RemoteException
{
- throw new Error("Not implemented for UtilDelegate");
+ try
+ {
+ return stub._is_local();
+ }
+ catch (SystemException e)
+ {
+ RemoteException rex = new RemoteException();
+ rex.initCause(e);
+ throw rex;
+ }
}
+ /**
+ * Load the class. The method uses class loaders from the call stact first. If
+ * this fails, the further behaviour depends on the System Property
+ * "java.rmi.server.useCodebaseOnly" with default value "false".
+ *
+ * <ul>
+ * <li>Try the current thread context class loader first.</li>
+ * <li>If remoteCodebase is non-null and useCodebaseOnly is "false" then call
+ * java.rmi.server.RMIClassLoader.loadClass (remoteCodebase, className)</li>
+ * <li> If remoteCodebase is null or useCodebaseOnly is true then call
+ * java.rmi.server.RMIClassLoader.loadClass(className)</li>
+ * <li>If a class is still not successfully loaded and the loader != null
+ * then try Class.forName(className, false, loader). </li>
+ * </ul>
+ *
+ * @param className the name of the class.
+ * @param remoteCodebase the codebase.
+ * @param loader the class loader.
+ * @return the loaded class.
+ *
+ * @throws ClassNotFoundException of the class cannot be loaded.
+ */
public Class loadClass(String className, String remoteCodebase,
- ClassLoader loader)
+ ClassLoader loader)
throws ClassNotFoundException
{
- try{
- if (remoteCodebase == null)
- return RMIClassLoader.loadClass(className);
- else
- return RMIClassLoader.loadClass(remoteCodebase, className);
- }
- catch (MalformedURLException e1)
+ if (loader == null)
+ loader = Thread.currentThread().getContextClassLoader();
+
+ String p_useCodebaseOnly = System.getProperty("java.rmi.server.useCodebaseOnly");
+
+ boolean useCodebaseOnly = p_useCodebaseOnly != null
+ && p_useCodebaseOnly.trim().equalsIgnoreCase("true");
+
+ try
{
- throw new ClassNotFoundException(className, e1);
+ if (remoteCodebase != null && !useCodebaseOnly)
+ return RMIClassLoader.loadClass(remoteCodebase, className);
}
- catch(ClassNotFoundException e2)
+ catch (Exception e)
{
- if(loader != null)
- return loader.loadClass(className);
- else
- return null;
+ // This failed but try others.
}
+
+ try
+ {
+ if (remoteCodebase == null || useCodebaseOnly)
+ return RMIClassLoader.loadClass(remoteCodebase, className);
+ }
+ catch (Exception e)
+ {
+ // This failed but try others.
+ }
+
+ if (loader != null)
+ return Class.forName(className, true, loader);
+
+ throw new ClassNotFoundException(className + " at " + remoteCodebase);
}
+ /**
+ * Converts CORBA {@link SystemException} into RMI {@link RemoteException}.
+ * The exception is converted as defined in the following table:
+ * <p>
+ * <table border = "1">
+ * <tr>
+ * <th>CORBA Exception</th>
+ * <th>RMI Exception</th>
+ * </tr>
+ * <tr>
+ * <td>{@link COMM_FAILURE}</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link INV_OBJREF}</td>
+ * <td>{@link NoSuchObjectException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link NO_PERMISSION}</td>
+ * <td>{@link AccessException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link MARSHAL}</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link BAD_PARAM} (all other cases)</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link OBJECT_NOT_EXIST}</td>
+ * <td>{@link NoSuchObjectException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link TRANSACTION_REQUIRED}</td>
+ * <td>{@link TransactionRequiredException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link TRANSACTION_ROLLEDBACK}</td>
+ * <td>{@link TransactionRolledbackException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link INVALID_TRANSACTION}</td>
+ * <td>{@link InvalidTransactionException}</td>
+ * </tr>
+ * <tr>
+ * <td bgcolor="lightgray">Any other {@link SystemException}</td>
+ * <td bgcolor="lightgray">{@link RemoteException}</td>
+ * </tr>
+ * </table>
+ * </p>
+ * <p>
+ * The exception detailed message always consists of
+ * <ol>
+ * <li>the string "CORBA "</li>
+ * <li>the CORBA name of the system exception</li>
+ * <li>single space</li>
+ * <li>the hexadecimal value of the system exception's minor code, preceeded
+ * by 0x (higher bits contain {@link OMGVMCID}).</li>
+ * <li>single space</li>
+ * <li>the {@link CompletionStatus} of the exception: "Yes", "No" or "Maybe".</li>
+ * </ol>
+ * <p>
+ * For instance, if the Internet connection was refused:
+ * </p>
+ * <p>
+ * <pre>
+ * <code>CORBA COMM_FAILURE 0x535500C9 No</code>
+ * </p>
+ * <p>
+ * The original CORBA exception is set as the cause of the RemoteException
+ * being created.
+ * </p>
+ */
public RemoteException mapSystemException(SystemException ex)
{
- throw new Error("Not implemented for UtilDelegate");
+ RemoteException rex;
+
+ String status;
+
+ switch (ex.completed.value())
+ {
+ case CompletionStatus._COMPLETED_MAYBE:
+ status = "Maybe";
+ break;
+
+ case CompletionStatus._COMPLETED_NO:
+ status = "No";
+ break;
+
+ case CompletionStatus._COMPLETED_YES:
+ status = "Yes";
+ break;
+
+ default:
+ status = "Unexpected completion status " + ex.completed.value();
+ }
+
+ String name = ex.getClass().getName();
+
+ if (name.startsWith(m_StandardPackage))
+ name = name.substring(m_StandardPackage.length());
+
+ String message = "CORBA " + name + " 0x" + Integer.toHexString(ex.minor)
+ + " " + status;
+
+ if (ex instanceof COMM_FAILURE)
+ rex = new MarshalException(message, ex);
+ else if (ex instanceof INV_OBJREF)
+ {
+ rex = new NoSuchObjectException(message);
+ rex.initCause(ex);
+ }
+ else if (ex instanceof NO_PERMISSION)
+ rex = new AccessException(message, ex);
+ else if (ex instanceof MARSHAL)
+ rex = new MarshalException(message, ex);
+ else if (ex instanceof BAD_PARAM)
+ rex = new MarshalException(message, ex);
+ else if (ex instanceof OBJECT_NOT_EXIST)
+ {
+ rex = new NoSuchObjectException(message);
+ rex.initCause(ex);
+ }
+ else if (ex instanceof TRANSACTION_REQUIRED)
+ {
+ rex = new TransactionRequiredException(message);
+ rex.initCause(ex);
+ }
+ else if (ex instanceof TRANSACTION_ROLLEDBACK)
+ {
+ rex = new TransactionRolledbackException(message);
+ rex.initCause(ex);
+ }
+ else if (ex instanceof INVALID_TRANSACTION)
+ {
+ rex = new InvalidTransactionException(message);
+ rex.initCause(ex);
+ }
+ else if (ex instanceof UNKNOWN)
+ rex = wrapException(ex.getCause());
+ else
+ rex = new RemoteException(message, ex);
+
+ return rex;
}
- public Object readAny(InputStream in)
+ /**
+ * Converts the exception that was thrown by the implementation method on a
+ * server side into RemoteException that can be transferred and re-thrown on a
+ * client side. The method converts exceptions as defined in the following
+ * table: <table border = "1">
+ * <tr>
+ * <th>Exception to map (or subclass)</th>
+ * <th>Maps into</th>
+ * </tr>
+ * <tr>
+ * <td>{@link Error}</td>
+ * <td>{@link ServerError}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link RemoteException}</td>
+ * <td>{@link ServerException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link SystemException}</td>
+ * <td>wrapException({@link #mapSystemException})</td>
+ * </tr>
+ * <tr>
+ * <td>{@link RuntimeException}</td>
+ * <td><b>rethrows</b></td>
+ * </tr>
+ * <tr>
+ * <td>Any other exception</td>
+ * <td>{@link UnexpectedException}</td>
+ * </tr>
+ * </table>
+ *
+ * @param ex an exception that was thrown on a server side implementation.
+ *
+ * @return the corresponding RemoteException unless it is a RuntimeException.
+ *
+ * @throws RuntimeException the passed exception if it is an instance of
+ * RuntimeException.
+ *
+ * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0.
+ */
+ public RemoteException wrapException(Throwable ex)
+ throws RuntimeException
{
- throw new Error("Not implemented for UtilDelegate");
+ if (ex instanceof RuntimeException)
+ throw (RuntimeException) ex;
+ else if (ex instanceof Error)
+ return new ServerError(ex.getMessage(), (Error) ex);
+ else if (ex instanceof RemoteException)
+ return new ServerException(ex.getMessage(), (Exception) ex);
+ else if (ex instanceof SystemException)
+ return wrapException(mapSystemException((SystemException) ex));
+ else
+ return new UnexpectedException("Unexpected", (Exception) ex);
}
- public void registerTarget(Tie tie, Remote target)
+ /**
+ * Write abstract interface to the CORBA output stream. The write format is
+ * matching CORBA abstract interface. Remotes and CORBA objects are written as
+ * objects, other classes are supposed to be value types and are written as
+ * such. {@link Remote}s are processed as defined in
+ * {@link #writeRemoteObject}. The written data contains discriminator,
+ * defining, that was written. Another method that writes the same content is
+ * {@link org.omg.CORBA_2_3.portable.OutputStream#write_abstract_interface(java.lang.Object)}.
+ *
+ * @param output a stream to write to, must be
+ * {@link org.omg.CORBA_2_3.portable.OutputStream}.
+ *
+ * @param object an object to write, must be CORBA object, Remote
+ */
+ public void writeAbstractObject(OutputStream output, Object object)
{
- throw new Error("Not implemented for UtilDelegate");
+ ((org.omg.CORBA_2_3.portable.OutputStream) output).write_abstract_interface(object);
}
-
- public void unexportObject(Remote target)
+
+ /**
+ * Write the passed java object to the output stream in the form of the CORBA
+ * {@link Any}. This includes creating an writing the object {@link TypeCode}
+ * first. Such Any can be later read by a non-RMI-IIOP CORBA implementation
+ * and manipulated, for instance, by means, provided in
+ * {@link org.omg.DynamicAny.DynAny}. Depending from the passed value, this
+ * method writes CORBA object, value type or value box. For value types Null
+ * is written with the abstract interface, its typecode having repository id
+ * "IDL:omg.org/CORBA/AbstractBase:1.0" and the empty string name.
+ *
+ * @param output the object to write.
+ * @param object the java object that must be written in the form of the CORBA
+ * {@link Any}.
+ */
+ public void writeAny(OutputStream output, Object object)
{
- throw new Error("Not implemented for UtilDelegate");
+ Any any = output.orb().create_any();
+ if (object == null)
+ {
+ GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_abstract_interface);
+ t.setId("IDL:omg.org/CORBA/AbstractBase:1.0");
+ t.setName("");
+ any.type(t);
+ output.write_any(any);
+ return;
+ }
+ else if (object instanceof org.omg.CORBA.Object
+ && !(object instanceof Remote))
+ {
+ // Write as value type.
+ boolean inserted = ObjectCreator.insertWithHelper(any, object);
+ if (inserted)
+ {
+ output.write_any(any);
+ return;
+ }
+ }
+
+ if (object instanceof org.omg.CORBA.Object)
+ writeAnyAsRemote(output, object);
+ else if (object instanceof Serializable)
+ {
+ any.insert_Value((Serializable) object);
+ output.write_any(any);
+ }
+ else
+ {
+ MARSHAL m = new MARSHAL(object.getClass().getName()
+ + " must be CORBA Object, Remote or Serializable");
+ m.minor = Minor.NonSerializable;
+ throw m;
+ }
}
-
- public RemoteException wrapException(Throwable orig)
+
+ /**
+ * Write Any as for remote object.
+ */
+ void writeAnyAsRemote(OutputStream output, Object object)
{
- throw new Error("Not implemented for UtilDelegate");
+ GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_objref);
+ t.setId(m_ValueHandler.getRMIRepositoryID(object.getClass()));
+ t.setName(object.getClass().getName());
+
+ // Writing Any (typecode, followed by value).
+ output.write_TypeCode(t);
+ writeRemoteObject(output, object);
}
-
- public void writeAbstractObject(OutputStream out, Object obj)
+
+ /**
+ * Get the class name excluding the package name.
+ */
+ String getName(String n)
{
- throw new Error("Not implemented for UtilDelegate");
+ int p = n.lastIndexOf('.');
+ if (p < 0)
+ return n;
+ else
+ return n.substring(p + 1);
}
-
- public void writeAny(OutputStream out, Object obj)
+
+ /**
+ * Read Any from the input stream.
+ */
+ public Object readAny(InputStream input)
{
- throw new Error("Not implemented for UtilDelegate");
+ return input.read_any();
}
- public void writeRemoteObject(OutputStream out, Object obj)
+ /**
+ * Write the passed parameter to the output stream as CORBA object. If the
+ * parameter is an instance of Remote and not an instance of Stub, the method
+ * instantiates a suitable Tie, connects the parameter to this Tie and then
+ * connects that Tie to the ORB that is requested from the output stream. Then
+ * the object reference is written to the stream, making remote invocations
+ * possible. This method is used in write_value(..) method group in
+ * {@link org.omg.CORBA_2_3.portable.OutputStream} and also may be called
+ * directly from generated Stubs and Ties.
+ *
+ * @param output a stream to write to, must be
+ * org.omg.CORBA_2_3.portable.OutputStream
+ * @param object an object to write.
+ */
+ public void writeRemoteObject(OutputStream an_output, Object object)
{
- throw new Error("Not implemented for UtilDelegate");
+ org.omg.CORBA_2_3.portable.OutputStream output = (org.omg.CORBA_2_3.portable.OutputStream) an_output;
+ if (object == null)
+ an_output.write_Object(null);
+ else if (isTieRequired(object))
+ {
+ // Find the interface that is implemented by the object and extends
+ // Remote.
+ Class fc = getExportedInterface(object);
+ exportTie(output, object, fc);
+ }
+ else if (object instanceof org.omg.CORBA.Object)
+ {
+ ensureOrbRunning(output);
+ an_output.write_Object((org.omg.CORBA.Object) object);
+ }
+ else if (object != null && object instanceof Serializable)
+ writeFields(an_output, (Serializable) object);
}
-}
+
+} \ No newline at end of file
diff --git a/gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java b/gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java
new file mode 100644
index 000000000..dc3b3cd6e
--- /dev/null
+++ b/gnu/javax/rmi/CORBA/ValueHandlerDelegateImpl.java
@@ -0,0 +1,163 @@
+/* ValueHandlerDelegateImpl.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.rmi.CORBA;
+
+import gnu.CORBA.CDR.gnuRuntime;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CustomMarshal;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.SendingContext.RunTime;
+
+import java.io.Externalizable;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.rmi.Remote;
+
+import javax.rmi.CORBA.ValueHandler;
+import javax.rmi.CORBA.ValueHandlerMultiFormat;
+
+/**
+ * Implementation of the ValueHandler.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) (implementation)
+ */
+public class ValueHandlerDelegateImpl
+ extends RmiUtilities
+ implements ValueHandler, ValueHandlerMultiFormat
+{
+ /**
+ * Return the maximal supported stream format version. We currently
+ * support the version 1.
+ *
+ * TODO Support the version 2.
+ */
+ public byte getMaximumStreamFormatVersion()
+ {
+ return 1;
+ }
+
+ /**
+ * Write value using the given stream format version.
+ */
+ public void writeValue(OutputStream output, Serializable value, byte version)
+ {
+ if (version!=1)
+ throw new BAD_PARAM("Unsupported stream format version "+version);
+ else
+ writeValue(output, value);
+ }
+
+ /**
+ * This implementation associates RunTime with stream rather than with the
+ * value handler and this method is not used in the implementation. It is
+ * implemented just for the sake of compatibility.
+ */
+ public RunTime getRunTimeCodeBase()
+ {
+ return new gnuRuntime(null, null);
+ }
+
+ /**
+ * Checks if an instance of this class can write its fields itself.
+ */
+ public boolean isCustomMarshaled(Class clz)
+ {
+ return CustomMarshal.class.isAssignableFrom(clz)
+ || Streamable.class.isAssignableFrom(clz);
+ }
+
+ /**
+ * No replacement, returns the passed parameter.
+ */
+ public Serializable writeReplace(Serializable value)
+ {
+ return value;
+ }
+
+ /**
+ * Compute the repository id in the RMI hashed format.
+ */
+ public String getRMIRepositoryID(final Class cx)
+ {
+ long hash = 0;
+ Class of = cx.isArray() ? cx.getComponentType() : null;
+
+ if (cx.equals(String[].class))
+ return RMI_STRING_ARRAY_ID;
+ else if (cx.equals(String.class))
+ return RMI_STRING_ID;
+ else if (cx.equals(Class.class))
+ return RMI_CLASS_ID;
+ else if (Remote.class.isAssignableFrom(cx)
+ || !Serializable.class.isAssignableFrom(cx)
+ || cx.isInterface()
+ || (cx.isArray() && (!Serializable.class.isAssignableFrom(of)
+ || of.isPrimitive() || Remote.class.isAssignableFrom(of)))
+
+ )
+ // Some classes that have zero hash code and serial no version id
+ // included.
+ return "RMI:" + cx.getName() + ":" + toHex(hash);
+ else if (cx.isArray())
+ // Arrays have the same hashcode and uid as they components.
+ return "RMI:" + cx.getName() + ":" + toHex(getHashCode(of)) + ":"
+ + toHex(getSid(of));
+ else
+ {
+ if (Externalizable.class.isAssignableFrom(cx))
+ hash = 1;
+ else
+ hash = getHashCode(cx);
+
+ return "RMI:" + cx.getName() + ":" + toHex(hash) + ":"
+ + toHex(getSid(cx));
+ }
+ }
+
+ /**
+ * Get the class serial version UID.
+ */
+ long getSid(Class cx)
+ {
+ ObjectStreamClass osc = ObjectStreamClass.lookup(cx);
+ return osc.getSerialVersionUID();
+ }
+} \ No newline at end of file
diff --git a/gnu/javax/rmi/PortableServer.java b/gnu/javax/rmi/PortableServer.java
deleted file mode 100644
index 4a841387d..000000000
--- a/gnu/javax/rmi/PortableServer.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/* PortableServer.java --
- Copyright (C) 2002, 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.javax.rmi;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.NoSuchObjectException;
-import java.rmi.server.UnicastRemoteObject;
-import java.rmi.server.RemoteStub;
-import java.util.Hashtable;
-
-import javax.rmi.CORBA.*;
-
-/**
- * The relationship of PortableRemoteObjectImpl with PortableServer
- * is like that of UnicastRemoteObject with UnicastServer
- */
-public class PortableServer
-{
- static private Hashtable tieCache = new Hashtable();
- static private Object NO_TIE = new Object();
-
- public static final synchronized void exportObject(Remote obj)
- throws RemoteException
- {
- if(Util.getTie(obj) != null)
- return;
-
- Tie tie = getTieFromRemote(obj);
- if (tie != null)
- Util.registerTarget(tie, obj);
- else
- UnicastRemoteObject.exportObject(obj);
- }
-
- public static final void unexportObject(Remote obj)
- {
- if (Util.getTie(obj) != null)
- Util.unexportObject(obj);
- if (tieCache.get(obj) != null) //??
- tieCache.remove(obj);
- }
-
- public static final Remote toStub(Remote obj)
- throws NoSuchObjectException
- {
- if (obj instanceof Stub || obj instanceof RemoteStub)
- return obj;
-
- Tie tie = Util.getTie(obj);
- Remote stub;
- if (tie != null)
- stub = getStubFromTie(tie);
- else
- throw new NoSuchObjectException("Can't toStub an unexported object");
- return stub;
- }
-
- static synchronized Tie getTieFromRemote(Remote obj)
- {
- Object tie = tieCache.get(obj);
- if (tie == null)
- {
- tie = getTieFromClass(obj.getClass());
- if(tie == null)
- tieCache.put(obj, NO_TIE);
- else
- tieCache.put(obj, tie);
- }
- else
- if(tie != NO_TIE)
- {
- try
- {
- tie = obj.getClass().newInstance();
- }
- catch(Exception _)
- {
- tie = null;
- }
- }
- else //NO_TIE
- tie = null;
-
- return (Tie)tie;
- }
-
- static synchronized Tie getTieFromClass(Class clz)
- {
- //FIX ME
- return null;
- }
-
- public static Remote getStubFromTie(Tie tie)
- {
- //FIX ME
- return null;
- }
-
- public static Remote getStubFromObjectImpl(ObjectImpl objimpl, Class toClass)
- {
- //FIX ME
- return null;
- }
-}
diff --git a/gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java b/gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java
new file mode 100644
index 000000000..fb9e684d0
--- /dev/null
+++ b/gnu/javax/sound/midi/alsa/AlsaInputPortDevice.java
@@ -0,0 +1,130 @@
+/* AlsaInputPortDevice.java -- ALSA MIDI In Port
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.sound.midi.alsa;
+
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Transmitter;
+import gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.AlsaPortInfo;
+
+/**
+ * ALSA MIDI In Port.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class AlsaInputPortDevice extends AlsaPortDevice
+{
+
+ AlsaInputPortDevice (AlsaPortInfo info)
+ {
+ super(info);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#open()
+ */
+ public void open() throws MidiUnavailableException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#close()
+ */
+ public void close()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#isOpen()
+ */
+ public boolean isOpen()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMicrosecondPosition()
+ */
+ public long getMicrosecondPosition()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMaxReceivers()
+ */
+ public int getMaxReceivers()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+ */
+ public int getMaxTransmitters()
+ {
+ // TODO Auto-generated method stub
+ return 1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getReceiver()
+ */
+ public Receiver getReceiver() throws MidiUnavailableException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getTransmitter()
+ */
+ public Transmitter getTransmitter() throws MidiUnavailableException
+ {
+ return new AlsaTransmitter();
+ }
+}
diff --git a/gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java b/gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java
new file mode 100644
index 000000000..4951be605
--- /dev/null
+++ b/gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider.java
@@ -0,0 +1,216 @@
+/* AlsaMidiDeviceProvider.java -- The ALSA MIDI Device Provider
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.sound.midi.alsa;
+
+import gnu.classpath.Configuration;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiDevice.Info;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+/**
+ * Provide ALSA MIDI devices.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class AlsaMidiDeviceProvider extends MidiDeviceProvider
+{
+ /**
+ * Abstract base for ALSA specific MIDI device info.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ private static abstract class AlsaInfo extends Info
+ {
+ /**
+ * Create an ALSA specific MIDI device info object.
+ *
+ * @param name the device name
+ * @param description the device description
+ */
+ public AlsaInfo(String name, String description)
+ {
+ super(name, "Alsa", description, "0.0");
+ }
+
+ abstract MidiDevice getDevice ();
+ }
+
+ /**
+ * ALSA MIDI Port.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ public static abstract class AlsaPortInfo extends AlsaInfo
+ {
+ long client;
+ long port;
+
+ /**
+ * Create ALSA MIDI In Port.
+ *
+ * @param name the device name
+ * @param description the device description
+ * @param client the client ID
+ * @param port the port ID
+ */
+ public AlsaPortInfo(String name, String description, long client, long port)
+ {
+ super(name, description);
+ this.client = client;
+ this.port = port;
+ }
+ }
+
+ /**
+ * ALSA Sequencer specific info.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ private static class AlsaSequencerInfo extends AlsaInfo
+ {
+ public AlsaSequencerInfo(String name, String description)
+ {
+ super(name, description);
+ }
+
+ MidiDevice getDevice()
+ {
+ return AlsaMidiSequencerDevice.getInstance();
+ }
+ }
+
+ /**
+ * ALSA MIDI In Port.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ private static class AlsaInputPortInfo extends AlsaPortInfo
+ {
+ public AlsaInputPortInfo(String name, String description, long client, long port)
+ {
+ super(name, description, client, port);
+ }
+
+ MidiDevice getDevice()
+ {
+ return new AlsaInputPortDevice(this);
+ }
+ }
+
+ /**
+ * ALSA MIDI Out Port.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ private static class AlsaOutputPortInfo extends AlsaPortInfo
+ {
+ public AlsaOutputPortInfo(String name, String description, long client, long port)
+ {
+ super(name, description, client, port);
+ }
+
+ MidiDevice getDevice()
+ {
+ return new AlsaOutputPortDevice(this);
+ }
+ }
+
+ private static AlsaInfo[] infos;
+
+ private static native AlsaInfo[] getInputDeviceInfo_();
+ private static native AlsaInfo[] getOutputDeviceInfo_();
+
+ /**
+ * Initialize the ALSA system
+ */
+ private static native void init_();
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ {
+ System.loadLibrary("gjsmalsa");
+ }
+
+ init_();
+
+ AlsaInfo inputs[] = getInputDeviceInfo_();
+ AlsaInfo outputs[] = getOutputDeviceInfo_();
+
+ infos = new AlsaInfo[inputs.length + outputs.length + 1];
+ infos[0] = new AlsaSequencerInfo ("/dev/snd/seq", "ALSA Sequencer");
+ System.arraycopy(inputs, 0, infos, 1, inputs.length);
+ System.arraycopy(outputs, 0, infos, 1 + inputs.length, outputs.length);
+ }
+
+ public AlsaMidiDeviceProvider()
+ {
+ // Nothing.
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.spi.MidiDeviceProvider#getDeviceInfo()
+ */
+ public Info[] getDeviceInfo()
+ {
+ return infos;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.spi.MidiDeviceProvider#getDevice(javax.sound.midi.MidiDevice.Info)
+ */
+ public MidiDevice getDevice(Info info)
+ {
+ for (int i = 0; i < infos.length; i++)
+ {
+ if (info.equals(infos[i]))
+ {
+ return infos[i].getDevice();
+ }
+ }
+ throw new IllegalArgumentException("Don't recognize MIDI device " + info);
+ }
+}
diff --git a/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java b/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java
new file mode 100644
index 000000000..c91f1e398
--- /dev/null
+++ b/gnu/javax/sound/midi/alsa/AlsaMidiSequencerDevice.java
@@ -0,0 +1,519 @@
+/* AlsaMidiSequencerDevice.java -- The ALSA MIDI sequencer device
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.sound.midi.alsa;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.sound.midi.ControllerEventListener;
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MetaEventListener;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Sequence;
+import javax.sound.midi.Sequencer;
+import javax.sound.midi.Track;
+import javax.sound.midi.Transmitter;
+
+// FIXME: These next two imports are only required by gcj it seems.
+import javax.sound.midi.MidiDevice.Info;
+import javax.sound.midi.Sequencer.SyncMode;
+
+/**
+ * The ALSA MIDI sequencer device. This is a singleton device.
+ *
+ * @author green@redhat.com
+ *
+ */
+public class AlsaMidiSequencerDevice implements Sequencer
+{
+ // The singleton instance.
+ public final static AlsaMidiSequencerDevice instance = new AlsaMidiSequencerDevice();
+
+ // A pointer to a native chunk of memory
+ private long nativeState;
+
+ // The sequence to process
+ private Sequence sequence;
+
+ /**
+ * A private constructor. There should only be one instance of this
+ * device.
+ */
+ private AlsaMidiSequencerDevice()
+ {
+ super();
+ }
+
+ /**
+ * Return the sequencer singleton.
+ *
+ * @return the sequencer singleton
+ */
+ public static AlsaMidiSequencerDevice getInstance()
+ {
+ return instance;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setSequence(javax.sound.midi.Sequence)
+ */
+ public void setSequence(Sequence seq) throws InvalidMidiDataException
+ {
+ sequence = seq;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setSequence(java.io.InputStream)
+ */
+ public void setSequence(InputStream istream) throws IOException,
+ InvalidMidiDataException
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getSequence()
+ */
+ public Sequence getSequence()
+ {
+ return sequence;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#start()
+ */
+ public void start()
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#stop()
+ */
+ public void stop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#isRunning()
+ */
+ public boolean isRunning()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#startRecording()
+ */
+ public void startRecording()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#stopRecording()
+ */
+ public void stopRecording()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#isRecording()
+ */
+ public boolean isRecording()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#recordEnable(javax.sound.midi.Track, int)
+ */
+ public void recordEnable(Track track, int channel)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#recordDisable(javax.sound.midi.Track)
+ */
+ public void recordDisable(Track track)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getTempoInBPM()
+ */
+ public float getTempoInBPM()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setTempoInBPM(float)
+ */
+ public void setTempoInBPM(float bpm)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getTempoInMPQ()
+ */
+ public float getTempoInMPQ()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setTempoInMPQ(float)
+ */
+ public void setTempoInMPQ(float mpq)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setTempoFactor(float)
+ */
+ public void setTempoFactor(float factor)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getTempoFactor()
+ */
+ public float getTempoFactor()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getTickLength()
+ */
+ public long getTickLength()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getTickPosition()
+ */
+ public long getTickPosition()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setTickPosition(long)
+ */
+ public void setTickPosition(long tick)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getMicrosecondLength()
+ */
+ public long getMicrosecondLength()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getMicrosecondPosition()
+ */
+ public long getMicrosecondPosition()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setMicrosecondPosition(long)
+ */
+ public void setMicrosecondPosition(long microsecond)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setMasterSyncMode(javax.sound.midi.Sequencer.SyncMode)
+ */
+ public void setMasterSyncMode(SyncMode sync)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getMasterSyncMode()
+ */
+ public SyncMode getMasterSyncMode()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getMasterSyncModes()
+ */
+ public SyncMode[] getMasterSyncModes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setSlaveSyncMode(javax.sound.midi.Sequencer.SyncMode)
+ */
+ public void setSlaveSyncMode(SyncMode sync)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getSlaveSyncMode()
+ */
+ public SyncMode getSlaveSyncMode()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getSlaveSyncModes()
+ */
+ public SyncMode[] getSlaveSyncModes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setTrackMute(int, boolean)
+ */
+ public void setTrackMute(int track, boolean mute)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getTrackMute(int)
+ */
+ public boolean getTrackMute(int track)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#setTrackSolo(int, boolean)
+ */
+ public void setTrackSolo(int track, boolean solo)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#getTrackSolo(int)
+ */
+ public boolean getTrackSolo(int track)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#addMetaEventListener(javax.sound.midi.MetaEventListener)
+ */
+ public boolean addMetaEventListener(MetaEventListener listener)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#removeMetaEventListener(javax.sound.midi.MetaEventListener)
+ */
+ public void removeMetaEventListener(MetaEventListener listener)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#addControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
+ */
+ public int[] addControllerEventListener(ControllerEventListener listener,
+ int[] controllers)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Sequencer#removeControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
+ */
+ public int[] removeControllerEventListener(ControllerEventListener listener,
+ int[] controllers)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getDeviceInfo()
+ */
+ public Info getDeviceInfo()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#open()
+ */
+ public void open() throws MidiUnavailableException
+ {
+ synchronized(this)
+ {
+ // Check to see if we're open already.
+ if (nativeState != 0)
+ return;
+
+ nativeState = open_();
+ }
+ }
+
+ /**
+ * Allocate the native state object, and open the sequencer.
+ *
+ * @return a long representation of a pointer to the nativeState.
+ */
+ private native long open_();
+
+ /**
+ * Close the sequencer and free the native state object.
+ */
+ private native void close_(long nativeState);
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#close()
+ */
+ public void close()
+ {
+ synchronized(this)
+ {
+ close_(nativeState);
+ nativeState = 0;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#isOpen()
+ */
+ public boolean isOpen()
+ {
+ synchronized(this)
+ {
+ return (nativeState != 0);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMaxReceivers()
+ */
+ public int getMaxReceivers()
+ {
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+ */
+ public int getMaxTransmitters()
+ {
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getReceiver()
+ */
+ public Receiver getReceiver() throws MidiUnavailableException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getTransmitter()
+ */
+ public Transmitter getTransmitter() throws MidiUnavailableException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java b/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java
new file mode 100644
index 000000000..bc5a55939
--- /dev/null
+++ b/gnu/javax/sound/midi/alsa/AlsaOutputPortDevice.java
@@ -0,0 +1,131 @@
+/* AlsaOutputPortDevice.java -- ALSA MIDI Output Port Device
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.sound.midi.alsa;
+
+import gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.AlsaPortInfo;
+
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Transmitter;
+
+/**
+ * ALSA MIDI Out Device
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class AlsaOutputPortDevice extends AlsaPortDevice
+{
+ AlsaOutputPortDevice (AlsaPortInfo info)
+ {
+ super(info);
+ }
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#open()
+ */
+ public void open() throws MidiUnavailableException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#close()
+ */
+ public void close()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#isOpen()
+ */
+ public boolean isOpen()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMicrosecondPosition()
+ */
+ public long getMicrosecondPosition()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMaxReceivers()
+ */
+ public int getMaxReceivers()
+ {
+ // TODO Auto-generated method stub
+ return 1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+ */
+ public int getMaxTransmitters()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getReceiver()
+ */
+ public Receiver getReceiver() throws MidiUnavailableException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getTransmitter()
+ */
+ public Transmitter getTransmitter() throws MidiUnavailableException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/gnu/javax/sound/midi/alsa/AlsaPortDevice.java b/gnu/javax/sound/midi/alsa/AlsaPortDevice.java
new file mode 100644
index 000000000..d666be1f1
--- /dev/null
+++ b/gnu/javax/sound/midi/alsa/AlsaPortDevice.java
@@ -0,0 +1,153 @@
+/* AlsaPortDevice.java -- ALSA MIDI Port Devices
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.sound.midi.alsa;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Transmitter;
+
+// FIXME: This next import is only rquired for gcj it seems.
+import javax.sound.midi.MidiDevice.Info;
+
+import gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider.AlsaPortInfo;
+
+/**
+ * ALSA Port Device
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public abstract class AlsaPortDevice implements MidiDevice
+{
+ /**
+ * The ALSA Receiver class.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ public class AlsaReceiver implements Receiver
+ {
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Receiver#send(javax.sound.midi.MidiMessage, long)
+ */
+ public void send(MidiMessage message, long timeStamp)
+ throws IllegalStateException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Receiver#close()
+ */
+ public void close()
+ {
+ // TODO Auto-generated method stub
+
+ }
+ }
+
+ AlsaMidiDeviceProvider.AlsaPortInfo info;
+
+ public AlsaPortDevice (AlsaPortInfo info)
+ {
+ this.info = info;
+ }
+
+ public Info getDeviceInfo()
+ {
+ return info;
+ }
+
+ native void run_receiver_thread_ (long client, long port, Receiver receiver);
+
+ /**
+ * The ALSA Transmitter class.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ protected class AlsaTransmitter implements Transmitter, Runnable
+ {
+ private Receiver receiver;
+
+ public void run()
+ {
+ run_receiver_thread_ (info.client, info.port, receiver);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Transmitter#setReceiver(javax.sound.midi.Receiver)
+ */
+ public void setReceiver(Receiver receiver)
+ {
+ synchronized (this)
+ {
+ this.receiver = receiver;
+ }
+
+ // Create the processing thread
+ new Thread(this).start();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Transmitter#getReceiver()
+ */
+ public Receiver getReceiver()
+ {
+ synchronized (this)
+ {
+ return receiver;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Transmitter#close()
+ */
+ public void close()
+ {
+ synchronized (this)
+ {
+ receiver.close();
+ receiver = null;
+ }
+ }
+ }
+}
diff --git a/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java b/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java
new file mode 100644
index 000000000..baf61732d
--- /dev/null
+++ b/gnu/javax/sound/midi/dssi/DSSIMidiDeviceProvider.java
@@ -0,0 +1,173 @@
+/* DSSIMidiDeviceProvider.java -- DSSI Device Provider
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.sound.midi.dssi;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+import java.io.FilenameFilter;
+
+import gnu.classpath.Configuration;
+import gnu.javax.sound.midi.alsa.AlsaMidiSequencerDevice;
+
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiDevice.Info;
+import javax.sound.midi.spi.MidiDeviceProvider;
+
+/**
+ * A DSSI MIDI device provider.
+ *
+ * DSSI (pronounced "dizzy") is an API for audio plugins, with particular
+ * application for software synthesis plugins with native user interfaces.
+ *
+ * Read about DSSI at http://dssi.sourceforge.net
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class DSSIMidiDeviceProvider extends MidiDeviceProvider
+{
+ /**
+ * The MidiDevice.Info specialized for DSSI synthesizers.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ private static class DSSIInfo extends Info
+ {
+ String soname;
+ long index;
+
+ public DSSIInfo(String name, String vendor, String description,
+ String version, String soname, long index)
+ {
+ super(name, vendor, description, version);
+ this.soname = soname;
+ this.index = index;
+ }
+ }
+
+ static native long dlopen_(String soname);
+ static native void dlclose_(long sohandle);
+ static native long getDSSIHandle_(long sohandle, long index);
+ static native String getDSSIName_(long handle);
+ static native String getDSSICopyright_(long handle);
+ static native String getDSSIVendor_(long handle);
+ static native String getDSSILabel_(long handle);
+
+ private static List examineLibrary(String soname)
+ {
+ List list = new ArrayList();
+ long index = 0;
+ long handle;
+
+ long sohandle = dlopen_(soname);
+ if (sohandle == 0)
+ return list;
+ do
+ {
+ handle = getDSSIHandle_(sohandle, index);
+ if (handle == 0)
+ break;
+ String name = getDSSILabel_(handle);
+ String copyright = getDSSICopyright_(handle);
+ String label = getDSSIName_(handle);
+ String vendor = getDSSIVendor_(handle);
+ list.add(new DSSIInfo(name, vendor, label,
+ "DSSI-1", soname, index));
+ index++;
+ } while (true);
+
+ // Close the library and free memory
+ dlclose_(sohandle);
+
+ return list;
+ }
+
+ private static DSSIInfo[] infos;
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("gjsmdssi");
+
+ File dssidir = new File("/usr/lib/dssi/");
+ String sofiles[] = dssidir.list(new FilenameFilter()
+ {
+ public boolean accept(File dir, String n)
+ {
+ return n.endsWith(".so");
+ }
+ });
+ List ilist = new ArrayList();
+ for (int i = 0; i < sofiles.length; i++)
+ ilist.addAll(examineLibrary(new File(dssidir, sofiles[i]).getAbsolutePath()));
+ infos = (DSSIInfo[]) ilist.toArray(new DSSIInfo[ilist.size()]);
+ }
+
+ public DSSIMidiDeviceProvider()
+ {
+ // Empty.
+ }
+
+ /* Return the Info array.
+ * @see javax.sound.midi.spi.MidiDeviceProvider#getDeviceInfo()
+ */
+ public Info[] getDeviceInfo()
+ {
+ return infos;
+ }
+
+ /* Get a MIDI Device for info.
+ * @see javax.sound.midi.spi.MidiDeviceProvider#getDevice(javax.sound.midi.MidiDevice.Info)
+ */
+ public MidiDevice getDevice(Info info)
+ {
+ for (int i = 0; i < infos.length; i++)
+ {
+ if (info.equals(infos[i]))
+ {
+ return new DSSISynthesizer(infos[i],
+ infos[i].soname,
+ infos[i].index);
+ }
+ }
+ throw new IllegalArgumentException("Don't recognize MIDI device " + info);
+ }
+}
diff --git a/gnu/javax/sound/midi/dssi/DSSISynthesizer.java b/gnu/javax/sound/midi/dssi/DSSISynthesizer.java
new file mode 100644
index 000000000..ca09b3050
--- /dev/null
+++ b/gnu/javax/sound/midi/dssi/DSSISynthesizer.java
@@ -0,0 +1,745 @@
+/* DSSISynthesizer.java -- DSSI Synthesizer Provider
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.javax.sound.midi.dssi;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.sound.midi.Instrument;
+import javax.sound.midi.MidiChannel;
+import javax.sound.midi.MidiMessage;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Patch;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.ShortMessage;
+import javax.sound.midi.Soundbank;
+import javax.sound.midi.SoundbankResource;
+import javax.sound.midi.Synthesizer;
+import javax.sound.midi.Transmitter;
+import javax.sound.midi.VoiceStatus;
+
+// FIXME: This import in only required for gcj it seems.
+import javax.sound.midi.MidiDevice.Info;
+
+/**
+ * DSSI soft-synth support.
+ *
+ * All DSSI soft-synths are expected to be installed in /usr/lib/dssi.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+public class DSSISynthesizer implements Synthesizer
+{
+ /**
+ * The DSSI Instrument class.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ class DSSIInstrument extends Instrument
+ {
+ DSSIInstrument (Soundbank soundbank, Patch patch, String name)
+ {
+ super (soundbank, patch, name, null);
+ }
+
+ /* @see javax.sound.midi.SoundbankResource#getData()
+ */
+ public Object getData()
+ {
+ return null;
+ }
+
+ }
+
+/**
+ * DSSISoundbank holds all instruments.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ class DSSISoundbank implements Soundbank
+ {
+ private String name;
+ private String description;
+ private List instruments = new ArrayList();
+ private List resources = new ArrayList();
+ private String vendor;
+ private String version;
+
+ public DSSISoundbank(String name, String description, String vendor, String version)
+ {
+ this.name = name;
+ this.description = description;
+ this.vendor = vendor;
+ this.version = version;
+ }
+
+ void add(Instrument instrument)
+ {
+ instruments.add(instrument);
+ }
+
+ /* @see javax.sound.midi.Soundbank#getName()
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /* @see javax.sound.midi.Soundbank#getVersion()
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+ /* @see javax.sound.midi.Soundbank#getVendor()
+ */
+ public String getVendor()
+ {
+ return vendor;
+ }
+
+ /* @see javax.sound.midi.Soundbank#getDescription()
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /* @see javax.sound.midi.Soundbank#getResources()
+ */
+ public SoundbankResource[] getResources()
+ {
+ return (SoundbankResource[])
+ resources.toArray(new SoundbankResource[resources.size()]);
+ }
+
+ /* @see javax.sound.midi.Soundbank#getInstruments()
+ */
+ public Instrument[] getInstruments()
+ {
+ return (Instrument[])
+ instruments.toArray(new Instrument[instruments.size()]);
+ }
+
+ /* @see javax.sound.midi.Soundbank#getInstrument(javax.sound.midi.Patch)
+ */
+ public Instrument getInstrument(Patch patch)
+ {
+ Iterator itr = instruments.iterator();
+
+ while (itr.hasNext())
+ {
+ Instrument i = (Instrument) itr.next();
+ if (i.getPatch().equals(patch))
+ return i;
+ }
+
+ return null;
+ }
+ }
+
+/**
+ * The Receiver class receives all MIDI messages from a connected
+ * Transmitter.
+ *
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ class DSSIReceiver implements Receiver
+ {
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Receiver#send(javax.sound.midi.MidiMessage, long)
+ */
+ public void send(MidiMessage message, long timeStamp)
+ throws IllegalStateException
+ {
+ if (message instanceof ShortMessage)
+ {
+ ShortMessage smessage = (ShortMessage) message;
+
+ switch (message.getStatus())
+ {
+ case ShortMessage.NOTE_ON:
+ int velocity = smessage.getData2();
+ if (velocity > 0)
+ channels[smessage.getChannel()].noteOn(smessage.getData1(),
+ smessage.getData2());
+ else
+ channels[smessage.getChannel()].noteOff(smessage.getData1());
+ break;
+ case ShortMessage.CONTROL_CHANGE:
+ channels[smessage.getChannel()].controlChange(smessage.getData1(),
+ smessage.getData2());
+ break;
+ default:
+ System.out.println ("Unhandled message: " + message.getStatus());
+ break;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Receiver#close()
+ */
+ public void close()
+ {
+ // TODO Auto-generated method stub
+ }
+
+ }
+
+ static native void noteOn_(long handle, int channel, int noteNumber, int velocity);
+ static native void noteOff_(long handle, int channel, int noteNumber, int velocity);
+ static native void setPolyPressure_(long handle, int channel, int noteNumber, int pressure);
+ static native int getPolyPressure_(long handle, int channel, int noteNumber);
+ static native void controlChange_(long handle, int channel, int control, int value);
+ static native void open_(long handle);
+ static native void close_(long handle);
+ static native String getProgramName_(long handle, int index);
+ static native int getProgramBank_(long handle, int index);
+ static native int getProgramProgram_(long handle, int index);
+ static native void selectProgram_(long handle, int bank, int program);
+
+ /**
+ * @author Anthony Green (green@redhat.com)
+ *
+ */
+ public class DSSIMidiChannel implements MidiChannel
+ {
+ int channel = 0;
+
+ /**
+ * Default contructor.
+ */
+ public DSSIMidiChannel(int channel)
+ {
+ super();
+ this.channel = channel;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#noteOn(int, int)
+ */
+ public void noteOn(int noteNumber, int velocity)
+ {
+ noteOn_(sohandle, channel, noteNumber, velocity);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#noteOff(int, int)
+ */
+ public void noteOff(int noteNumber, int velocity)
+ {
+ noteOff_(sohandle, channel, noteNumber, velocity);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#noteOff(int)
+ */
+ public void noteOff(int noteNumber)
+ {
+ noteOff_(sohandle, channel, noteNumber, -1);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#setPolyPressure(int, int)
+ */
+ public void setPolyPressure(int noteNumber, int pressure)
+ {
+ setPolyPressure_(sohandle, channel, noteNumber, pressure);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getPolyPressure(int)
+ */
+ public int getPolyPressure(int noteNumber)
+ {
+ return getPolyPressure_(sohandle, channel, noteNumber);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#setChannelPressure(int)
+ */
+ public void setChannelPressure(int pressure)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getChannelPressure()
+ */
+ public int getChannelPressure()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* @see javax.sound.midi.MidiChannel#controlChange(int, int) */
+ public void controlChange(int controller, int value)
+ {
+ controlChange_(sohandle, channel, controller, value);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getController(int)
+ */
+ public int getController(int controller)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#programChange(int)
+ */
+ public void programChange(int program)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#programChange(int, int)
+ */
+ public void programChange(int bank, int program)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getProgram()
+ */
+ public int getProgram()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#setPitchBend(int)
+ */
+ public void setPitchBend(int bend)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getPitchBend()
+ */
+ public int getPitchBend()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#resetAllControllers()
+ */
+ public void resetAllControllers()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#allNotesOff()
+ */
+ public void allNotesOff()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#allSoundOff()
+ */
+ public void allSoundOff()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#localControl(boolean)
+ */
+ public boolean localControl(boolean on)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#setMono(boolean)
+ */
+ public void setMono(boolean on)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getMono()
+ */
+ public boolean getMono()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#setOmni(boolean)
+ */
+ public void setOmni(boolean on)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getOmni()
+ */
+ public boolean getOmni()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#setMute(boolean)
+ */
+ public void setMute(boolean mute)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getMute()
+ */
+ public boolean getMute()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#setSolo(boolean)
+ */
+ public void setSolo(boolean solo)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiChannel#getSolo()
+ */
+ public boolean getSolo()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ }
+
+ long sohandle;
+ long handle;
+ private Info info;
+
+ MidiChannel channels[] = new MidiChannel[16];
+
+ // The list of known soundbanks, and the default one.
+ List soundbanks = new ArrayList();
+ DSSISoundbank defaultSoundbank;
+
+ /**
+ * Create a DSSI Synthesizer.
+ *
+ * @param info the DSSIInfo for this soft-synth
+ * @param soname the name of the .so file for this DSSI synth
+ * @param index the DSSI index for this soft-synth
+ */
+ public DSSISynthesizer(Info info, String soname, long index)
+ {
+ super();
+ this.info = info;
+ sohandle = DSSIMidiDeviceProvider.dlopen_(soname);
+ handle = DSSIMidiDeviceProvider.getDSSIHandle_(sohandle, index);
+ channels[0] = new DSSIMidiChannel(0);
+ defaultSoundbank = new DSSISoundbank("name", "description",
+ "vendor", "version");
+ soundbanks.add(defaultSoundbank);
+
+ int i = 0;
+ String name;
+ do
+ {
+ name = getProgramName_(sohandle, i);
+ if (name != null)
+ {
+ defaultSoundbank.
+ add(new DSSIInstrument(defaultSoundbank,
+ new Patch(getProgramBank_(sohandle, i),
+ getProgramProgram_(sohandle, i)),
+ name));
+ i++;
+ }
+ } while (name != null);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#getMaxPolyphony()
+ */
+ public int getMaxPolyphony()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#getLatency()
+ */
+ public long getLatency()
+ {
+ // DSSI and LADSPA provide no way to determine the latency.
+ // Let's just return 0 for now.
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#getChannels()
+ */
+ public MidiChannel[] getChannels()
+ {
+ return channels;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#getVoiceStatus()
+ */
+ public VoiceStatus[] getVoiceStatus()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#isSoundbankSupported(javax.sound.midi.Soundbank)
+ */
+ public boolean isSoundbankSupported(Soundbank soundbank)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* @see javax.sound.midi.Synthesizer#loadInstrument(javax.sound.midi.Instrument)
+ */
+ public boolean loadInstrument(Instrument instrument)
+ {
+ // FIXME: perhaps this isn't quite right. It can probably
+ // be in any soundbank.
+ if (instrument.getSoundbank() != defaultSoundbank)
+ throw new IllegalArgumentException ("Synthesizer doesn't support this instrument's soundbank");
+
+ Patch patch = instrument.getPatch();
+ selectProgram_(sohandle, patch.getBank(), patch.getProgram());
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#unloadInstrument(javax.sound.midi.Instrument)
+ */
+ public void unloadInstrument(Instrument instrument)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#remapInstrument(javax.sound.midi.Instrument, javax.sound.midi.Instrument)
+ */
+ public boolean remapInstrument(Instrument from, Instrument to)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* @see javax.sound.midi.Synthesizer#getDefaultSoundbank()
+ */
+ public Soundbank getDefaultSoundbank()
+ {
+ return defaultSoundbank;
+ }
+
+ /* @see javax.sound.midi.Synthesizer#getAvailableInstruments()
+ */
+ public Instrument[] getAvailableInstruments()
+ {
+ List instruments = new ArrayList();
+ Iterator itr = soundbanks.iterator();
+ while (itr.hasNext())
+ {
+ Soundbank sb = (Soundbank) itr.next();
+ Instrument ins[] = sb.getInstruments();
+ for (int i = 0; i < ins.length; i++)
+ instruments.add(ins[i]);
+ }
+ return (Instrument[])
+ instruments.toArray(new Instrument[instruments.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#getLoadedInstruments()
+ */
+ public Instrument[] getLoadedInstruments()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#loadAllInstruments(javax.sound.midi.Soundbank)
+ */
+ public boolean loadAllInstruments(Soundbank soundbank)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#unloadAllInstruments(javax.sound.midi.Soundbank)
+ */
+ public void unloadAllInstruments(Soundbank soundbank)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#loadInstruments(javax.sound.midi.Soundbank, javax.sound.midi.Patch[])
+ */
+ public boolean loadInstruments(Soundbank soundbank, Patch[] patchList)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.Synthesizer#unloadInstruments(javax.sound.midi.Soundbank, javax.sound.midi.Patch[])
+ */
+ public void unloadInstruments(Soundbank soundbank, Patch[] patchList)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* @see javax.sound.midi.MidiDevice#getDeviceInfo()
+ */
+ public Info getDeviceInfo()
+ {
+ return info;
+ }
+
+ /* @see javax.sound.midi.MidiDevice#open()
+ */
+ public void open() throws MidiUnavailableException
+ {
+ open_(sohandle);
+ }
+
+ /* @see javax.sound.midi.MidiDevice#close()
+ */
+ public void close()
+ {
+ close_(sohandle);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#isOpen()
+ */
+ public boolean isOpen()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.sound.midi.MidiDevice#getMicrosecondPosition()
+ */
+ public long getMicrosecondPosition()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* @see javax.sound.midi.MidiDevice#getMaxReceivers()
+ */
+ public int getMaxReceivers()
+ {
+ return 1;
+ }
+
+ /* @see javax.sound.midi.MidiDevice#getMaxTransmitters()
+ */
+ public int getMaxTransmitters()
+ {
+ return 0;
+ }
+
+ /* @see javax.sound.midi.MidiDevice#getReceiver()
+ */
+ public Receiver getReceiver() throws MidiUnavailableException
+ {
+ return new DSSIReceiver();
+ }
+
+ /* @see javax.sound.midi.MidiDevice#getTransmitter()
+ */
+ public Transmitter getTransmitter() throws MidiUnavailableException
+ {
+ return null;
+ }
+}
diff --git a/gnu/xml/stream/XMLOutputFactoryImpl.java b/gnu/xml/stream/XMLOutputFactoryImpl.java
index 25f520416..05b6d6c0f 100644
--- a/gnu/xml/stream/XMLOutputFactoryImpl.java
+++ b/gnu/xml/stream/XMLOutputFactoryImpl.java
@@ -121,7 +121,8 @@ public class XMLOutputFactoryImpl
{
if (IS_PREFIX_DEFAULTING.equals(name))
prefixDefaulting = ((Boolean) value).booleanValue();
- throw new IllegalArgumentException(name);
+ else
+ throw new IllegalArgumentException(name);
}
public Object getProperty(String name)
diff --git a/gnu/xml/transform/TransformerImpl.java b/gnu/xml/transform/TransformerImpl.java
index a36aa6173..cf4048847 100644
--- a/gnu/xml/transform/TransformerImpl.java
+++ b/gnu/xml/transform/TransformerImpl.java
@@ -1,5 +1,5 @@
/* TransformerImpl.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -505,6 +505,12 @@ class TransformerImpl
{
URL url = new URL(systemId);
URLConnection connection = url.openConnection();
+ // We need to call setDoInput(false), because our
+ // implementation of the file protocol allows writing
+ // (unlike Sun), but it will fail with a FileNotFoundException
+ // if we also open the connection for input and the output
+ // file doesn't yet exist.
+ connection.setDoInput(false);
connection.setDoOutput(true);
out = connection.getOutputStream();
}
diff --git a/include/Makefile.am b/include/Makefile.am
index a65ac5e47..3be305045 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -6,6 +6,13 @@ ARG_JNI_JAVAH = -jni
ARG_CLASSPATH_JAVAH = -bootclasspath
JAVAH = $(USER_JAVAH) $(ARG_JNI_JAVAH) $(ARG_CLASSPATH_JAVAH) ../lib:$(USER_CLASSLIB)
+SOUND_H_FILES = \
+$(top_srcdir)/include/gnu_javax_sound_midi_alsa_AlsaPortDevice.h \
+$(top_srcdir)/include/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.h \
+$(top_srcdir)/include/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.h \
+$(top_srcdir)/include/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h \
+$(top_srcdir)/include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h
+
XMLJ_H_FILES = \
$(top_srcdir)/include/gnu_xml_libxmlj_dom_GnomeDocument.h \
$(top_srcdir)/include/gnu_xml_libxmlj_dom_GnomeXPathNodeList.h \
@@ -105,6 +112,7 @@ $(top_srcdir)/include/gnu_java_awt_peer_qt_QtContainerPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_qt_QtEmbeddedWindowPeer.h
H_FILES = \
+$(SOUND_H_FILES) \
$(XMLJ_H_FILES) \
$(GTKPEER_H_FILES) \
$(QTPEER_H_FILES) \
@@ -149,6 +157,12 @@ $(top_srcdir)/include/gnu_java_awt_peer_gtk_%.h: $(top_builddir)/lib/gnu/java/aw
$(top_srcdir)/include/gnu_java_awt_peer_qt_%.h: $(top_builddir)/lib/gnu/java/awt/peer/qt/%.class
$(JAVAH) -o $@ gnu.java.awt.peer.qt.$*
+$(top_srcdir)/include/gnu_javax_sound_midi_alsa_%.h: $(top_builddir)/lib/gnu/javax/sound/midi/alsa/%.class
+ $(JAVAH) -o $@ gnu.javax.sound.midi.alsa.$*
+
+$(top_srcdir)/include/gnu_javax_sound_midi_dssi_%.h: $(top_builddir)/lib/gnu/javax/sound/midi/dssi/%.class
+ $(JAVAH) -o $@ gnu.javax.sound.midi.dssi.$*
+
$(top_srcdir)/include/gnu_java_net_PlainDatagramSocketImpl.h: $(top_srcdir)/gnu/java/net/PlainDatagramSocketImpl.java
$(JAVAH) -o $@ gnu.java.net.PlainDatagramSocketImpl
$(top_srcdir)/include/gnu_java_net_PlainSocketImpl.h: $(top_srcdir)/gnu/java/net/PlainSocketImpl.java
diff --git a/include/gnu_java_awt_peer_gtk_GdkTextLayout.h b/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
index b4d0c5328..c74a574e7 100644
--- a/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
+++ b/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
@@ -16,6 +16,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos (JNIE
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_initState (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_dispose (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_initStaticState (JNIEnv *env, jclass);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_getOutline (JNIEnv *env, jobject, jobject);
#ifdef __cplusplus
}
diff --git a/include/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.h b/include/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.h
new file mode 100644
index 000000000..8e3ed7104
--- /dev/null
+++ b/include/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.h
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider__
+#define __gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jobjectArray JNICALL Java_gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider_getInputDeviceInfo_1 (JNIEnv *env, jclass);
+JNIEXPORT jobjectArray JNICALL Java_gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider_getOutputDeviceInfo_1 (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider_init_1 (JNIEnv *env, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider__ */
diff --git a/include/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.h b/include/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.h
new file mode 100644
index 000000000..e6205394c
--- /dev/null
+++ b/include/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.h
@@ -0,0 +1,20 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice__
+#define __gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL Java_gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice_open_1 (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice_close_1 (JNIEnv *env, jobject, jlong);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice__ */
diff --git a/include/gnu_javax_sound_midi_alsa_AlsaPortDevice.h b/include/gnu_javax_sound_midi_alsa_AlsaPortDevice.h
new file mode 100644
index 000000000..30fae5ff7
--- /dev/null
+++ b/include/gnu_javax_sound_midi_alsa_AlsaPortDevice.h
@@ -0,0 +1,19 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_javax_sound_midi_alsa_AlsaPortDevice__
+#define __gnu_javax_sound_midi_alsa_AlsaPortDevice__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_alsa_AlsaPortDevice_run_1receiver_1thread_1 (JNIEnv *env, jobject, jlong, jlong, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_javax_sound_midi_alsa_AlsaPortDevice__ */
diff --git a/include/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h b/include/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h
new file mode 100644
index 000000000..6306a3e7a
--- /dev/null
+++ b/include/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h
@@ -0,0 +1,25 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider__
+#define __gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlopen_1 (JNIEnv *env, jclass, jstring);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlclose_1 (JNIEnv *env, jclass, jlong);
+JNIEXPORT jlong JNICALL Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIHandle_1 (JNIEnv *env, jclass, jlong, jlong);
+JNIEXPORT jstring JNICALL Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIName_1 (JNIEnv *env, jclass, jlong);
+JNIEXPORT jstring JNICALL Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSICopyright_1 (JNIEnv *env, jclass, jlong);
+JNIEXPORT jstring JNICALL Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIVendor_1 (JNIEnv *env, jclass, jlong);
+JNIEXPORT jstring JNICALL Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSILabel_1 (JNIEnv *env, jclass, jlong);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider__ */
diff --git a/include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h b/include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h
new file mode 100644
index 000000000..3cb0b77e6
--- /dev/null
+++ b/include/gnu_javax_sound_midi_dssi_DSSISynthesizer.h
@@ -0,0 +1,29 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_javax_sound_midi_dssi_DSSISynthesizer__
+#define __gnu_javax_sound_midi_dssi_DSSISynthesizer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOn_1 (JNIEnv *env, jclass, jlong, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOff_1 (JNIEnv *env, jclass, jlong, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_setPolyPressure_1 (JNIEnv *env, jclass, jlong, jint, jint, jint);
+JNIEXPORT jint JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getPolyPressure_1 (JNIEnv *env, jclass, jlong, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_controlChange_1 (JNIEnv *env, jclass, jlong, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_open_1 (JNIEnv *env, jclass, jlong);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_close_1 (JNIEnv *env, jclass, jlong);
+JNIEXPORT jstring JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramName_1 (JNIEnv *env, jclass, jlong, jint);
+JNIEXPORT jint JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramBank_1 (JNIEnv *env, jclass, jlong, jint);
+JNIEXPORT jint JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramProgram_1 (JNIEnv *env, jclass, jlong, jint);
+JNIEXPORT void JNICALL Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_selectProgram_1 (JNIEnv *env, jclass, jlong, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_javax_sound_midi_dssi_DSSISynthesizer__ */
diff --git a/java/awt/BorderLayout.java b/java/awt/BorderLayout.java
index adf2ebf65..0e626bbb1 100644
--- a/java/awt/BorderLayout.java
+++ b/java/awt/BorderLayout.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt;
+
/**
* This class implements a layout manager that positions components
* in certain sectors of the parent container.
@@ -229,6 +230,12 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
private int vgap;
+ // Some constants for use with calcSize().
+ private static final int MIN = 0;
+ private static final int MAX = 1;
+ private static final int PREF = 2;
+
+
/**
* Initializes a new instance of <code>BorderLayout</code> with no
* horiztonal or vertical gaps between components.
@@ -449,7 +456,7 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
*/
public void invalidateLayout(Container parent)
{
- // FIXME: Implement this properly!
+ // Nothing to do here.
}
/**
@@ -560,7 +567,8 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
}
/**
- * FIXME: Document me!
+ * This is a convenience method to set the bounds on a component.
+ * If the indicated component is null, nothing is done.
*/
private void setBounds(Component comp, int x, int y, int w, int h)
{
@@ -569,12 +577,6 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
comp.setBounds(x, y, w, h);
}
- // FIXME: Maybe move to top of file.
- // Some constants for use with calcSize().
- private static final int MIN = 0;
- private static final int MAX = 1;
- private static final int PREF = 2;
-
private Dimension calcCompSize(Component comp, int what)
{
if (comp == null || !comp.isVisible())
@@ -660,4 +662,112 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
return(new Dimension(width, height));
}
}
+
+ /**
+ * Return the component at the indicated location, or null if no component
+ * is at that location. The constraints argument must be one of the
+ * location constants specified by this class.
+ * @param constraints the location
+ * @return the component at that location, or null
+ * @throws IllegalArgumentException if the constraints argument is not
+ * recognized
+ * @since 1.5
+ */
+ public Component getLayoutComponent(Object constraints)
+ {
+ if (constraints == CENTER)
+ return center;
+ if (constraints == NORTH)
+ return north;
+ if (constraints == EAST)
+ return east;
+ if (constraints == SOUTH)
+ return south;
+ if (constraints == WEST)
+ return west;
+ if (constraints == PAGE_START)
+ return firstLine;
+ if (constraints == PAGE_END)
+ return lastLine;
+ if (constraints == LINE_START)
+ return firstItem;
+ if (constraints == LINE_END)
+ return lastItem;
+ throw new IllegalArgumentException("constraint " + constraints
+ + " is not recognized");
+ }
+
+ /**
+ * Return the component at the specified location, which must be one
+ * of the absolute constants such as CENTER or SOUTH. The container's
+ * orientation is used to map this location to the correct corresponding
+ * component, so for instance in a right-to-left container, a request
+ * for the EAST component could return the LINE_END component. This will
+ * return null if no component is available at the given location.
+ * @param container the container whose orientation is used
+ * @param constraints the absolute location of the component
+ * @return the component at the location, or null
+ * @throws IllegalArgumentException if the constraint is not recognized
+ */
+ public Component getLayoutComponent(Container container, Object constraints)
+ {
+ ComponentOrientation orient = container.getComponentOrientation();
+ if (constraints == CENTER)
+ return center;
+ // Note that we don't support vertical layouts.
+ if (constraints == NORTH)
+ return north;
+ if (constraints == SOUTH)
+ return south;
+ if (constraints == WEST)
+ {
+ // Note that relative layout takes precedence.
+ if (orient.isLeftToRight())
+ return firstItem == null ? west : firstItem;
+ return lastItem == null ? west : lastItem;
+ }
+ if (constraints == EAST)
+ {
+ // Note that relative layout takes precedence.
+ if (orient.isLeftToRight())
+ return lastItem == null ? east : lastItem;
+ return firstItem == null ? east : firstItem;
+ }
+ throw new IllegalArgumentException("constraint " + constraints
+ + " is not recognized");
+ }
+
+ /**
+ * Return the constraint corresponding to a component in this layout.
+ * If the component is null, or is not in this layout, returns null.
+ * Otherwise, this will return one of the constraint constants defined
+ * in this class.
+ * @param c the component
+ * @return the constraint, or null
+ * @since 1.5
+ */
+ public Object getConstraints(Component c)
+ {
+ if (c == null)
+ return null;
+ if (c == center)
+ return CENTER;
+ if (c == north)
+ return NORTH;
+ if (c == east)
+ return EAST;
+ if (c == south)
+ return SOUTH;
+ if (c == west)
+ return WEST;
+ if (c == firstLine)
+ return PAGE_START;
+ if (c == lastLine)
+ return PAGE_END;
+ if (c == firstItem)
+ return LINE_START;
+ if (c == lastItem)
+ return LINE_END;
+ return null;
+ }
}
diff --git a/java/awt/Canvas.java b/java/awt/Canvas.java
index fe2f85484..b599582ba 100644
--- a/java/awt/Canvas.java
+++ b/java/awt/Canvas.java
@@ -292,8 +292,8 @@ public class Canvas
*
* @since 1.4
*/
- public void createBufferStrategy(int numBuffers,
- BufferCapabilities caps)
+ public void createBufferStrategy(int numBuffers, BufferCapabilities caps)
+ throws AWTException
{
if (numBuffers < 1)
throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
@@ -305,15 +305,7 @@ public class Canvas
// a flipping strategy was requested
if (caps.isPageFlipping())
- {
- try
- {
- bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
- }
- catch (AWTException e)
- {
- }
- }
+ bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
else
bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true);
}
diff --git a/java/awt/Choice.java b/java/awt/Choice.java
index 3c49ad854..9b9fe4b97 100644
--- a/java/awt/Choice.java
+++ b/java/awt/Choice.java
@@ -565,6 +565,10 @@ processEvent(AWTEvent event)
protected void
processItemEvent(ItemEvent event)
{
+ int index = pItems.indexOf((String) event.getItem());
+ // Don't call back into the peers when selecting index here
+ if (event.getStateChange() == ItemEvent.SELECTED)
+ this.selectedIndex = index;
if (item_listeners != null)
item_listeners.itemStateChanged(event);
}
diff --git a/java/awt/ColorPaintContext.java b/java/awt/ColorPaintContext.java
index 759ba9d87..82a78f63f 100644
--- a/java/awt/ColorPaintContext.java
+++ b/java/awt/ColorPaintContext.java
@@ -63,7 +63,7 @@ class ColorPaintContext implements PaintContext
/**
* Create the context for a given color.
*
- * @param c The solid color to use.
+ * @param colorRGB The solid color to use.
*/
ColorPaintContext(int colorRGB)
{
@@ -74,7 +74,7 @@ class ColorPaintContext implements PaintContext
* Create the context for a given color.
*
* @param cm The color model of this context.
- * @param c The solid color to use.
+ * @param colorRGB The solid color to use.
*/
ColorPaintContext(ColorModel cm,int colorRGB)
{
diff --git a/java/awt/Component.java b/java/awt/Component.java
index 16caa7c34..c3f36af30 100644
--- a/java/awt/Component.java
+++ b/java/awt/Component.java
@@ -762,7 +762,7 @@ public abstract class Component
if (! visible || peer == null)
return false;
- return parent == null ? true : parent.isShowing();
+ return parent == null ? false : parent.isShowing();
}
/**
@@ -901,15 +901,16 @@ public abstract class Component
if (currentPeer != null)
currentPeer.setVisible(true);
+ // The JDK repaints the component before invalidating the parent.
+ // So do we.
+ if (isShowing())
+ repaint();
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
- {
- currentParent.invalidate();
- currentParent.repaint();
- }
+ currentParent.invalidate();
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
@@ -945,18 +946,19 @@ public abstract class Component
ComponentPeer currentPeer=peer;
if (currentPeer != null)
currentPeer.setVisible(false);
-
+ boolean wasShowing = isShowing();
this.visible = false;
-
+
+ // The JDK repaints the component before invalidating the parent.
+ // So do we.
+ if (wasShowing)
+ repaint();
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
- {
- currentParent.invalidate();
- currentParent.repaint();
- }
+ currentParent.invalidate();
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
@@ -1074,8 +1076,9 @@ public abstract class Component
Component p = parent;
if (p != null)
return p.getFont();
- else
- return new Font("Dialog", Font.PLAIN, 12);
+ if (peer != null)
+ return peer.getGraphics().getFont();
+ return null;
}
/**
@@ -1401,17 +1404,14 @@ public abstract class Component
peer.setBounds (x, y, width, height);
// Erase old bounds and repaint new bounds for lightweights.
- if (isLightweight() && isShowing ())
+ if (isLightweight() && isShowing())
{
if (parent != null)
{
Rectangle parentBounds = parent.getBounds();
- Rectangle oldBounds = new Rectangle(parent.getX() + oldx,
- parent.getY() + oldy,
- oldwidth, oldheight);
- Rectangle newBounds = new Rectangle(parent.getX() + x,
- parent.getY() + y,
- width, height);
+ Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth,
+ oldheight);
+ Rectangle newBounds = new Rectangle(x, y, width, height);
Rectangle destroyed = oldBounds.union(newBounds);
if (!destroyed.isEmpty())
parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
@@ -1735,11 +1735,8 @@ public abstract class Component
if (peer != null)
{
Graphics gfx = peer.getGraphics();
- if (gfx != null)
- return gfx;
- // create graphics for lightweight:
- Container parent = getParent();
- if (parent != null)
+ // Create peer for lightweights.
+ if (gfx == null && parent != null)
{
gfx = parent.getGraphics();
Rectangle bounds = getBounds();
@@ -1747,6 +1744,8 @@ public abstract class Component
gfx.translate(bounds.x, bounds.y);
return gfx;
}
+ gfx.setFont(font);
+ return gfx;
}
return null;
}
@@ -1886,7 +1885,7 @@ public abstract class Component
* @see #repaint(long, int, int, int, int)
*/
public void repaint()
- {
+ {
if(!isShowing())
{
Component p = parent;
@@ -3480,7 +3479,10 @@ public abstract class Component
ComponentPeer tmp = peer;
peer = null;
if (tmp != null)
- tmp.dispose();
+ {
+ tmp.hide();
+ tmp.dispose();
+ }
}
/**
@@ -3807,13 +3809,16 @@ public abstract class Component
{
synchronized (getTreeLock ())
{
- // Find this Component's top-level ancestor.
- Container parent = getParent ();
-
+ // Find this Component's top-level ancestor.
+ Container parent = (this instanceof Container) ? (Container) this
+ : getParent();
while (parent != null
&& !(parent instanceof Window))
parent = parent.getParent ();
+ if (parent == null)
+ return;
+
Window toplevel = (Window) parent;
if (toplevel.isFocusableWindow ())
{
diff --git a/java/awt/DefaultKeyboardFocusManager.java b/java/awt/DefaultKeyboardFocusManager.java
index f53cc5ef0..bce6352a9 100644
--- a/java/awt/DefaultKeyboardFocusManager.java
+++ b/java/awt/DefaultKeyboardFocusManager.java
@@ -146,8 +146,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
*/
private AWTKeyStroke waitForKeyStroke = null;
- /** The {@link java.util.SortedSet} of current {@link
- #EventDelayRequest}s. */
+ /** The {@link java.util.SortedSet} of current
+ * {@link EventDelayRequest}s. */
private SortedSet delayRequests = new TreeSet ();
public DefaultKeyboardFocusManager ()
diff --git a/java/awt/EventQueue.java b/java/awt/EventQueue.java
index 15b6e1e7a..235ad2ac1 100644
--- a/java/awt/EventQueue.java
+++ b/java/awt/EventQueue.java
@@ -42,7 +42,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.InputMethodEvent;
import java.awt.event.InvocationEvent;
-import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import java.util.EmptyStackException;
diff --git a/java/awt/Font.java b/java/awt/Font.java
index 1494ea633..2e4c9f61c 100644
--- a/java/awt/Font.java
+++ b/java/awt/Font.java
@@ -44,15 +44,15 @@ import gnu.java.awt.peer.ClasspathFontPeer;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.LineMetrics;
-import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.peer.FontPeer;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInputStream;
import java.io.Serializable;
-import static java.text.AttributedCharacterIterator.Attribute;
+import java.text.AttributedCharacterIterator;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.HashMap;
@@ -70,39 +70,35 @@ import java.util.StringTokenizer;
public class Font implements Serializable
{
-/*
- * Static Variables
- */
-
-/**
- * Constant indicating a "plain" font.
- */
-public static final int PLAIN = 0;
+ /**
+ * Constant indicating a "plain" font.
+ */
+ public static final int PLAIN = 0;
-/**
- * Constant indicating a "bold" font.
- */
-public static final int BOLD = 1;
+ /**
+ * Constant indicating a "bold" font.
+ */
+ public static final int BOLD = 1;
-/**
- * Constant indicating an "italic" font.
- */
-public static final int ITALIC = 2;
+ /**
+ * Constant indicating an "italic" font.
+ */
+ public static final int ITALIC = 2;
-/**
- * Constant indicating the baseline mode characteristic of Roman.
- */
-public static final int ROMAN_BASELINE = 0;
+ /**
+ * Constant indicating the baseline mode characteristic of Roman.
+ */
+ public static final int ROMAN_BASELINE = 0;
-/**
- * Constant indicating the baseline mode characteristic of Chinese.
- */
-public static final int CENTER_BASELINE = 1;
+ /**
+ * Constant indicating the baseline mode characteristic of Chinese.
+ */
+ public static final int CENTER_BASELINE = 1;
-/**
- * Constant indicating the baseline mode characteristic of Devanigri.
- */
-public static final int HANGING_BASELINE = 2;
+ /**
+ * Constant indicating the baseline mode characteristic of Devanigri.
+ */
+ public static final int HANGING_BASELINE = 2;
/**
@@ -171,1145 +167,1138 @@ public static final int HANGING_BASELINE = 2;
protected String name;
/**
- * The size of this font in pixels.
+ * The size of this font in points, rounded.
*
* @since 1.0
*/
protected int size;
/**
+ * The size of this font in points.
+ *
+ * @since 1.0
+ */
+ protected float pointSize;
+
+ /**
* The style of this font -- PLAIN, BOLD, ITALIC or BOLD+ITALIC.
*
* @since 1.0
*/
protected int style;
-// Serialization constant
-private static final long serialVersionUID = -4206021311591459213L;
+//Serialization constant
+ private static final long serialVersionUID = -4206021311591459213L;
// The ClasspathToolkit-provided peer which implements this font
- private ClasspathFontPeer peer;
-
-/*************************************************************************/
+ private transient ClasspathFontPeer peer;
-/*
- * Static Methods
- */
-/**
- * Creates a <code>Font</code> object from the specified string, which
- * is in one of the following formats:
- * <p>
- * <ul>
- * <li>fontname-style-pointsize
- * <li>fontname-style
- * <li>fontname-pointsize
- * <li>fontname
- * </ul>
- * <p>
- * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default
- * style if none is specified is PLAIN. The default size if none
- * is specified is 12.
- *
- * @param fontspec a string specifying the required font (<code>null</code>
- * permitted, interpreted as 'Dialog-PLAIN-12').
- *
- * @return A font.
- */
- public static Font decode (String fontspec)
-{
- if (fontspec == null)
- fontspec = "Dialog-PLAIN-12";
- String name = null;
- int style = PLAIN;
- int size = 12;
-
- StringTokenizer st = new StringTokenizer(fontspec, "- ");
- while (st.hasMoreTokens())
- {
- String token = st.nextToken();
- if (name == null)
- {
- name = token;
- continue;
- }
-
- if (token.toUpperCase().equals("BOLD"))
- {
- style = BOLD;
- continue;
- }
- if (token.toUpperCase().equals("ITALIC"))
- {
- style = ITALIC;
- continue;
- }
- if (token.toUpperCase().equals("BOLDITALIC"))
- {
+ /**
+ * Creates a <code>Font</code> object from the specified string, which
+ * is in one of the following formats:
+ * <p>
+ * <ul>
+ * <li>fontname-style-pointsize
+ * <li>fontname-style
+ * <li>fontname-pointsize
+ * <li>fontname
+ * </ul>
+ * <p>
+ * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default
+ * style if none is specified is PLAIN. The default size if none
+ * is specified is 12.
+ *
+ * @param fontspec a string specifying the required font (<code>null</code>
+ * permitted, interpreted as 'Dialog-PLAIN-12').
+ *
+ * @return A font.
+ */
+ public static Font decode(String fontspec)
+ {
+ if (fontspec == null)
+ fontspec = "Dialog-PLAIN-12";
+ String name = null;
+ int style = PLAIN;
+ int size = 12;
+
+ StringTokenizer st = new StringTokenizer(fontspec, "- ");
+ while (st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ if (name == null)
+ {
+ name = token;
+ continue;
+ }
+
+ if (token.toUpperCase().equals("BOLD"))
+ {
+ style = BOLD;
+ continue;
+ }
+ if (token.toUpperCase().equals("ITALIC"))
+ {
+ style = ITALIC;
+ continue;
+ }
+ if (token.toUpperCase().equals("BOLDITALIC"))
+ {
style = BOLD | ITALIC;
- continue;
- }
-
- int tokenval = 0;
- try
- {
- tokenval = Integer.parseInt(token);
- }
- catch(NumberFormatException e)
- {
- // Ignored.
- }
+ continue;
+ }
+
+ int tokenval = 0;
+ try
+ {
+ tokenval = Integer.parseInt(token);
+ }
+ catch (NumberFormatException e)
+ {
+ // Ignored.
+ }
if (tokenval != 0)
size = tokenval;
}
HashMap attrs = new HashMap();
- ClasspathFontPeer.copyStyleToAttrs (style, attrs);
- ClasspathFontPeer.copySizeToAttrs (size, attrs);
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
- return getFontFromToolkit (name, attrs);
-}
+ return getFontFromToolkit(name, attrs);
+ }
/* These methods delegate to the toolkit. */
- protected static ClasspathToolkit tk ()
+ static ClasspathToolkit tk()
{
- return (ClasspathToolkit)(Toolkit.getDefaultToolkit ());
+ return (ClasspathToolkit) Toolkit.getDefaultToolkit();
}
/* Every factory method in Font should eventually call this. */
- protected static Font getFontFromToolkit (String name, Map attribs)
+ static Font getFontFromToolkit(String name, Map attribs)
{
- return tk ().getFont (name, attribs);
+ return tk().getFont(name, attribs);
}
/* Every Font constructor should eventually call this. */
- protected static ClasspathFontPeer getPeerFromToolkit (String name, Map attrs)
+ static ClasspathFontPeer getPeerFromToolkit(String name, Map attrs)
{
- return tk ().getClasspathFontPeer (name, attrs);
+ return tk().getClasspathFontPeer(name, attrs);
}
-/*************************************************************************/
-
-/**
- * Returns a <code>Font</code> object from the passed property name.
- *
- * @param propname The name of the system property.
- * @param defval Value to use if the property is not found.
- *
- * @return The requested font, or <code>default</code> if the property
- * not exist or is malformed.
- */
- public static Font getFont (String propname, Font defval)
-{
- String propval = System.getProperty(propname);
- if (propval != null)
- return decode (propval);
+ /**
+ * Returns a <code>Font</code> object from the passed property name.
+ *
+ * @param propname The name of the system property.
+ * @param defval Value to use if the property is not found.
+ *
+ * @return The requested font, or <code>default</code> if the property
+ * not exist or is malformed.
+ */
+ public static Font getFont(String propname, Font defval)
+ {
+ String propval = System.getProperty(propname);
+ if (propval != null)
+ return decode(propval);
return defval;
-}
-
-/*************************************************************************/
-
-/**
- * Returns a <code>Font</code> object from the passed property name.
- *
- * @param propname The name of the system property.
- *
- * @return The requested font, or <code>null</code> if the property
- * not exist or is malformed.
- */
- public static Font getFont (String propname)
-{
- return getFont (propname, (Font)null);
-}
-
-/*************************************************************************/
+ }
-/*
- * Constructors
- */
+ /**
+ * Returns a <code>Font</code> object from the passed property name.
+ *
+ * @param propname The name of the system property.
+ *
+ * @return The requested font, or <code>null</code> if the property
+ * not exist or is malformed.
+ */
+ public static Font getFont(String propname)
+ {
+ return getFont(propname, (Font) null);
+ }
-/**
- * Initializes a new instance of <code>Font</code> with the specified
- * attributes.
- *
- * @param name The name of the font.
- * @param style The font style.
- * @param size The font point size.
- */
-
- public Font (String name, int style, int size)
+ /**
+ * Initializes a new instance of <code>Font</code> with the specified
+ * attributes.
+ *
+ * @param name The name of the font.
+ * @param style The font style.
+ * @param size The font point size.
+ */
+ public Font(String name, int style, int size)
{
HashMap attrs = new HashMap();
- ClasspathFontPeer.copyStyleToAttrs (style, attrs);
- ClasspathFontPeer.copySizeToAttrs (size, attrs);
- this.peer = getPeerFromToolkit (name, attrs);
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
+ this.peer = getPeerFromToolkit(name, attrs);
+ this.size = size;
+ this.pointSize = (float) size;
+ if (name != null)
+ this.name = name;
+ else
+ this.name = peer.getName(this);
}
- public Font (Map<? extends Attribute, ?> attrs)
+ public Font(Map attrs)
{
this(null, attrs);
}
/* This extra constructor is here to permit ClasspathToolkit and to
- build a font with a "logical name" as well as attrs.
- ClasspathToolkit.getFont(String,Map) uses reflection to call this
- package-private constructor. */
- Font (String name, Map attrs)
+ build a font with a "logical name" as well as attrs.
+ ClasspathToolkit.getFont(String,Map) uses reflection to call this
+ package-private constructor. */
+ Font(String name, Map attrs)
{
// If attrs is null, setting it to an empty HashMap will give this
// Font default attributes.
if (attrs == null)
attrs = new HashMap();
- this.peer = getPeerFromToolkit (name, attrs);
+ peer = getPeerFromToolkit(name, attrs);
+ size = (int) peer.getSize(this);
+ pointSize = peer.getSize(this);
+ if (name != null)
+ this.name = name;
+ else
+ this.name = peer.getName(this);
}
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
+ /**
* Returns the logical name of the font. A logical name is the name the
* font was constructed with. It may be the name of a logical font (one
* of 6 required names in all java environments) or it may be a face
* name.
- *
- * @return The logical name of the font.
- *
- * @see #getFamily()
- * @see #getFontName()
- */
+ *
+ * @return The logical name of the font.
+ *
+ * @see #getFamily()
+ * @see #getFontName()
+ */
public String getName ()
-{
- return peer.getName (this);
-}
-
-/*************************************************************************/
-
-/**
- * Returns the style of the font.
- *
- * @return The font style.
- */
- public int getSize ()
-{
- return (int) peer.getSize (this);
-}
-
- public float getSize2D ()
-{
- return peer.getSize (this);
-}
-
-/*************************************************************************/
-
-/**
- * Tests whether or not this is a plain font. This will be true if
- * and only if neither the bold nor the italics style is set.
- *
- * @return <code>true</code> if this is a plain font, <code>false</code>
- * otherwise.
- */
- public boolean isPlain ()
-{
- return peer.isPlain (this);
-}
+ {
+ return peer.getName(this);
+ }
-/*************************************************************************/
+ /**
+ * Returns the size of the font, in typographics points (1/72 of an inch),
+ * rounded to an integer.
+ *
+ * @return The font size
+ */
+ public int getSize()
+ {
+ return size;
+ }
-/**
- * Tests whether or not this font is bold.
- *
- * @return <code>true</code> if this font is bold, <code>false</code>
- * otherwise.
- */
- public boolean isBold ()
-{
- return peer.isBold (this);
-}
+ /**
+ * Returns the size of the font, in typographics points (1/72 of an inch).
+ *
+ * @return The font size
+ */
+ public float getSize2D()
+ {
+ return pointSize;
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not this is a plain font. This will be true if
+ * and only if neither the bold nor the italics style is set.
+ *
+ * @return <code>true</code> if this is a plain font, <code>false</code>
+ * otherwise.
+ */
+ public boolean isPlain()
+ {
+ return peer.isPlain(this);
+ }
-/**
- * Tests whether or not this font is italic.
- *
- * @return <code>true</code> if this font is italic, <code>false</code>
- * otherwise.
- */
- public boolean isItalic ()
-{
- return peer.isItalic (this);
-}
+ /**
+ * Tests whether or not this font is bold.
+ *
+ * @return <code>true</code> if this font is bold, <code>false</code>
+ * otherwise.
+ */
+ public boolean isBold()
+ {
+ return peer.isBold(this);
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not this font is italic.
+ *
+ * @return <code>true</code> if this font is italic, <code>false</code>
+ * otherwise.
+ */
+ public boolean isItalic()
+ {
+ return peer.isItalic(this);
+ }
-/**
+ /**
* Returns the family name of this font. A family name describes a design
* or "brand name" (such as Helvetica or Palatino). It is less specific
* than a font face name (such as Helvetica Bold).
- *
- * @return A string containing the font family name.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFontName()
- * @see GraphicsEnvironment#getAvailableFontFamilyNames()
- */
- public String getFamily ()
-{
- return peer.getFamily (this);
-}
+ *
+ * @return A string containing the font family name.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFontName()
+ * @see GraphicsEnvironment#getAvailableFontFamilyNames()
+ */
+ public String getFamily()
+ {
+ return peer.getFamily(this);
+ }
-/**
- * Returns integer code representing the sum of style flags of this font, a
- * combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}.
- *
- * @return code representing the style of this font.
- *
- * @see #isPlain()
- * @see #isBold()
- * @see #isItalic()
- */
- public int getStyle ()
-{
- return peer.getStyle (this);
-}
+ /**
+ * Returns integer code representing the sum of style flags of this font, a
+ * combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}.
+ *
+ * @return code representing the style of this font.
+ *
+ * @see #isPlain()
+ * @see #isBold()
+ * @see #isItalic()
+ */
+ public int getStyle()
+ {
+ return peer.getStyle(this);
+ }
-/**
- * Checks if specified character maps to a glyph in this font.
- *
- * @param c The character to check.
- *
- * @return Whether the character has a corresponding glyph in this font.
- *
- * @since 1.2
- */
- public boolean canDisplay (char c)
-{
- return peer.canDisplay (this, c);
-}
+ /**
+ * Checks if specified character maps to a glyph in this font.
+ *
+ * @param c The character to check.
+ *
+ * @return Whether the character has a corresponding glyph in this font.
+ *
+ * @since 1.2
+ */
+ public boolean canDisplay(char c)
+ {
+ return peer.canDisplay(this, c);
+ }
-/**
- * Checks how much of a given string can be mapped to glyphs in
- * this font.
- *
- * @param s The string to check.
- *
- * @return The index of the first character in <code>s</code> which cannot
- * be converted to a glyph by this font, or <code>-1</code> if all
- * characters can be mapped to glyphs.
- *
- * @since 1.2
- */
- public int canDisplayUpTo (String s)
-{
- return peer.canDisplayUpTo (this, new StringCharacterIterator (s),
- 0, s.length () - 1);
-}
+ /**
+ * Checks how much of a given string can be mapped to glyphs in
+ * this font.
+ *
+ * @param s The string to check.
+ *
+ * @return The index of the first character in <code>s</code> which cannot
+ * be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ */
+ public int canDisplayUpTo(String s)
+ {
+ return peer.canDisplayUpTo(this, new StringCharacterIterator(s),
+ 0, s.length() - 1);
+ }
-/**
- * Checks how much of a given sequence of text can be mapped to glyphs in
- * this font.
- *
- * @param text Array containing the text to check.
- * @param start Position of first character to check in <code>text</code>.
- * @param limit Position of last character to check in <code>text</code>.
- *
- * @return The index of the first character in the indicated range which
- * cannot be converted to a glyph by this font, or <code>-1</code> if all
- * characters can be mapped to glyphs.
- *
- * @since 1.2
- *
- * @throws IndexOutOfBoundsException if the range [start, limit] is
- * invalid in <code>text</code>.
- */
+ /**
+ * Checks how much of a given sequence of text can be mapped to glyphs in
+ * this font.
+ *
+ * @param text Array containing the text to check.
+ * @param start Position of first character to check in <code>text</code>.
+ * @param limit Position of last character to check in <code>text</code>.
+ *
+ * @return The index of the first character in the indicated range which
+ * cannot be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ *
+ * @throws IndexOutOfBoundsException if the range [start, limit] is
+ * invalid in <code>text</code>.
+ */
public int canDisplayUpTo (char[] text, int start, int limit)
-{
- return peer.canDisplayUpTo
- (this, new StringCharacterIterator (new String (text)), start, limit);
-}
+ {
+ return peer.canDisplayUpTo(this,
+ new StringCharacterIterator(new String (text)),
+ start, limit);
+ }
-/**
- * Checks how much of a given sequence of text can be mapped to glyphs in
- * this font.
- *
- * @param i Iterator over the text to check.
- * @param start Position of first character to check in <code>i</code>.
- * @param limit Position of last character to check in <code>i</code>.
- *
- * @return The index of the first character in the indicated range which
- * cannot be converted to a glyph by this font, or <code>-1</code> if all
- * characters can be mapped to glyphs.
- *
- * @since 1.2
- *
- * @throws IndexOutOfBoundsException if the range [start, limit] is
- * invalid in <code>i</code>.
- */
- public int canDisplayUpTo (CharacterIterator i, int start, int limit)
-{
- return peer.canDisplayUpTo (this, i, start, limit);
-}
+ /**
+ * Checks how much of a given sequence of text can be mapped to glyphs in
+ * this font.
+ *
+ * @param i Iterator over the text to check.
+ * @param start Position of first character to check in <code>i</code>.
+ * @param limit Position of last character to check in <code>i</code>.
+ *
+ * @return The index of the first character in the indicated range which
+ * cannot be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ *
+ * @throws IndexOutOfBoundsException if the range [start, limit] is
+ * invalid in <code>i</code>.
+ */
+ public int canDisplayUpTo(CharacterIterator i, int start, int limit)
+ {
+ return peer.canDisplayUpTo(this, i, start, limit);
+ }
-/**
- * Creates a new font with point size 1 and {@link #PLAIN} style,
- * reading font data from the provided input stream. The resulting font
- * can have further fonts derived from it using its
- * <code>deriveFont</code> method.
- *
- * @param fontFormat Integer code indicating the format the font data is
- * in.Currently this can only be {@link #TRUETYPE_FONT}.
- * @param is {@link InputStream} from which font data will be read. This
- * stream is not closed after font data is extracted.
- *
- * @return A new {@link Font} of the format indicated.
- *
- * @throws IllegalArgumentException if <code>fontType</code> is not
- * recognized.
- * @throws FontFormatException if data in InputStream is not of format
- * indicated.
- * @throws IOException if insufficient data is present on InputStream.
- *
- * @since 1.3
- */
- public static Font createFont (int fontFormat, InputStream is)
- throws FontFormatException, IOException
-{
- return tk().createFont (fontFormat, is);
-}
+ /**
+ * Creates a new font with point size 1 and {@link #PLAIN} style,
+ * reading font data from the provided input stream. The resulting font
+ * can have further fonts derived from it using its
+ * <code>deriveFont</code> method.
+ *
+ * @param fontFormat Integer code indicating the format the font data is
+ * in.Currently this can only be {@link #TRUETYPE_FONT}.
+ * @param is {@link InputStream} from which font data will be read. This
+ * stream is not closed after font data is extracted.
+ *
+ * @return A new {@link Font} of the format indicated.
+ *
+ * @throws IllegalArgumentException if <code>fontType</code> is not
+ * recognized.
+ * @throws FontFormatException if data in InputStream is not of format
+ * indicated.
+ * @throws IOException if insufficient data is present on InputStream.
+ *
+ * @since 1.3
+ */
+ public static Font createFont (int fontFormat, InputStream is)
+ throws FontFormatException, IOException
+ {
+ return tk().createFont(fontFormat, is);
+ }
-/**
- * Maps characters to glyphs in a one-to-one relationship, returning a new
- * {@link GlyphVector} with a mapped glyph for each input character. This
- * sort of mapping is often sufficient for some scripts such as Roman, but
- * is inappropriate for scripts with special shaping or contextual layout
- * requirements such as Arabic, Indic, Hebrew or Thai.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param str The string to convert to Glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- */
- public GlyphVector createGlyphVector (FontRenderContext ctx, String str)
-{
- return peer.createGlyphVector (this, ctx, new StringCharacterIterator (str));
-}
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param str The string to convert to Glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, String str)
+ {
+ return peer.createGlyphVector(this, ctx, new StringCharacterIterator(str));
+ }
-/**
- * Maps characters to glyphs in a one-to-one relationship, returning a new
- * {@link GlyphVector} with a mapped glyph for each input character. This
- * sort of mapping is often sufficient for some scripts such as Roman, but
- * is inappropriate for scripts with special shaping or contextual layout
- * requirements such as Arabic, Indic, Hebrew or Thai.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param i Iterator over the text to convert to glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- */
- public GlyphVector createGlyphVector (FontRenderContext ctx, CharacterIterator i)
-{
- return peer.createGlyphVector (this, ctx, i);
-}
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param i Iterator over the text to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx,
+ CharacterIterator i)
+ {
+ return peer.createGlyphVector(this, ctx, i);
+ }
-/**
- * Maps characters to glyphs in a one-to-one relationship, returning a new
- * {@link GlyphVector} with a mapped glyph for each input character. This
- * sort of mapping is often sufficient for some scripts such as Roman, but
- * is inappropriate for scripts with special shaping or contextual layout
- * requirements such as Arabic, Indic, Hebrew or Thai.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param chars Array of characters to convert to glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- */
- public GlyphVector createGlyphVector (FontRenderContext ctx, char[] chars)
-{
- return peer.createGlyphVector
- (this, ctx, new StringCharacterIterator (new String (chars)));
-}
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param chars Array of characters to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, char[] chars)
+ {
+ return peer.createGlyphVector(this, ctx,
+ new StringCharacterIterator(new String(chars)));
+ }
-/**
- * Extracts a sequence of glyphs from a font, returning a new {@link
- * GlyphVector} with a mapped glyph for each input glyph code.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param glyphCodes Array of characters to convert to glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- *
- * @specnote This method is documented to perform character-to-glyph
- * conversions, in the Sun documentation, but its second parameter name is
- * "glyphCodes" and it is not clear to me why it would exist if its
- * purpose was to transport character codes inside integers. I assume it
- * is mis-documented in the Sun documentation.
- */
-
- public GlyphVector createGlyphVector (FontRenderContext ctx, int[] glyphCodes)
-{
- return peer.createGlyphVector (this, ctx, glyphCodes);
-}
+ /**
+ * Extracts a sequence of glyphs from a font, returning a new {@link
+ * GlyphVector} with a mapped glyph for each input glyph code.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param glyphCodes Array of characters to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ *
+ * @specnote This method is documented to perform character-to-glyph
+ * conversions, in the Sun documentation, but its second parameter name is
+ * "glyphCodes" and it is not clear to me why it would exist if its
+ * purpose was to transport character codes inside integers. I assume it
+ * is mis-documented in the Sun documentation.
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, int[] glyphCodes)
+ {
+ return peer.createGlyphVector(this, ctx, glyphCodes);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new size and style.
- *
- * @param style The style of the newly created font.
- * @param size The size of the newly created font.
- *
- * @return A clone of the current font, with the specified size and style.
- *
- * @since 1.2
- */
- public Font deriveFont (int style, float size)
-{
- return peer.deriveFont (this, style, size);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new size and style.
+ *
+ * @param style The style of the newly created font.
+ * @param size The size of the newly created font.
+ *
+ * @return A clone of the current font, with the specified size and style.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style, float size)
+ {
+ return peer.deriveFont(this, style, size);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new size.
- *
- * @param size The size of the newly created font.
- *
- * @return A clone of the current font, with the specified size.
- *
- * @since 1.2
- */
- public Font deriveFont (float size)
-{
- return peer.deriveFont (this, size);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new size.
+ *
+ * @param size The size of the newly created font.
+ *
+ * @return A clone of the current font, with the specified size.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(float size)
+ {
+ return peer.deriveFont(this, size);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new style.
- *
- * @param style The style of the newly created font.
- *
- * @return A clone of the current font, with the specified style.
- *
- * @since 1.2
- */
- public Font deriveFont (int style)
-{
- return peer.deriveFont (this, style);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new style.
+ *
+ * @param style The style of the newly created font.
+ *
+ * @return A clone of the current font, with the specified style.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style)
+ {
+ return peer.deriveFont(this, style);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new style and subjected to a new affine transformation.
- *
- * @param style The style of the newly created font.
- * @param a The transformation to apply.
- *
- * @return A clone of the current font, with the specified style and
- * transform.
- *
- * @throws IllegalArgumentException If transformation is
- * <code>null</code>.
- *
- * @since 1.2
- */
- public Font deriveFont (int style, AffineTransform a)
-{
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new style and subjected to a new affine transformation.
+ *
+ * @param style The style of the newly created font.
+ * @param a The transformation to apply.
+ *
+ * @return A clone of the current font, with the specified style and
+ * transform.
+ *
+ * @throws IllegalArgumentException If transformation is
+ * <code>null</code>.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style, AffineTransform a)
+ {
if (a == null)
- throw new IllegalArgumentException ("Affine transformation is null");
+ throw new IllegalArgumentException("Affine transformation is null");
- return peer.deriveFont (this, style, a);
-}
+ return peer.deriveFont(this, style, a);
+ }
-/**
- * Produces a new {@link Font} based on the current font, subjected
- * to a new affine transformation.
- *
- * @param a The transformation to apply.
- *
- * @return A clone of the current font, with the specified transform.
- *
- * @throws IllegalArgumentException If transformation is
- * <code>null</code>.
- *
- * @since 1.2
- */
- public Font deriveFont (AffineTransform a)
-{
+ /**
+ * Produces a new {@link Font} based on the current font, subjected
+ * to a new affine transformation.
+ *
+ * @param a The transformation to apply.
+ *
+ * @return A clone of the current font, with the specified transform.
+ *
+ * @throws IllegalArgumentException If transformation is
+ * <code>null</code>.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(AffineTransform a)
+ {
if (a == null)
- throw new IllegalArgumentException ("Affine transformation is null");
+ throw new IllegalArgumentException("Affine transformation is null");
- return peer.deriveFont (this, a);
-}
+ return peer.deriveFont(this, a);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new set of attributes.
- *
- * @param attributes Attributes of the newly created font.
- *
- * @return A clone of the current font, with the specified attributes.
- *
- * @since 1.2
- */
- public Font deriveFont (Map<? extends Attribute, ?> attributes)
-{
- return peer.deriveFont (this, attributes);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new set of attributes.
+ *
+ * @param attributes Attributes of the newly created font.
+ *
+ * @return A clone of the current font, with the specified attributes.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(Map attributes)
+ {
+ return peer.deriveFont(this, attributes);
+ }
-/**
- * Returns a map of chracter attributes which this font currently has set.
- *
- * @return A map of chracter attributes which this font currently has set.
- *
- * @see #getAvailableAttributes()
- * @see java.text.AttributedCharacterIterator.Attribute
- * @see java.awt.font.TextAttribute
- */
- public Map<TextAttribute,?> getAttributes ()
-{
- return peer.getAttributes (this);
-}
+ /**
+ * Returns a map of chracter attributes which this font currently has set.
+ *
+ * @return A map of chracter attributes which this font currently has set.
+ *
+ * @see #getAvailableAttributes()
+ * @see java.text.AttributedCharacterIterator.Attribute
+ * @see java.awt.font.TextAttribute
+ */
+ public Map getAttributes()
+ {
+ return peer.getAttributes(this);
+ }
-/**
- * Returns an array of chracter attribute keys which this font understands.
- *
- * @return An array of chracter attribute keys which this font understands.
- *
- * @see #getAttributes()
- * @see java.text.AttributedCharacterIterator.Attribute
- * @see java.awt.font.TextAttribute
- */
- public Attribute[] getAvailableAttributes()
-{
- return peer.getAvailableAttributes (this);
-}
+ /**
+ * Returns an array of chracter attribute keys which this font understands.
+ *
+ * @return An array of chracter attribute keys which this font understands.
+ *
+ * @see #getAttributes()
+ * @see java.text.AttributedCharacterIterator.Attribute
+ * @see java.awt.font.TextAttribute
+ */
+ public AttributedCharacterIterator.Attribute[] getAvailableAttributes()
+ {
+ return peer.getAvailableAttributes(this);
+ }
-/**
- * Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link
- * #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline
- * this font will measure baseline offsets for, when presenting glyph
- * metrics for a given character.
- *
- * Baseline offsets describe the position of a glyph relative to an
- * invisible line drawn under, through the center of, or over a line of
- * rendered text, respectively. Different scripts use different baseline
- * modes, so clients should not assume all baseline offsets in a glyph
- * vector are from a common baseline.
- *
- * @param c The character code to select a baseline mode for.
- *
- * @return The baseline mode which would be used in a glyph associated
- * with the provided character.
- *
- * @since 1.2
- *
- * @see LineMetrics#getBaselineOffsets()
- */
- public byte getBaselineFor (char c)
-{
- return peer.getBaselineFor (this, c);
-}
+ /**
+ * Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link
+ * #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline
+ * this font will measure baseline offsets for, when presenting glyph
+ * metrics for a given character.
+ *
+ * Baseline offsets describe the position of a glyph relative to an
+ * invisible line drawn under, through the center of, or over a line of
+ * rendered text, respectively. Different scripts use different baseline
+ * modes, so clients should not assume all baseline offsets in a glyph
+ * vector are from a common baseline.
+ *
+ * @param c The character code to select a baseline mode for.
+ *
+ * @return The baseline mode which would be used in a glyph associated
+ * with the provided character.
+ *
+ * @since 1.2
+ *
+ * @see LineMetrics#getBaselineOffsets()
+ */
+ public byte getBaselineFor(char c)
+ {
+ return peer.getBaselineFor(this, c);
+ }
-/**
- * Returns the family name of this font. A family name describes a
- * typographic style (such as Helvetica or Palatino). It is more specific
- * than a logical font name (such as Sans Serif) but less specific than a
- * font face name (such as Helvetica Bold).
- *
- * @param lc The locale in which to describe the name of the font family.
- *
- * @return A string containing the font family name, localized for the
- * provided locale.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFontName()
- * @see GraphicsEnvironment#getAvailableFontFamilyNames()
- * @see Locale
- */
- public String getFamily (Locale lc)
-{
- return peer.getFamily (this, lc);
-}
+ /**
+ * Returns the family name of this font. A family name describes a
+ * typographic style (such as Helvetica or Palatino). It is more specific
+ * than a logical font name (such as Sans Serif) but less specific than a
+ * font face name (such as Helvetica Bold).
+ *
+ * @param lc The locale in which to describe the name of the font family.
+ *
+ * @return A string containing the font family name, localized for the
+ * provided locale.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFontName()
+ * @see GraphicsEnvironment#getAvailableFontFamilyNames()
+ * @see Locale
+ */
+ public String getFamily(Locale lc)
+ {
+ return peer.getFamily(this, lc);
+ }
-/**
- * Returns a font appropriate for the given attribute set.
- *
- * @param attributes The attributes required for the new font.
- *
- * @return A new Font with the given attributes.
- *
- * @since 1.2
- *
- * @see java.awt.font.TextAttribute
- */
- public static Font getFont (Map<? extends Attribute, ?> attributes)
-{
- return getFontFromToolkit (null, attributes);
-}
+ /**
+ * Returns a font appropriate for the given attribute set.
+ *
+ * @param attributes The attributes required for the new font.
+ *
+ * @return A new Font with the given attributes.
+ *
+ * @since 1.2
+ *
+ * @see java.awt.font.TextAttribute
+ */
+ public static Font getFont(Map attributes)
+ {
+ return getFontFromToolkit(null, attributes);
+ }
-/**
- * Returns the font face name of the font. A font face name describes a
- * specific variant of a font family (such as Helvetica Bold). It is more
- * specific than both a font family name (such as Helvetica) and a logical
- * font name (such as Sans Serif).
- *
- * @return The font face name of the font.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFamily()
- */
- public String getFontName ()
-{
- return peer.getFontName (this);
-}
+ /**
+ * Returns the font face name of the font. A font face name describes a
+ * specific variant of a font family (such as Helvetica Bold). It is more
+ * specific than both a font family name (such as Helvetica) and a logical
+ * font name (such as Sans Serif).
+ *
+ * @return The font face name of the font.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ */
+ public String getFontName()
+ {
+ return peer.getFontName(this);
+ }
-/**
- * Returns the font face name of the font. A font face name describes a
- * specific variant of a font family (such as Helvetica Bold). It is more
+ /**
+ * Returns the font face name of the font. A font face name describes a
+ * specific variant of a font family (such as Helvetica Bold). It is more
* specific than both a font family name (such as Helvetica).
- *
- * @param lc The locale in which to describe the name of the font face.
- *
- * @return A string containing the font face name, localized for the
- * provided locale.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFamily()
- */
- public String getFontName (Locale lc)
-{
- return peer.getFontName (this, lc);
-}
+ *
+ * @param lc The locale in which to describe the name of the font face.
+ *
+ * @return A string containing the font face name, localized for the
+ * provided locale.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ */
+ public String getFontName(Locale lc)
+ {
+ return peer.getFontName(this, lc);
+ }
-/**
- * Returns the italic angle of this font, a measurement of its slant when
- * style is {@link #ITALIC}. The precise meaning is the inverse slope of a
- * caret line which "best measures" the font's italic posture.
- *
- * @return The italic angle.
- *
- * @see java.awt.font.TextAttribute#POSTURE
- */
- public float getItalicAngle ()
-{
- return peer.getItalicAngle (this);
-}
+ /**
+ * Returns the italic angle of this font, a measurement of its slant when
+ * style is {@link #ITALIC}. The precise meaning is the inverse slope of a
+ * caret line which "best measures" the font's italic posture.
+ *
+ * @return The italic angle.
+ *
+ * @see java.awt.font.TextAttribute#POSTURE
+ */
+ public float getItalicAngle()
+ {
+ return peer.getItalicAngle(this);
+ }
-/**
- * Returns a {@link LineMetrics} object constructed with the specified
- * text and {@link FontRenderContext}.
- *
- * @param text The string to calculate metrics from.
- * @param begin Index of first character in <code>text</code> to measure.
- * @param limit Index of last character in <code>text</code> to measure.
- * @param rc Context for calculating precise glyph placement and hints.
- *
- * @return A new {@link LineMetrics} object.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>text</code>.
- */
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param text The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
public LineMetrics getLineMetrics(String text, int begin,
int limit, FontRenderContext rc)
-{
- return peer.getLineMetrics (this, new StringCharacterIterator (text),
- begin, limit, rc);
-}
+ {
+ return peer.getLineMetrics(this, new StringCharacterIterator(text),
+ begin, limit, rc);
+ }
-/**
- * Returns a {@link LineMetrics} object constructed with the specified
- * text and {@link FontRenderContext}.
- *
- * @param chars The string to calculate metrics from.
- * @param begin Index of first character in <code>text</code> to measure.
- * @param limit Index of last character in <code>text</code> to measure.
- * @param rc Context for calculating precise glyph placement and hints.
- *
- * @return A new {@link LineMetrics} object.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>chars</code>.
- */
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param chars The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ */
public LineMetrics getLineMetrics(char[] chars, int begin,
int limit, FontRenderContext rc)
-{
- return peer.getLineMetrics (this, new StringCharacterIterator (new String(chars)),
- begin, limit, rc);
-}
+ {
+ return peer.getLineMetrics(this,
+ new StringCharacterIterator(new String(chars)),
+ begin, limit, rc);
+ }
-/**
- * Returns a {@link LineMetrics} object constructed with the specified
- * text and {@link FontRenderContext}.
- *
- * @param ci The string to calculate metrics from.
- * @param begin Index of first character in <code>text</code> to measure.
- * @param limit Index of last character in <code>text</code> to measure.
- * @param rc Context for calculating precise glyph placement and hints.
- *
- * @return A new {@link LineMetrics} object.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>ci</code>.
- */
- public LineMetrics getLineMetrics (CharacterIterator ci, int begin,
- int limit, FontRenderContext rc)
-{
- return peer.getLineMetrics (this, ci, begin, limit, rc);
-}
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param ci The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>ci</code>.
+ */
+ public LineMetrics getLineMetrics(CharacterIterator ci, int begin,
+ int limit, FontRenderContext rc)
+ {
+ return peer.getLineMetrics(this, ci, begin, limit, rc);
+ }
-/**
- * Returns the maximal bounding box of all the bounding boxes in this
- * font, when the font's bounding boxes are evaluated in a given {@link
- * FontRenderContext}
- *
- * @param rc Context in which to evaluate bounding boxes.
- *
- * @return The maximal bounding box.
- */
- public Rectangle2D getMaxCharBounds (FontRenderContext rc)
-{
- return peer.getMaxCharBounds (this, rc);
-}
+ /**
+ * Returns the maximal bounding box of all the bounding boxes in this
+ * font, when the font's bounding boxes are evaluated in a given {@link
+ * FontRenderContext}
+ *
+ * @param rc Context in which to evaluate bounding boxes.
+ *
+ * @return The maximal bounding box.
+ */
+ public Rectangle2D getMaxCharBounds(FontRenderContext rc)
+ {
+ return peer.getMaxCharBounds(this, rc);
+ }
-/**
- * Returns the glyph code this font uses to represent missing glyphs. This
- * code will be present in glyph vectors when the font was unable to
- * locate a glyph to represent a particular character code.
- *
- * @return The missing glyph code.
- *
- * @since 1.2
- */
- public int getMissingGlyphCode ()
-{
- return peer.getMissingGlyphCode (this);
-}
+ /**
+ * Returns the glyph code this font uses to represent missing glyphs. This
+ * code will be present in glyph vectors when the font was unable to
+ * locate a glyph to represent a particular character code.
+ *
+ * @return The missing glyph code.
+ *
+ * @since 1.2
+ */
+ public int getMissingGlyphCode()
+ {
+ return peer.getMissingGlyphCode(this);
+ }
-/**
- * Returns the overall number of glyphs in this font. This number is one
- * more than the greatest glyph code used in any glyph vectors this font
- * produces. In other words, glyph codes are taken from the range
- * <code>[ 0, getNumGlyphs() - 1 ]</code>.
- *
- * @return The number of glyphs in this font.
- *
- * @since 1.2
- */
- public int getNumGlyphs ()
-{
- return peer.getMissingGlyphCode (this);
-}
+ /**
+ * Returns the overall number of glyphs in this font. This number is one
+ * more than the greatest glyph code used in any glyph vectors this font
+ * produces. In other words, glyph codes are taken from the range
+ * <code>[ 0, getNumGlyphs() - 1 ]</code>.
+ *
+ * @return The number of glyphs in this font.
+ *
+ * @since 1.2
+ */
+ public int getNumGlyphs()
+ {
+ return peer.getMissingGlyphCode(this);
+ }
-/**
- * Returns the PostScript Name of this font.
- *
- * @return The PostScript Name of this font.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFamily()
- * @see #getFontName()
- */
- public String getPSName ()
-{
- return peer.getPostScriptName (this);
-}
+ /**
+ * Returns the PostScript Name of this font.
+ *
+ * @return The PostScript Name of this font.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ * @see #getFontName()
+ */
+ public String getPSName()
+ {
+ return peer.getPostScriptName(this);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param str The string to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @see #createGlyphVector(FontRenderContext, String)
- */
- public Rectangle2D getStringBounds (String str, FontRenderContext frc)
-{
- return getStringBounds (str, 0, str.length () - 1, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param str The string to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @see #createGlyphVector(FontRenderContext, String)
+ */
+ public Rectangle2D getStringBounds(String str, FontRenderContext frc)
+ {
+ return getStringBounds(str, 0, str.length() - 1, frc);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param str The string to measure.
- * @param begin Index of the first character in <code>str</code> to measure.
- * @param limit Index of the last character in <code>str</code> to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>str</code>.
- *
- * @since 1.2
- *
- * @see #createGlyphVector(FontRenderContext, String)
- */
- public Rectangle2D getStringBounds (String str, int begin,
- int limit, FontRenderContext frc)
-{
- return peer.getStringBounds (this, new StringCharacterIterator(str), begin, limit, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param str The string to measure.
+ * @param begin Index of the first character in <code>str</code> to measure.
+ * @param limit Index of the last character in <code>str</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>str</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, String)
+ */
+ public Rectangle2D getStringBounds(String str, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this, new StringCharacterIterator(str), begin,
+ limit, frc);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param ci The text to measure.
- * @param begin Index of the first character in <code>ci</code> to measure.
- * @param limit Index of the last character in <code>ci</code> to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>ci</code>.
- *
- * @since 1.2
- *
- * @see #createGlyphVector(FontRenderContext, CharacterIterator)
- */
- public Rectangle2D getStringBounds (CharacterIterator ci, int begin,
- int limit, FontRenderContext frc)
-{
- return peer.getStringBounds (this, ci, begin, limit, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param ci The text to measure.
+ * @param begin Index of the first character in <code>ci</code> to measure.
+ * @param limit Index of the last character in <code>ci</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>ci</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, CharacterIterator)
+ */
+ public Rectangle2D getStringBounds(CharacterIterator ci, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this, ci, begin, limit, frc);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param chars The text to measure.
- * @param begin Index of the first character in <code>ci</code> to measure.
- * @param limit Index of the last character in <code>ci</code> to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>chars</code>.
- *
- * @since 1.2
- *
- * @see #createGlyphVector(FontRenderContext, char[])
- */
- public Rectangle2D getStringBounds (char[] chars, int begin,
- int limit, FontRenderContext frc)
-{
- return peer.getStringBounds (this, new StringCharacterIterator (new String (chars)),
- begin, limit, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param chars The text to measure.
+ * @param begin Index of the first character in <code>ci</code> to measure.
+ * @param limit Index of the last character in <code>ci</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, char[])
+ */
+ public Rectangle2D getStringBounds(char[] chars, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this,
+ new StringCharacterIterator(new String(chars)),
+ begin, limit, frc);
+ }
-/**
- * Returns a copy of the affine transformation this font is currently
- * subject to, if any.
- *
- * @return The current transformation.
- */
- public AffineTransform getTransform ()
-{
- return peer.getTransform (this);
-}
+ /**
+ * Returns a copy of the affine transformation this font is currently
+ * subject to, if any.
+ *
+ * @return The current transformation.
+ */
+ public AffineTransform getTransform()
+ {
+ return peer.getTransform(this);
+ }
-/**
- * Indicates whether this font's line metrics are uniform. A font may be
- * composed of several "subfonts", each covering a different code range,
- * and each with their own line metrics. A font with no subfonts, or
- * subfonts with identical line metrics, is said to have "uniform" line
- * metrics.
- *
- * @return Whether this font has uniform line metrics.
- *
- * @see LineMetrics
- * @see #getLineMetrics(String, FontRenderContext)
- */
- public boolean hasUniformLineMetrics ()
-{
- return peer.hasUniformLineMetrics (this);
-}
+ /**
+ * Indicates whether this font's line metrics are uniform. A font may be
+ * composed of several "subfonts", each covering a different code range,
+ * and each with their own line metrics. A font with no subfonts, or
+ * subfonts with identical line metrics, is said to have "uniform" line
+ * metrics.
+ *
+ * @return Whether this font has uniform line metrics.
+ *
+ * @see LineMetrics
+ * @see #getLineMetrics(String, FontRenderContext)
+ */
+ public boolean hasUniformLineMetrics()
+ {
+ return peer.hasUniformLineMetrics(this);
+ }
-/**
- * Indicates whether this font is subject to a non-identity affine
- * transformation.
- *
- * @return <code>true</code> iff the font has a non-identity affine
- * transformation applied to it.
- */
- public boolean isTransformed ()
-{
- return peer.isTransformed (this);
-}
+ /**
+ * Indicates whether this font is subject to a non-identity affine
+ * transformation.
+ *
+ * @return <code>true</code> iff the font has a non-identity affine
+ * transformation applied to it.
+ */
+ public boolean isTransformed()
+ {
+ return peer.isTransformed(this);
+ }
-/**
- * Produces a glyph vector representing a full layout fo the specified
- * text in this font. Full layouts may include complex shaping and
- * reordering operations, for scripts such as Arabic or Hindi.
- *
- * Bidirectional (bidi) layout is not performed in this method; text
- * should have its bidi direction specified with one of the flags {@link
- * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}.
- *
- * Some types of layout (notably Arabic glyph shaping) may examine context
- * characters beyond the bounds of the indicated range, in order to select
- * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and
- * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra
- * context areas from being examined, for instance if they contain invalid
- * characters.
- *
- * @param frc Context in which to perform the layout.
- * @param chars Text to perform layout on.
- * @param start Index of first character to perform layout on.
- * @param limit Index of last character to perform layout on.
- * @param flags Combination of flags controlling layout.
- *
- * @return A new {@link GlyphVector} representing the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>chars</code>.
- */
- public GlyphVector layoutGlyphVector (FontRenderContext frc,
- char[] chars, int start,
- int limit, int flags)
-{
- return peer.layoutGlyphVector (this, frc, chars, start, limit, flags);
-}
+ /**
+ * Produces a glyph vector representing a full layout fo the specified
+ * text in this font. Full layouts may include complex shaping and
+ * reordering operations, for scripts such as Arabic or Hindi.
+ *
+ * Bidirectional (bidi) layout is not performed in this method; text
+ * should have its bidi direction specified with one of the flags {@link
+ * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}.
+ *
+ * Some types of layout (notably Arabic glyph shaping) may examine context
+ * characters beyond the bounds of the indicated range, in order to select
+ * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and
+ * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra
+ * context areas from being examined, for instance if they contain invalid
+ * characters.
+ *
+ * @param frc Context in which to perform the layout.
+ * @param chars Text to perform layout on.
+ * @param start Index of first character to perform layout on.
+ * @param limit Index of last character to perform layout on.
+ * @param flags Combination of flags controlling layout.
+ *
+ * @return A new {@link GlyphVector} representing the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ */
+ public GlyphVector layoutGlyphVector(FontRenderContext frc,
+ char[] chars, int start,
+ int limit, int flags)
+ {
+ return peer.layoutGlyphVector(this, frc, chars, start, limit, flags);
+ }
-/**
- * Returns a native peer object for this font.
- *
- * @return A native peer object for this font.
- *
- * @deprecated
- */
- public FontPeer getPeer ()
-{
+ /**
+ * Returns a native peer object for this font.
+ *
+ * @return A native peer object for this font.
+ *
+ * @deprecated
+ */
+ public FontPeer getPeer()
+ {
return peer;
-}
+ }
-/**
- * Returns a hash value for this font.
- *
- * @return A hash for this font.
- */
+ /**
+ * Returns a hash value for this font.
+ *
+ * @return A hash for this font.
+ */
public int hashCode()
-{
+ {
return this.toString().hashCode();
-}
-
-
-/**
- * Tests whether or not the specified object is equal to this font. This
- * will be true if and only if:
- * <P>
- * <ul>
- * <li>The object is not <code>null</code>.
- * <li>The object is an instance of <code>Font</code>.
- * <li>The object has the same names, style, size, and transform as this object.
- * </ul>
- *
- * @return <code>true</code> if the specified object is equal to this
- * object, <code>false</code> otherwise.
- */
-public boolean
-equals(Object obj)
-{
- if (obj == null)
- return(false);
+ }
- if (!(obj instanceof Font))
- return(false);
- Font f = (Font)obj;
+ /**
+ * Tests whether or not the specified object is equal to this font. This
+ * will be true if and only if:
+ * <P>
+ * <ul>
+ * <li>The object is not <code>null</code>.
+ * <li>The object is an instance of <code>Font</code>.
+ * <li>The object has the same names, style, size, and transform as this object.
+ * </ul>
+ *
+ * @return <code>true</code> if the specified object is equal to this
+ * object, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ return false;
- return (f.getName ().equals (this.getName ()) &&
- f.getFamily ().equals (this.getFamily ()) &&
- f.getFontName ().equals (this.getFontName ()) &&
- f.getTransform ().equals (this.getTransform ()) &&
- f.getSize() == this.getSize() &&
- f.getStyle() == this.getStyle());
-}
+ if (! (obj instanceof Font))
+ return false;
-/*************************************************************************/
+ Font f = (Font) obj;
-/**
- * Returns a string representation of this font.
- *
- * @return A string representation of this font.
- */
-public String
-toString()
-{
- String styleString = "";
-
- switch (getStyle ())
- {
- case 0:
- styleString = "plain";
- break;
- case 1:
- styleString = "bold";
- break;
- case 2:
- styleString = "italic";
- break;
- default:
- styleString = "unknown";
- }
+ return (f.getName().equals(this.getName())
+ && f.getFamily().equals(this.getFamily())
+ && f.getFontName().equals(this.getFontName())
+ && f.getTransform().equals(this.getTransform ())
+ && f.getSize() == this.getSize()
+ && f.getStyle() == this.getStyle());
+ }
- return getClass ().getName ()
- + "[family=" + getFamily ()
- + ",name=" + getFontName ()
- + ",style=" + styleString
- + ",size=" + getSize () + "]";
-}
+ /**
+ * Returns a string representation of this font.
+ *
+ * @return A string representation of this font.
+ */
+ public String toString()
+ {
+ String styleString = "";
+
+ switch (getStyle())
+ {
+ case 0:
+ styleString = "plain";
+ break;
+ case 1:
+ styleString = "bold";
+ break;
+ case 2:
+ styleString = "italic";
+ break;
+ default:
+ styleString = "unknown";
+ }
+
+ return getClass().getName()
+ + "[family=" + getFamily ()
+ + ",name=" + getFontName ()
+ + ",style=" + styleString
+ + ",size=" + getSize () + "]";
+ }
/**
@@ -1332,8 +1321,22 @@ toString()
*/
public LineMetrics getLineMetrics(String str, FontRenderContext frc)
{
- return getLineMetrics (str, 0, str.length () - 1, frc);
+ return getLineMetrics(str, 0, str.length() - 1, frc);
}
-} // class Font
+ /**
+ * Reads the normal fields from the stream and then constructs the
+ * peer from the style and size through getPeerFromToolkit().
+ */
+ private void readObject(ObjectInputStream ois)
+ throws IOException, ClassNotFoundException
+ {
+ ois.defaultReadObject();
+
+ HashMap attrs = new HashMap();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
+ peer = getPeerFromToolkit(name, attrs);
+ }
+}
diff --git a/java/awt/FontMetrics.java b/java/awt/FontMetrics.java
index 6dd73ec25..91866462f 100644
--- a/java/awt/FontMetrics.java
+++ b/java/awt/FontMetrics.java
@@ -362,6 +362,18 @@ public abstract class FontMetrics implements java.io.Serializable
rc = gRC;
return font.getLineMetrics(chars, begin, limit, rc);
}
+
+ /**
+ * Returns the bounds of the largest character in a Graphics context.
+ * @param context the Graphics context object.
+ * @return a <code>Rectangle2D</code> representing the bounds
+ */
+ public Rectangle2D getMaxCharBounds(Graphics context)
+ {
+ if( context instanceof Graphics2D )
+ return font.getMaxCharBounds(((Graphics2D)context).getFontRenderContext());
+ return font.getMaxCharBounds( gRC );
+ }
/**
* Returns a {@link LineMetrics} object constructed with the
@@ -424,4 +436,13 @@ public abstract class FontMetrics implements java.io.Serializable
return gRC;
}
+
+ /**
+ * Returns if the font has uniform line metrics.
+ * @see Font#hasUniformLineMetrics()
+ */
+ public boolean hasUniformLineMetrics()
+ {
+ return font.hasUniformLineMetrics();
+ }
}
diff --git a/java/awt/Graphics.java b/java/awt/Graphics.java
index ff26190e5..a28ca7e42 100644
--- a/java/awt/Graphics.java
+++ b/java/awt/Graphics.java
@@ -42,726 +42,595 @@ import java.awt.image.ImageObserver;
import java.text.AttributedCharacterIterator;
/**
- * This is the abstract superclass of classes for drawing to graphics
- * devices such as the screen or printers.
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- * @author Warren Levy (warrenl@cygnus.com)
- */
-public abstract class Graphics
-{
-
-/*
- * Instance Variables
- */
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * Default constructor for subclasses.
- */
-protected
-Graphics()
-{
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
+ * This is the abstract superclass of classes for drawing to graphics
+ * devices such as the screen or printers.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Warren Levy (warrenl@cygnus.com)
*/
-
-/**
- * Returns a copy of this <code>Graphics</code> object.
- *
- * @return A copy of this object.
- */
-public abstract Graphics
-create();
-
-/*************************************************************************/
-
-/**
- * Returns a copy of this <code>Graphics</code> object. The origin point
- * will be translated to the point (x, y) and the cliping rectangle set
- * to the intersection of the clipping rectangle in this object and the
- * rectangle specified by the parameters to this method.
- *
- * @param x The new X coordinate of the clipping region rect.
- * @param y The new Y coordinate of the clipping region rect.
- * @param width The width of the clipping region intersect rectangle.
- * @param height The height of the clipping region intersect rectangle.
- *
- * @return A copy of this object, modified as specified.
- */
-public Graphics
-create(int x, int y, int width, int height)
+public abstract class Graphics
{
- Graphics g = create();
-
- g.translate(x, y);
- // FIXME: I'm not sure if this will work. Are the old clip rect bounds
- // translated above?
- g.clipRect(0, 0, width, height);
- return(g);
-}
-
-/*************************************************************************/
-
-/**
- * Translates this context so that its new origin point is the point
- * (x, y).
- *
- * @param x The new X coordinate of the origin.
- * @param y The new Y coordinate of the origin.
- */
-public abstract void
-translate(int x, int y);
-
-/*************************************************************************/
-
-/**
- * Returns the current color for this object.
- *
- * @return The color for this object.
- */
-public abstract Color
-getColor();
-
-/*************************************************************************/
-
-/**
- * Sets the current color for this object.
- *
- * @param color The new color.
- */
-public abstract void
-setColor(Color color);
-
-/*************************************************************************/
-
-/**
- * Sets this context into "paint" mode, where the target pixels are
- * completely overwritten when drawn on.
- */
-public abstract void
-setPaintMode();
-
-/*************************************************************************/
-
-/**
- * Sets this context info "XOR" mode, where the targe pixles are
- * XOR-ed when drawn on.
- *
- * @param color The color to XOR against.
- */
-public abstract void
-setXORMode(Color color);
+ /**
+ * Default constructor for subclasses.
+ */
+ protected
+ Graphics()
+ {
+ }
+
+ /**
+ * Returns a copy of this <code>Graphics</code> object.
+ *
+ * @return A copy of this object.
+ */
+ public abstract Graphics create();
+
+ /**
+ * Returns a copy of this <code>Graphics</code> object. The origin point
+ * will be translated to the point (x, y) and the cliping rectangle set
+ * to the intersection of the clipping rectangle in this object and the
+ * rectangle specified by the parameters to this method.
+ *
+ * @param x The new X coordinate of the clipping region rect.
+ * @param y The new Y coordinate of the clipping region rect.
+ * @param width The width of the clipping region intersect rectangle.
+ * @param height The height of the clipping region intersect rectangle.
+ *
+ * @return A copy of this object, modified as specified.
+ */
+ public Graphics create(int x, int y, int width, int height)
+ {
+ Graphics g = create();
+
+ g.translate(x, y);
+ // FIXME: I'm not sure if this will work. Are the old clip rect bounds
+ // translated above?
+ g.clipRect(0, 0, width, height);
+
+ return(g);
+ }
+
+ /**
+ * Translates this context so that its new origin point is the point
+ * (x, y).
+ *
+ * @param x The new X coordinate of the origin.
+ * @param y The new Y coordinate of the origin.
+ */
+ public abstract void translate(int x, int y);
+
+ /**
+ * Returns the current color for this object.
+ *
+ * @return The color for this object.
+ */
+ public abstract Color getColor();
+
+ /**
+ * Sets the current color for this object.
+ *
+ * @param color The new color.
+ */
+ public abstract void setColor(Color color);
+
+ /**
+ * Sets this context into "paint" mode, where the target pixels are
+ * completely overwritten when drawn on.
+ */
+ public abstract void setPaintMode();
+
+ /**
+ * Sets this context info "XOR" mode, where the targe pixles are
+ * XOR-ed when drawn on.
+ *
+ * @param color The color to XOR against.
+ */
+ public abstract void setXORMode(Color color);
-/*************************************************************************/
-
-/**
- * Returns the current font for this graphics context.
- *
- * @return The current font.
- */
-public abstract Font
-getFont();
-
-/*************************************************************************/
-
-/**
- * Sets the font for this graphics context to the specified value.
- *
- * @param font The new font.
- */
-public abstract void
-setFont(Font font);
-
-/*************************************************************************/
-
-/**
- * Returns the font metrics for the current font.
- *
- * @return The font metrics for the current font.
- */
-public FontMetrics
-getFontMetrics()
-{
- return(getFontMetrics(getFont()));
-}
-
-/*************************************************************************/
-
-/**
- * Returns the font metrics for the specified font.
- *
- * @param font The font to return metrics for.
- *
- * @return The requested font metrics.
- */
-public abstract FontMetrics
-getFontMetrics(Font font);
-
-/*************************************************************************/
-
-/**
- * Returns the bounding rectangle of the clipping region for this
- * graphics context.
- *
- * @return The bounding rectangle for the clipping region.
- */
-public abstract Rectangle
-getClipBounds();
-
-/*************************************************************************/
-
-/**
- * Returns the bounding rectangle of the clipping region for this
- * graphics context.
- *
- * @return The bounding rectangle for the clipping region.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getClipBounds()</code>.
- */
-public Rectangle
-getClipRect()
-{
- return(getClipBounds());
-}
-
-/*************************************************************************/
-
-/**
- * Sets the clipping region to the intersection of the current clipping
- * region and the rectangle determined by the specified parameters.
- *
- * @param x The X coordinate of the upper left corner of the intersect rect.
- * @param y The Y coordinate of the upper left corner of the intersect rect.
- * @param width The width of the intersect rect.
- * @param height The height of the intersect rect.
- */
-public abstract void
-clipRect(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Sets the clipping region to the rectangle determined by the specified
- * parameters.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- */
-public abstract void
-setClip(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Returns the current clipping region as a <code>Shape</code> object.
- *
- * @return The clipping region as a <code>Shape</code>.
- */
-public abstract Shape
-getClip();
-
-/*************************************************************************/
-
-/**
- * Sets the clipping region to the specified <code>Shape</code>.
- *
- * @param clip The new clipping region.
- */
-public abstract void
-setClip(Shape clip);
-
-/*************************************************************************/
-
-/**
- * Copies the specified rectangle to the specified offset location.
- *
- * @param x The X coordinate of the upper left corner of the copy rect.
- * @param y The Y coordinate of the upper left corner of the copy rect.
- * @param width The width of the copy rect.
- * @param height The height of the copy rect.
- * @param dx The offset from the X value to start drawing.
- * @param dy The offset from the Y value to start drawing.
- */
-public abstract void
-copyArea(int x, int y, int width, int height, int dx, int dy);
-
-/*************************************************************************/
-
-/**
- * Draws a line between the two specified points.
- *
- * @param x1 The X coordinate of the first point.
- * @param y1 The Y coordinate of the first point.
- * @param x2 The X coordinate of the second point.
- * @param y2 The Y coordinate of the second point.
- */
-public abstract void
-drawLine(int x1, int y1, int x2, int y2);
-
-/*************************************************************************/
-
-/**
- * Fills the area bounded by the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the fill rect.
- * @param y The Y coordinate of the upper left corner of the fill rect.
- * @param width The width of the fill rect.
- * @param height The height of the fill rect.
- */
-public abstract void
-fillRect(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Draws the outline of the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the draw rect.
- * @param y The Y coordinate of the upper left corner of the draw rect.
- * @param width The width of the draw rect.
- * @param height The height of the draw rect.
- */
-public void
-drawRect(int x, int y, int width, int height)
-{
- int x1 = x;
- int y1 = y;
- int x2 = x + width;
- int y2 = y + height;
- drawLine(x1, y1, x2, y1);
- drawLine(x2, y1, x2, y2);
- drawLine(x2, y2, x1, y2);
- drawLine(x1, y2, x1, y1);
-}
-
-/*************************************************************************/
-
-/**
- * Clears the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the clear rect.
- * @param y The Y coordinate of the upper left corner of the clear rect.
- * @param width The width of the clear rect.
- * @param height The height of the clear rect.
- */
-public abstract void
-clearRect(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Draws the outline of the specified rectangle with rounded cornders.
- *
- * @param x The X coordinate of the upper left corner of the draw rect.
- * @param y The Y coordinate of the upper left corner of the draw rect.
- * @param width The width of the draw rect.
- * @param height The height of the draw rect.
- * @param arcWidth The width of the corner arcs.
- * @param arcHeight The height of the corner arcs.
- */
-public abstract void
-drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);
-
-/*************************************************************************/
-
-/**
- * Fills the specified rectangle with rounded cornders.
- *
- * @param x The X coordinate of the upper left corner of the fill rect.
- * @param y The Y coordinate of the upper left corner of the fill rect.
- * @param width The width of the fill rect.
- * @param height The height of the fill rect.
- * @param arcWidth The width of the corner arcs.
- * @param arcHeight The height of the corner arcs.
- */
-public abstract void
-fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);
-
-/*************************************************************************/
-
-public void
-draw3DRect(int x, int y, int width, int height, boolean raised)
-{
- Color color = getColor();
- Color tl = color.brighter();
- Color br = color.darker();
+ /**
+ * Returns the current font for this graphics context.
+ *
+ * @return The current font.
+ */
+ public abstract Font getFont();
+
+ /**
+ * Sets the font for this graphics context to the specified value.
+ *
+ * @param font The new font.
+ */
+ public abstract void setFont(Font font);
+
+ /**
+ * Returns the font metrics for the current font.
+ *
+ * @return The font metrics for the current font.
+ */
+ public FontMetrics getFontMetrics()
+ {
+ return getFontMetrics(getFont());
+ }
+
+ /**
+ * Returns the font metrics for the specified font.
+ *
+ * @param font The font to return metrics for.
+ *
+ * @return The requested font metrics.
+ */
+ public abstract FontMetrics getFontMetrics(Font font);
+
+ /**
+ * Returns the bounding rectangle of the clipping region for this
+ * graphics context.
+ *
+ * @return The bounding rectangle for the clipping region.
+ */
+ public abstract Rectangle getClipBounds();
+
+ /**
+ * Returns the bounding rectangle of the clipping region for this
+ * graphics context.
+ *
+ * @return The bounding rectangle for the clipping region.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getClipBounds()</code>.
+ */
+ public Rectangle getClipRect()
+ {
+ return getClipBounds();
+ }
+
+ /**
+ * Sets the clipping region to the intersection of the current clipping
+ * region and the rectangle determined by the specified parameters.
+ *
+ * @param x The X coordinate of the upper left corner of the intersect rect.
+ * @param y The Y coordinate of the upper left corner of the intersect rect.
+ * @param width The width of the intersect rect.
+ * @param height The height of the intersect rect.
+ */
+ public abstract void clipRect(int x, int y, int width, int height);
+
+ /**
+ * Sets the clipping region to the rectangle determined by the specified
+ * parameters.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void setClip(int x, int y, int width, int height);
+
+ /**
+ * Returns the current clipping region as a <code>Shape</code> object.
+ *
+ * @return The clipping region as a <code>Shape</code>.
+ */
+ public abstract Shape getClip();
+
+ /**
+ * Sets the clipping region to the specified <code>Shape</code>.
+ *
+ * @param clip The new clipping region.
+ */
+ public abstract void setClip(Shape clip);
+
+ /**
+ * Copies the specified rectangle to the specified offset location.
+ *
+ * @param x The X coordinate of the upper left corner of the copy rect.
+ * @param y The Y coordinate of the upper left corner of the copy rect.
+ * @param width The width of the copy rect.
+ * @param height The height of the copy rect.
+ * @param dx The offset from the X value to start drawing.
+ * @param dy The offset from the Y value to start drawing.
+ */
+ public abstract void copyArea(int x, int y, int width, int height, int dx,
+ int dy);
+
+ /**
+ * Draws a line between the two specified points.
+ *
+ * @param x1 The X coordinate of the first point.
+ * @param y1 The Y coordinate of the first point.
+ * @param x2 The X coordinate of the second point.
+ * @param y2 The Y coordinate of the second point.
+ */
+ public abstract void drawLine(int x1, int y1, int x2, int y2);
+
+ /**
+ * Fills the area bounded by the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ */
+ public abstract void fillRect(int x, int y, int width, int height);
+
+ /**
+ * Draws the outline of the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the draw rect.
+ * @param y The Y coordinate of the upper left corner of the draw rect.
+ * @param width The width of the draw rect.
+ * @param height The height of the draw rect.
+ */
+ public void drawRect(int x, int y, int width, int height)
+ {
+ int x1 = x;
+ int y1 = y;
+ int x2 = x + width;
+ int y2 = y + height;
+ drawLine(x1, y1, x2, y1);
+ drawLine(x2, y1, x2, y2);
+ drawLine(x2, y2, x1, y2);
+ drawLine(x1, y2, x1, y1);
+ }
+
+ /**
+ * Clears the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the clear rect.
+ * @param y The Y coordinate of the upper left corner of the clear rect.
+ * @param width The width of the clear rect.
+ * @param height The height of the clear rect.
+ */
+ public abstract void clearRect(int x, int y, int width, int height);
+
+ /**
+ * Draws the outline of the specified rectangle with rounded cornders.
+ *
+ * @param x The X coordinate of the upper left corner of the draw rect.
+ * @param y The Y coordinate of the upper left corner of the draw rect.
+ * @param width The width of the draw rect.
+ * @param height The height of the draw rect.
+ * @param arcWidth The width of the corner arcs.
+ * @param arcHeight The height of the corner arcs.
+ */
+ public abstract void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight);
+
+ /**
+ * Fills the specified rectangle with rounded cornders.
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ * @param arcWidth The width of the corner arcs.
+ * @param arcHeight The height of the corner arcs.
+ */
+ public abstract void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight);
+
+ public void draw3DRect(int x, int y, int width, int height, boolean raised)
+ {
+ Color color = getColor();
+ Color tl = color.brighter();
+ Color br = color.darker();
- if (!raised)
- {
- Color tmp = tl;
- tl = br;
- br = tmp;
- }
+ if (!raised)
+ {
+ Color tmp = tl;
+ tl = br;
+ br = tmp;
+ }
- int x1 = x;
- int y1 = y;
- int x2 = x + width;
- int y2 = y + height;
+ int x1 = x;
+ int y1 = y;
+ int x2 = x + width;
+ int y2 = y + height;
- setColor(tl);
- drawLine(x1, y1, x2, y1);
- drawLine(x1, y2, x1, y1);
- setColor(br);
- drawLine(x2, y1, x2, y2);
- drawLine(x2, y2, x1, y2);
- setColor(color);
-}
-
-/**
- * Fills the specified rectangle with a 3D effect
- *
- * @param x The X coordinate of the upper left corner of the fill rect.
- * @param y The Y coordinate of the upper left corner of the fill rect.
- * @param width The width of the fill rect.
- * @param height The height of the fill rect.
- * @param raised <code>true</code> if the rectangle appears raised,
- * <code>false</code> if it should appear etched.
- */
-public void
-fill3DRect(int x, int y, int width, int height, boolean raised)
-{
- fillRect(x, y, width, height);
- draw3DRect(x, y, width-1, height-1, raised);
-}
-
-/*************************************************************************/
-
-/**
- * Draws an oval that just fits within the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- */
-public abstract void
-drawOval(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Fills an oval that just fits within the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- */
-public abstract void
-fillOval(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Draws an arc using the specified bounding rectangle and the specified
- * angle parameter. The arc is centered at the center of the rectangle.
- * The arc starts at the arcAngle position and extend for arcAngle
- * degrees. The degree origin is at the 3 o'clock position.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- * @param arcStart The beginning angle of the arc.
- * @param arcAngle The extent of the arc.
- */
-public abstract void
-drawArc(int x, int y, int width, int height, int arcStart, int arcAngle);
-
-/*************************************************************************/
-
-/**
- * Fills the arc define by the specified bounding rectangle and the specified
- * angle parameter. The arc is centered at the center of the rectangle.
- * The arc starts at the arcAngle position and extend for arcAngle
- * degrees. The degree origin is at the 3 o'clock position.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- * @param arcStart The beginning angle of the arc.
- * @param arcAngle The extent of the arc.
- */
-public abstract void
-fillArc(int x, int y, int width, int height, int arcStart, int arcAngle);
-
-/*************************************************************************/
-
-/**
- * Draws a series of interconnected lines determined by the arrays
- * of corresponding x and y coordinates.
- *
- * @param xPoints The X coordinate array.
- * @param yPoints The Y coordinate array.
- * @param npoints The number of points to draw.
- */
-public abstract void
-drawPolyline(int xPoints[], int yPoints[], int npoints);
-
-/*************************************************************************/
-
-/**
- * Draws a series of interconnected lines determined by the arrays
- * of corresponding x and y coordinates. The figure is closed if necessary
- * by connecting the first and last points.
- *
- * @param xPoints The X coordinate array.
- * @param yPoints The Y coordinate array.
- * @param npoints The number of points to draw.
- */
-public abstract void
-drawPolygon(int xPoints[], int yPoints[], int npoints);
-
-/*************************************************************************/
-
-/**
- * Draws the specified polygon.
- *
- * @param polygon The polygon to draw.
- */
-public void
-drawPolygon(Polygon polygon)
-{
- drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
-}
-
-/*************************************************************************/
-
-/**
- * Fills the polygon determined by the arrays
- * of corresponding x and y coordinates.
- *
- * @param xPoints The X coordinate array.
- * @param yPoints The Y coordinate array.
- * @param npoints The number of points to draw.
- */
-public abstract void
-fillPolygon(int xPoints[], int yPoints[], int npoints);
-
-/*************************************************************************/
-
-/**
- * Fills the specified polygon
- *
- * @param polygon The polygon to fill.
- */
-public void
-fillPolygon(Polygon polygon)
-{
- fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
-}
-
-/*************************************************************************/
-
-/**
- * Draws the specified string starting at the specified point.
- *
- * @param string The string to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- */
-public abstract void
-drawString(String string, int x, int y);
-
-public abstract void drawString (AttributedCharacterIterator ci, int x, int y);
-
-/*************************************************************************/
-
-/**
- * Draws the specified characters starting at the specified point.
- *
- * @param data The array of characters to draw.
- * @param offset The offset into the array to start drawing characters from.
- * @param length The number of characters to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- */
-public void
-drawChars(char data[], int offset, int length, int x, int y)
-{
- drawString(new String(data, offset, length), x, y);
-}
-
-public void
-drawBytes(byte[] data, int offset, int length, int x, int y)
-{
- String str = new String(data, offset, length);
- drawString(str, x, y);
-}
-
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, ImageObserver observer);
+ setColor(tl);
+ drawLine(x1, y1, x2, y1);
+ drawLine(x1, y2, x1, y1);
+ setColor(br);
+ drawLine(x2, y1, x2, y2);
+ drawLine(x2, y2, x1, y2);
+ setColor(color);
+ }
+
+ /**
+ * Fills the specified rectangle with a 3D effect
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ * @param raised <code>true</code> if the rectangle appears raised,
+ * <code>false</code> if it should appear etched.
+ */
+ public void fill3DRect(int x, int y, int width, int height, boolean raised)
+ {
+ fillRect(x, y, width, height);
+ draw3DRect(x, y, width-1, height-1, raised);
+ }
+
+ /**
+ * Draws an oval that just fits within the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void drawOval(int x, int y, int width, int height);
+
+ /**
+ * Fills an oval that just fits within the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void fillOval(int x, int y, int width, int height);
+
+ /**
+ * Draws an arc using the specified bounding rectangle and the specified
+ * angle parameter. The arc is centered at the center of the rectangle.
+ * The arc starts at the arcAngle position and extend for arcAngle
+ * degrees. The degree origin is at the 3 o'clock position.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ * @param arcStart The beginning angle of the arc.
+ * @param arcAngle The extent of the arc.
+ */
+ public abstract void drawArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle);
+
+ /**
+ * Fills the arc define by the specified bounding rectangle and the specified
+ * angle parameter. The arc is centered at the center of the rectangle.
+ * The arc starts at the arcAngle position and extend for arcAngle
+ * degrees. The degree origin is at the 3 o'clock position.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ * @param arcStart The beginning angle of the arc.
+ * @param arcAngle The extent of the arc.
+ */
+ public abstract void fillArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle);
+
+ /**
+ * Draws a series of interconnected lines determined by the arrays
+ * of corresponding x and y coordinates.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void drawPolyline(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Draws a series of interconnected lines determined by the arrays
+ * of corresponding x and y coordinates. The figure is closed if necessary
+ * by connecting the first and last points.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void drawPolygon(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Draws the specified polygon.
+ *
+ * @param polygon The polygon to draw.
+ */
+ public void drawPolygon(Polygon polygon)
+ {
+ drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
+ }
+
+ /**
+ * Fills the polygon determined by the arrays
+ * of corresponding x and y coordinates.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void fillPolygon(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Fills the specified polygon
+ *
+ * @param polygon The polygon to fill.
+ */
+ public void fillPolygon(Polygon polygon)
+ {
+ fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
+ }
+
+ /**
+ * Draws the specified string starting at the specified point.
+ *
+ * @param string The string to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ */
+ public abstract void drawString(String string, int x, int y);
+
+ public abstract void drawString (AttributedCharacterIterator ci, int x,
+ int y);
+
+ /**
+ * Draws the specified characters starting at the specified point.
+ *
+ * @param data The array of characters to draw.
+ * @param offset The offset into the array to start drawing characters from.
+ * @param length The number of characters to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ */
+ public void drawChars(char data[], int offset, int length, int x, int y)
+ {
+ drawString(new String(data, offset, length), x, y);
+ }
+
+ public void drawBytes(byte[] data, int offset, int length, int x, int y)
+ {
+ String str = new String(data, offset, length);
+ drawString(str, x, y);
+ }
+
+ /**
+ * Draws all of the image that is available and returns. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y,
+ ImageObserver observer);
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. The image
- * is scaled to fit in the specified rectangle. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param width The width of the rectangle to draw in.
- * @param height The height of the rectangle to draw in.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, int width, int height,
- ImageObserver observer);
+ /**
+ * Draws all of the image that is available and returns. The image
+ * is scaled to fit in the specified rectangle. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param width The width of the rectangle to draw in.
+ * @param height The height of the rectangle to draw in.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, int width,
+ int height, ImageObserver observer);
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param bgcolor The background color to use for the image.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer);
+ /**
+ * Draws all of the image that is available and returns. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param bgcolor The background color to use for the image.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer);
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. The image
- * is scaled to fit in the specified rectangle. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param width The width of the rectangle to draw in.
- * @param height The height of the rectangle to draw in.
- * @param bgcolor The background color to use for the image.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, int width, int height, Color bgcolor,
- ImageObserver observer);
-
-/*************************************************************************/
-
-/**
- * FIXME: Write Javadocs for this when you understand it.
- */
-public abstract boolean
-drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
- int sx2, int sy2, ImageObserver observer);
-
-/*************************************************************************/
-
-/**
- * FIXME: Write Javadocs for this when you understand it.
- */
-public abstract boolean
-drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
- int sx2, int sy2, Color bgcolor, ImageObserver observer);
-
-/*************************************************************************/
-
-/**
- * Free any resources held by this graphics context immediately instead
- * of waiting for the object to be garbage collected and finalized.
- */
-public abstract void
-dispose();
-
-/*************************************************************************/
-
-/**
- * Frees the resources held by this graphics context when it is
- * garbage collected.
- */
-public void
-finalize()
-{
- dispose();
-}
-
-/*************************************************************************/
-
-/**
- * Returns a string representation of this object.
- *
- * @return A string representation of this object.
- */
-public String
-toString()
-{
- return getClass ().getName () + "[font=" + getFont () + ",color=" + getColor () + "]";
-}
-
-public boolean
-hitClip(int x, int y, int width, int height)
-{
- throw new UnsupportedOperationException("not implemented yet");
-}
-
-public Rectangle
-getClipBounds(Rectangle r)
-{
- Rectangle clipBounds = getClipBounds();
+ /**
+ * Draws all of the image that is available and returns. The image
+ * is scaled to fit in the specified rectangle. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param width The width of the rectangle to draw in.
+ * @param height The height of the rectangle to draw in.
+ * @param bgcolor The background color to use for the image.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, int width,
+ int height, Color bgcolor,
+ ImageObserver observer);
+
+ /**
+ * FIXME: Write Javadocs for this when you understand it.
+ */
+ public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
+ int dy2, int sx1, int sy1, int sx2,
+ int sy2, ImageObserver observer);
+
+ /**
+ * FIXME: Write Javadocs for this when you understand it.
+ */
+ public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
+ int dy2, int sx1, int sy1, int sx2,
+ int sy2, Color bgcolor,
+ ImageObserver observer);
+
+ /**
+ * Free any resources held by this graphics context immediately instead
+ * of waiting for the object to be garbage collected and finalized.
+ */
+ public abstract void dispose();
+
+ /**
+ * Frees the resources held by this graphics context when it is
+ * garbage collected.
+ */
+ public void finalize()
+ {
+ dispose();
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString()
+ {
+ return getClass ().getName () + "[font=" + getFont () + ",color="
+ + getColor () + "]";
+ }
+
+ /**
+ * Returns <code>true</code> if the specified rectangle intersects with the
+ * current clip, <code>false</code> otherwise.
+ *
+ * @param x the X coordinate of the upper left corner of the test rectangle
+ * @param y the Y coordinate of the upper left corner of the test rectangle
+ * @param width the width of the upper left corner of the test rectangle
+ * @param height the height of the upper left corner of the test rectangle
+ * @return <code>true</code> if the specified rectangle intersects with the
+ * current clip, <code>false</code> otherwise
+ */
+ public boolean hitClip(int x, int y, int width, int height)
+ {
+ return getClip().intersects(x, y, width, height);
+ }
+
+ public Rectangle getClipBounds(Rectangle r)
+ {
+ Rectangle clipBounds = getClipBounds();
- if (r == null)
- return clipBounds;
-
- r.x = clipBounds.x;
- r.y = clipBounds.y;
- r.width = clipBounds.width;
- r.height = clipBounds.height;
- return r;
+ if (r == null)
+ return clipBounds;
+
+ r.x = clipBounds.x;
+ r.y = clipBounds.y;
+ r.width = clipBounds.width;
+ r.height = clipBounds.height;
+ return r;
+ }
}
-
-} // class Graphics
-
diff --git a/java/awt/GraphicsConfiguration.java b/java/awt/GraphicsConfiguration.java
index 069d7414b..1526ad3cf 100644
--- a/java/awt/GraphicsConfiguration.java
+++ b/java/awt/GraphicsConfiguration.java
@@ -130,11 +130,10 @@ public abstract class GraphicsConfiguration
* with the given transparency. Because the buffer is volatile, it
* can be optimized by native graphics accelerators.
*
- * @param w the width of the buffer
- * @param h the height of the buffer
+ * @param width the width of the buffer
+ * @param height the height of the buffer
* @param transparency the transparency value for the buffer
* @return the buffered image, or null if none is supported
- * @throws AWTException if the capabilities cannot be met
* @since 1.5
*/
public abstract VolatileImage createCompatibleVolatileImage(int width,
diff --git a/java/awt/GridBagLayout.java b/java/awt/GridBagLayout.java
index f912bf97b..7e8fa0fb6 100644
--- a/java/awt/GridBagLayout.java
+++ b/java/awt/GridBagLayout.java
@@ -708,17 +708,20 @@ public class GridBagLayout
if (lastInCol.containsKey(new Integer(x)))
{
Component lastComponent = (Component) lastInRow.get(new Integer(x));
- GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
-
- if (lastConstraints.gridheight == GridBagConstraints.RELATIVE)
+ if (lastComponent != null)
{
- constraints.gridy = max_y - 1;
- break;
- }
- else
- {
- constraints.gridy = Math.max (constraints.gridy,
- lastConstraints.gridy + Math.max (1, lastConstraints.gridheight));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+
+ if (lastConstraints.gridheight == GridBagConstraints.RELATIVE)
+ {
+ constraints.gridy = max_y - 1;
+ break;
+ }
+ else
+ {
+ constraints.gridy = Math.max (constraints.gridy,
+ lastConstraints.gridy + Math.max (1, lastConstraints.gridheight));
+ }
}
}
}
diff --git a/java/awt/Image.java b/java/awt/Image.java
index b657ad007..642131eba 100644
--- a/java/awt/Image.java
+++ b/java/awt/Image.java
@@ -141,7 +141,6 @@ public abstract class Image
* This method is only valid for off-screen objects.
*
* @return a graphics context object for an off-screen object
- * @see Graphics#getcreateImage(int, int)
*/
public abstract Graphics getGraphics();
diff --git a/java/awt/KeyboardFocusManager.java b/java/awt/KeyboardFocusManager.java
index a61a9a810..8a945767d 100644
--- a/java/awt/KeyboardFocusManager.java
+++ b/java/awt/KeyboardFocusManager.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt;
import java.applet.Applet;
+import java.awt.FocusTraversalPolicy;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
@@ -213,7 +214,7 @@ public abstract class KeyboardFocusManager
currentFocusOwners */
private static Map currentFocusCycleRoots = new HashMap ();
- /** The default {@link FocusTraveralPolicy} that focus-managing
+ /** The default {@link FocusTraversalPolicy} that focus-managing
{@link Container}s will use to define their initial focus
traversal policy. */
private FocusTraversalPolicy defaultPolicy;
@@ -287,7 +288,7 @@ public abstract class KeyboardFocusManager
KeyboardFocusManager manager;
if (m == null)
- manager = createFocusManager();
+ manager = new DefaultKeyboardFocusManager();
else
manager = m;
@@ -295,46 +296,6 @@ public abstract class KeyboardFocusManager
}
/**
- * Creates a KeyboardFocusManager. The exact class is determined by the
- * system property 'gnu.java.awt.FocusManager'. If this is not set,
- * we default to DefaultKeyboardFocusManager.
- */
- private static KeyboardFocusManager createFocusManager()
- {
- String fmClassName = System.getProperty("gnu.java.awt.FocusManager",
- "java.awt.DefaultKeyboardFocusManager");
- try
- {
- Class fmClass = Class.forName(fmClassName);
- KeyboardFocusManager fm = (KeyboardFocusManager) fmClass.newInstance();
- return fm;
- }
- catch (ClassNotFoundException ex)
- {
- System.err.println("The class " + fmClassName + " cannot be found.");
- System.err.println("Check the setting of the system property");
- System.err.println("gnu.java.awt.FocusManager");
- return null;
- }
- catch (InstantiationException ex)
- {
- System.err.println("The class " + fmClassName + " cannot be");
- System.err.println("instantiated.");
- System.err.println("Check the setting of the system property");
- System.err.println("gnu.java.awt.FocusManager");
- return null;
- }
- catch (IllegalAccessException ex)
- {
- System.err.println("The class " + fmClassName + " cannot be");
- System.err.println("accessed.");
- System.err.println("Check the setting of the system property");
- System.err.println("gnu.java.awt.FocusManager");
- return null;
- }
- }
-
- /**
* Retrieve the {@link Component} that has the keyboard focus, or
* null if the focus owner was not set by a thread in the current
* {@link java.lang.ThreadGroup}.
@@ -1366,11 +1327,11 @@ public abstract class KeyboardFocusManager
*
* @return a global object set by the current ThreadGroup, or null
*
- * @see getFocusOwner
- * @see getPermanentFocusOwner
- * @see getFocusedWindow
- * @see getActiveWindow
- * @see getCurrentFocusCycleRoot
+ * @see #getFocusOwner()
+ * @see #getPermanentFocusOwner()
+ * @see #getFocusedWindow()
+ * @see #getActiveWindow()
+ * @see #getCurrentFocusCycleRoot()
*/
private Object getObject (Map globalMap)
{
@@ -1390,11 +1351,11 @@ public abstract class KeyboardFocusManager
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*
- * @see getGlobalFocusOwner
- * @see getGlobalPermanentFocusOwner
- * @see getGlobalFocusedWindow
- * @see getGlobalActiveWindow
- * @see getGlobalCurrentFocusCycleRoot
+ * @see #getGlobalFocusOwner()
+ * @see #getGlobalPermanentFocusOwner()
+ * @see #getGlobalFocusedWindow()
+ * @see #getGlobalActiveWindow()
+ * @see #getGlobalCurrentFocusCycleRoot()
*/
private Object getGlobalObject (Map globalMap)
{
@@ -1434,11 +1395,11 @@ public abstract class KeyboardFocusManager
* @param newObject the object to set
* @param property the property that will change
*
- * @see setGlobalFocusOwner
- * @see setGlobalPermanentFocusOwner
- * @see setGlobalFocusedWindow
- * @see setGlobalActiveWindow
- * @see setGlobalCurrentFocusCycleRoot
+ * @see #setGlobalFocusOwner(Component)
+ * @see #setGlobalPermanentFocusOwner(Component)
+ * @see #setGlobalFocusedWindow(Window)
+ * @see #setGlobalActiveWindow(Window)
+ * @see #setGlobalCurrentFocusCycleRoot(Container)
*/
private void setGlobalObject (Map globalMap,
Object newObject,
diff --git a/java/awt/MenuComponent.java b/java/awt/MenuComponent.java
index ec6980e10..375d08436 100644
--- a/java/awt/MenuComponent.java
+++ b/java/awt/MenuComponent.java
@@ -1157,7 +1157,7 @@ protected abstract class AccessibleAWTMenuComponent
* the appropriate information.
*
* @param color the new color to use for the background.
- * @see getBackground()
+ * @see #getBackground()
*/
public void setBackground(Color color)
{
@@ -1217,7 +1217,7 @@ protected abstract class AccessibleAWTMenuComponent
*
* @param enabled true if the component should be enabled,
* false otherwise.
- * @see #getEnabled()
+ * @see #isEnabled()
*/
public void setEnabled(boolean enabled)
{
diff --git a/java/awt/Polygon.java b/java/awt/Polygon.java
index a72522cb0..403c336cd 100644
--- a/java/awt/Polygon.java
+++ b/java/awt/Polygon.java
@@ -544,7 +544,6 @@ public class Polygon implements Shape, Serializable
* the positive X, or Y axis, within a given interval.
*
* @return the winding number.
- * @see #condensed
* @see #contains(double, double)
*/
private int evaluateCrossings(double x, double y, boolean useYaxis,
diff --git a/java/awt/ScrollPaneAdjustable.java b/java/awt/ScrollPaneAdjustable.java
index cfca19b44..bec5b5106 100644
--- a/java/awt/ScrollPaneAdjustable.java
+++ b/java/awt/ScrollPaneAdjustable.java
@@ -87,12 +87,16 @@ public class ScrollPaneAdjustable
public void addAdjustmentListener (AdjustmentListener listener)
{
- AWTEventMulticaster.add (adjustmentListener, listener);
+ if (listener == null)
+ return;
+ adjustmentListener = AWTEventMulticaster.add (adjustmentListener, listener);
}
public void removeAdjustmentListener (AdjustmentListener listener)
{
- AWTEventMulticaster.remove (adjustmentListener, listener);
+ if (listener == null)
+ return;
+ adjustmentListener = AWTEventMulticaster.remove (adjustmentListener, listener);
}
public AdjustmentListener[] getAdjustmentListeners ()
diff --git a/java/awt/Window.java b/java/awt/Window.java
index d1e8fceef..ccc609596 100644
--- a/java/awt/Window.java
+++ b/java/awt/Window.java
@@ -289,7 +289,7 @@ public class Window extends Container implements Accessible
// Show visible owned windows.
synchronized (getTreeLock())
- {
+ {
Iterator e = ownedWindows.iterator();
while(e.hasNext())
{
@@ -306,14 +306,13 @@ public class Window extends Container implements Accessible
// synchronous access to ownedWindows there.
e.remove();
}
- }
validate();
super.show();
toFront();
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.setGlobalFocusedWindow (this);
-
+
if (!shown)
{
FocusTraversalPolicy policy = getFocusTraversalPolicy ();
@@ -327,6 +326,7 @@ public class Window extends Container implements Accessible
shown = true;
}
+ }
}
/**
@@ -939,8 +939,8 @@ public class Window extends Container implements Accessible
*
* @since 1.4
*/
- public void createBufferStrategy(int numBuffers,
- BufferCapabilities caps)
+ public void createBufferStrategy(int numBuffers, BufferCapabilities caps)
+ throws AWTException
{
if (numBuffers < 1)
throw new IllegalArgumentException("Window.createBufferStrategy: number"
@@ -952,15 +952,7 @@ public class Window extends Container implements Accessible
// a flipping strategy was requested
if (caps.isPageFlipping())
- {
- try
- {
- bufferStrategy = new WindowFlipBufferStrategy(numBuffers);
- }
- catch (AWTException e)
- {
- }
- }
+ bufferStrategy = new WindowFlipBufferStrategy(numBuffers);
else
bufferStrategy = new WindowBltBufferStrategy(numBuffers, true);
}
diff --git a/java/awt/color/ICC_Profile.java b/java/awt/color/ICC_Profile.java
index 75f55a1da..1072cd694 100644
--- a/java/awt/color/ICC_Profile.java
+++ b/java/awt/color/ICC_Profile.java
@@ -324,11 +324,11 @@ public class ICC_Profile implements Serializable
* An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
* may be returned if appropriate.
*
- * @throws IllegalArgumentException if the profile data is an invalid
- * v2 profile.
- *
* @param data - the profile data
* @return An ICC_Profile object
+ *
+ * @throws IllegalArgumentException if the profile data is an invalid
+ * v2 profile.
*/
public static ICC_Profile getInstance(byte[] data)
{
@@ -373,12 +373,12 @@ public class ICC_Profile implements Serializable
* An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
* may be returned if appropriate.
*
+ * @param filename - the file name of the profile file.
+ * @return An ICC_Profile object
+ *
* @throws IllegalArgumentException if the profile data is an invalid
* v2 profile.
* @throws IOException if the file could not be read.
- *
- * @param filename - the file name of the profile file.
- * @return An ICC_Profile object
*/
public static ICC_Profile getInstance(String filename)
throws IOException
@@ -400,12 +400,12 @@ public class ICC_Profile implements Serializable
* An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
* may be returned if appropriate.
*
+ * @param in - the input stream to read the profile from.
+ * @return An ICC_Profile object
+ *
* @throws IllegalArgumentException if the profile data is an invalid
* v2 profile.
* @throws IOException if the stream could not be read.
- *
- * @param in - the input stream to read the profile from.
- * @return An ICC_Profile object
*/
public static ICC_Profile getInstance(InputStream in)
throws IOException
diff --git a/java/awt/event/MouseEvent.java b/java/awt/event/MouseEvent.java
index b13a8c599..3e0fecacf 100644
--- a/java/awt/event/MouseEvent.java
+++ b/java/awt/event/MouseEvent.java
@@ -42,6 +42,7 @@ import gnu.java.awt.EventModifier;
import java.awt.Component;
import java.awt.Point;
+import java.awt.PopupMenu;
import java.io.IOException;
import java.io.ObjectInputStream;
diff --git a/java/awt/geom/Area.java b/java/awt/geom/Area.java
index 7a0fac43a..ad20b535f 100644
--- a/java/awt/geom/Area.java
+++ b/java/awt/geom/Area.java
@@ -1215,7 +1215,7 @@ public class Area implements Shape, Cloneable
* @param t1 - global parametric value of the first curve's starting point
* @param t2 - global parametric value of the second curve's starting point
* @param w1 - global parametric length of curve 1
- * @param c1 - global parametric length of curve 2
+ * @param w2 - global parametric length of curve 2
*
* The final four parameters are for keeping track of the parametric
* value of the curve. For a full curve t = 0, w = 1, w is halved with
diff --git a/java/awt/geom/GeneralPath.java b/java/awt/geom/GeneralPath.java
index f54855874..15fb8aba8 100644
--- a/java/awt/geom/GeneralPath.java
+++ b/java/awt/geom/GeneralPath.java
@@ -558,7 +558,8 @@ public final class GeneralPath implements Shape, Cloneable
* Constructs a new iterator for enumerating the segments of a
* GeneralPath.
*
- * @param at an affine transformation for projecting the returned
+ * @param path the path to enumerate
+ * @param transform an affine transformation for projecting the returned
* points, or <code>null</code> to return the original points
* without any mapping.
*/
diff --git a/java/awt/im/InputContext.java b/java/awt/im/InputContext.java
index 981ffcc5b..c81993215 100644
--- a/java/awt/im/InputContext.java
+++ b/java/awt/im/InputContext.java
@@ -49,6 +49,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
+import java.text.AttributedCharacterIterator.Attribute;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -338,7 +339,7 @@ public class InputContext
/**
* Starts a reconversion operation in the current input method. The input
- * method gets theh text to reconvert from the client component, using
+ * method gets the text to reconvert from the client component, using
* {@link InputMethodRequests#getSelectedText(Attribute[])}. Then the
* composed and committed text produced by the operation is sent back to
* the client using a sequence of InputMethodRequests.
diff --git a/java/awt/im/InputMethodHighlight.java b/java/awt/im/InputMethodHighlight.java
index 0eafe9c5f..a2ee86d44 100644
--- a/java/awt/im/InputMethodHighlight.java
+++ b/java/awt/im/InputMethodHighlight.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package java.awt.im;
+import java.awt.Toolkit;
+import java.text.Annotation;
+import java.text.AttributedCharacterIterator;
import java.util.Map;
import java.awt.font.TextAttribute;
@@ -54,7 +57,7 @@ import java.awt.font.TextAttribute;
* text segments.
*
* @author Eric Blake (ebb9@email.byu.edu)
- * @see AttributedCharacterIterators
+ * @see AttributedCharacterIterator
* @see Annotation
* @since 1.2
* @status updated to 1.4
diff --git a/java/awt/im/InputMethodRequests.java b/java/awt/im/InputMethodRequests.java
index d50ec33c5..0423358cc 100644
--- a/java/awt/im/InputMethodRequests.java
+++ b/java/awt/im/InputMethodRequests.java
@@ -37,8 +37,10 @@ exception statement from your version. */
package java.awt.im;
+import java.awt.Component;
import java.awt.Rectangle;
import java.awt.font.TextHitInfo;
+import java.awt.event.InputMethodListener;
import java.text.AttributedCharacterIterator;
import java.text.AttributedCharacterIterator.Attribute;
diff --git a/java/awt/im/spi/InputMethod.java b/java/awt/im/spi/InputMethod.java
index 840d193a8..ebe450841 100644
--- a/java/awt/im/spi/InputMethod.java
+++ b/java/awt/im/spi/InputMethod.java
@@ -38,7 +38,11 @@ exception statement from your version. */
package java.awt.im.spi;
import java.awt.AWTEvent;
+import java.awt.Component;
import java.awt.Rectangle;
+import java.awt.im.InputContext;
+import java.awt.im.InputMethodRequests;
+import java.text.AttributedCharacterIterator.Attribute;
import java.util.Locale;
/**
@@ -152,8 +156,8 @@ public interface InputMethod
* Notify this input method of changes in the client window. This is called
* when notifications are enabled (see {@link
* InputMethodContext#enableClientWindowNotification(InputMethod, boolean)},
- * if {@link #removeNotify(Component)} has not been called. The following
- * situations trigger a notification:<ul>
+ * if {@link InputContext#removeNotify(Component)} has not been called.
+ * The following situations trigger a notification:<ul>
* <li>The client window changes in location, size, visibility,
* iconification, or is closed.</li>
* <li>When enabling client notification (or on the first activation after
@@ -202,7 +206,7 @@ public interface InputMethod
/**
* Notify the input method that a client component has been removed from its
* hierarchy, or that input method support has been disabled. This is
- * called by {@link InputContext#removeNotify()}, and only when the input
+ * called by {@link InputContext#removeNotify(Component)}, and only when the input
* method is inactive.
*/
void removeNotify();
diff --git a/java/awt/im/spi/InputMethodContext.java b/java/awt/im/spi/InputMethodContext.java
index 243bbc65b..aed21e8d3 100644
--- a/java/awt/im/spi/InputMethodContext.java
+++ b/java/awt/im/spi/InputMethodContext.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.im.spi;
+import java.awt.HeadlessException;
+import java.awt.Rectangle;
import java.awt.Window;
import java.awt.font.TextHitInfo;
import java.awt.im.InputMethodRequests;
@@ -114,7 +116,7 @@ public interface InputMethodContext extends InputMethodRequests
/**
* Sets whether notification of the client window's location and state should
* be enabled for the input method. When enabled, the input method's
- * {@link #notifyClientWindowChange(Rectangle)} method is called.
+ * {@link InputMethod#notifyClientWindowChange(Rectangle)} method is called.
* Notification is automatically disabled when the input method is disposed.
*
* @param inputMethod the method to change status of
diff --git a/java/awt/im/spi/InputMethodDescriptor.java b/java/awt/im/spi/InputMethodDescriptor.java
index 093d73192..d234e5c57 100644
--- a/java/awt/im/spi/InputMethodDescriptor.java
+++ b/java/awt/im/spi/InputMethodDescriptor.java
@@ -39,6 +39,7 @@ package java.awt.im.spi;
import java.awt.AWTException;
import java.awt.Image;
+import java.awt.im.InputContext;
import java.util.Locale;
/**
@@ -57,7 +58,7 @@ public interface InputMethodDescriptor
* also by country and variant), via
* {@link InputContext#selectInputMethod(Locale)}. The returned list should
* ignore pass-through locales, so it is usually a subset of locales for
- * which {@link InputMethod#setContext(Locale)} returns true. If
+ * which {@link InputMethod#setLocale(Locale)} returns true. If
* {@link #hasDynamicLocaleList()} returns true, this is called each time
* information is needed, allowing dynamic addition or removal of supported
* locales.
diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java
index bde57fc37..c730c6dcb 100644
--- a/java/awt/image/BufferedImage.java
+++ b/java/awt/image/BufferedImage.java
@@ -48,9 +48,7 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
-import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.Vector;
/**
diff --git a/java/awt/image/ColorModel.java b/java/awt/image/ColorModel.java
index 1ebcb98a7..1ced2a043 100644
--- a/java/awt/image/ColorModel.java
+++ b/java/awt/image/ColorModel.java
@@ -609,7 +609,7 @@ public abstract class ColorModel implements Transparency
* @param obj Array of TransferType or null.
*
* @return pixel value encoded according to the color model.
- * @throws ArrayIndexOutOfBounds
+ * @throws ArrayIndexOutOfBoundsException
* @throws ClassCastException
* @since 1.4
*/
diff --git a/java/awt/image/ComponentSampleModel.java b/java/awt/image/ComponentSampleModel.java
index 953f63c1e..5cf06e4a1 100644
--- a/java/awt/image/ComponentSampleModel.java
+++ b/java/awt/image/ComponentSampleModel.java
@@ -63,8 +63,11 @@ public class ComponentSampleModel extends SampleModel
protected int[] bandOffsets;
protected int[] bankIndices;
- // FIXME: Should we really shadow the numBands in the superclass?
- //protected int numBands;
+ /**
+ * Number of bands in the image described.
+ * @specnote This field shadows the protected numBands in SampleModel.
+ */
+ protected int numBands;
/** Used when creating data buffers. */
protected int numBanks;
@@ -100,6 +103,7 @@ public class ComponentSampleModel extends SampleModel
this.bandOffsets = bandOffsets;
this.bankIndices = bankIndices;
+ this.numBands = bandOffsets.length;
this.numBanks = 0;
for (int b=0; b<bankIndices.length; b++)
diff --git a/java/awt/image/ImageConsumer.java b/java/awt/image/ImageConsumer.java
index 4a8ff2b14..11f64f978 100644
--- a/java/awt/image/ImageConsumer.java
+++ b/java/awt/image/ImageConsumer.java
@@ -75,7 +75,7 @@ public interface ImageConsumer
* most one call to <code>setPixels</code> for any single pixel.
*
* @see #setHints
- * @see #setPixels
+ * @see #setPixels(int, int, int, int, ColorModel, int[], int, int)
*/
int SINGLEPASS = 8;
diff --git a/java/awt/image/PackedColorModel.java b/java/awt/image/PackedColorModel.java
index 894e6e66f..b60230fa7 100644
--- a/java/awt/image/PackedColorModel.java
+++ b/java/awt/image/PackedColorModel.java
@@ -90,11 +90,7 @@ public abstract class PackedColorModel extends ColorModel
return bitsPerComponent;
}
- /** Initializes the masks.
- *
- * @return an array containing the number of bits per color
- * component.
- */
+ /** Initializes the masks. */
private void initMasks(int[] colorMaskArray, int alphaMask)
{
int numComponents = colorMaskArray.length;
diff --git a/java/awt/image/SampleModel.java b/java/awt/image/SampleModel.java
index 257e30a5b..115966222 100644
--- a/java/awt/image/SampleModel.java
+++ b/java/awt/image/SampleModel.java
@@ -47,7 +47,8 @@ public abstract class SampleModel
/** Height of image described. */
protected int height;
- /** Number of bands in the image described. */
+ /** Number of bands in the image described. Package-private here,
+ shadowed by ComponentSampleModel. */
protected int numBands;
/**
diff --git a/java/awt/print/PrinterJob.java b/java/awt/print/PrinterJob.java
index e61ab61bc..e1aeabc3e 100644
--- a/java/awt/print/PrinterJob.java
+++ b/java/awt/print/PrinterJob.java
@@ -169,8 +169,11 @@ public abstract class PrinterJob
/**
* Prints the page with given attributes.
*/
- public abstract void print (PrintRequestAttributeSet attributes)
- throws PrinterException;
+ public void print (PrintRequestAttributeSet attributes)
+ throws PrinterException
+ {
+ print ();
+ }
/**
* Displays a dialog box to the user which allows the print job
diff --git a/java/beans/IndexedPropertyDescriptor.java b/java/beans/IndexedPropertyDescriptor.java
index aca55b75b..61c3f228d 100644
--- a/java/beans/IndexedPropertyDescriptor.java
+++ b/java/beans/IndexedPropertyDescriptor.java
@@ -1,4 +1,4 @@
-/* java.beans.IndexedPropertyDescriptor
+/* IndexedPropertyDescriptor.java --
Copyright (C) 1998, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,266 +42,380 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method;
/**
- ** IndexedPropertyDescriptor describes information about a JavaBean
- ** indexed property, by which we mean an array-like property that
- ** has been exposed via a pair of get and set methods and another
- ** pair that allows you to get to the property by an index.<P>
- **
- ** An example property would have four methods like this:<P>
- ** <CODE>FooBar[] getFoo()</CODE><BR>
- ** <CODE>void setFoo(FooBar[])</CODE><BR>
- ** <CODE>FooBar getFoo(int)</CODE><BR>
- ** <CODE>void setFoo(int,FooBar)</CODE><P>
- **
- ** The constraints put on get and set methods are:<P>
- ** <OL>
- ** <LI>There must be at least a get(int) or a set(int,...) method.
- ** Nothing else is required. <B>Spec note:</B>One nice restriction
- ** would be that if there is a get() there must be a get(int), same
- ** with set, but that is not in the spec and is fairly harmless.)</LI>
- ** <LI>A get array method must have signature
- ** <CODE>&lt;propertyType&gt;[] &lt;getMethodName&gt;()</CODE></LI>
- ** <LI>A set array method must have signature
- ** <CODE>void &lt;setMethodName&gt;(&lt;propertyType&gt;[])</CODE></LI>
- ** <LI>A get index method must have signature
- ** <CODE>&lt;propertyType&gt; &lt;getMethodName&gt;(int)</CODE></LI>
- ** <LI>A set index method must have signature
- ** <CODE>void &lt;setMethodName&gt;(int,&lt;propertyType&gt;)</CODE></LI>
- ** <LI>All these methods may throw any exception.</LI>
- ** <LI>All these methods must be public.</LI>
- ** </OL>
- **
- ** @author John Keiser
- ** @since JDK1.1
- ** @version 1.1.0, 26 Jul 1998
- **/
+ * IndexedPropertyDescriptor describes information about a JavaBean
+ * indexed property, by which we mean an array-like property that
+ * has been exposed via a pair of get and set methods and another
+ * pair that allows you to get to the property by an index.<P>
+ *
+ * An example property would have four methods like this:<P>
+ * <CODE>FooBar[] getFoo()</CODE><BR>
+ * <CODE>void setFoo(FooBar[])</CODE><BR>
+ * <CODE>FooBar getFoo(int)</CODE><BR>
+ * <CODE>void setFoo(int,FooBar)</CODE><P>
+ *
+ * The constraints put on get and set methods are:<P>
+ * <OL>
+ * <LI>There must be at least a get(int) or a set(int,...) method.
+ * Nothing else is required. <B>Spec note:</B>One nice restriction
+ * would be that if there is a get() there must be a get(int), same
+ * with set, but that is not in the spec and is fairly harmless.)</LI>
+ * <LI>A get array method must have signature
+ * <CODE>&lt;propertyType&gt;[] &lt;getMethodName&gt;()</CODE></LI>
+ * <LI>A set array method must have signature
+ * <CODE>void &lt;setMethodName&gt;(&lt;propertyType&gt;[])</CODE></LI>
+ * <LI>A get index method must have signature
+ * <CODE>&lt;propertyType&gt; &lt;getMethodName&gt;(int)</CODE></LI>
+ * <LI>A set index method must have signature
+ * <CODE>void &lt;setMethodName&gt;(int,&lt;propertyType&gt;)</CODE></LI>
+ * <LI>All these methods may throw any exception.</LI>
+ * <LI>All these methods must be public.</LI>
+ * </OL>
+ *
+ * @author John Keiser
+ * @since JDK1.1
+ */
+public class IndexedPropertyDescriptor extends PropertyDescriptor
+{
+ private Class<?> indexedPropertyType;
+ private Method setIndex;
+ private Method getIndex;
-public class IndexedPropertyDescriptor extends PropertyDescriptor {
- private Class<?> indexedPropertyType;
- private Method setIndex;
- private Method getIndex;
+ /**
+ * Create a new IndexedPropertyDescriptor by introspection.
+ * This form of constructor creates the PropertyDescriptor by
+ * looking for getter methods named <CODE>get&lt;name&gt;()</CODE>
+ * and setter methods named
+ * <CODE>set&lt;name&gt;()</CODE> in class
+ * <CODE>&lt;beanClass&gt;</CODE>, where &lt;name&gt; has its
+ * first letter capitalized by the constructor.<P>
+ *
+ * <B>Implementation note:</B> If there is a get(int) method,
+ * then the return type of that method is used to find the
+ * remaining methods. If there is no get method, then the
+ * set(int) method is searched for exhaustively and that type
+ * is used to find the others.<P>
+ *
+ * <B>Spec note:</B>
+ * If there is no get(int) method and multiple set(int) methods with
+ * the same name and the correct parameters (different type of course),
+ * then an IntrospectionException is thrown. While Sun's spec
+ * does not state this, it can make Bean behavior different on
+ * different systems (since method order is not guaranteed) and as
+ * such, can be treated as a bug in the spec. I am not aware of
+ * whether Sun's implementation catches this.
+ *
+ * @param name the programmatic name of the property, usually
+ * starting with a lowercase letter (e.g. fooManChu
+ * instead of FooManChu).
+ * @param beanClass the class the get and set methods live in.
+ *
+ * @exception IntrospectionException if the methods are not found or
+ * invalid.
+ */
+ public IndexedPropertyDescriptor(String name, Class<?> beanClass)
+ throws IntrospectionException
+ {
+ super(name);
+ String capitalized;
+ try
+ {
+ capitalized = Character.toUpperCase(name.charAt(0))
+ + name.substring(1);
+ }
+ catch(StringIndexOutOfBoundsException e)
+ {
+ capitalized = "";
+ }
+ findMethods(beanClass, "get" + capitalized, "set" + capitalized,
+ "get" + capitalized, "set" + capitalized);
+ }
- /** Create a new IndexedPropertyDescriptor by introspection.
- ** This form of constructor creates the PropertyDescriptor by
- ** looking for getter methods named <CODE>get&lt;name&gt;()</CODE>
- ** and setter methods named
- ** <CODE>set&lt;name&gt;()</CODE> in class
- ** <CODE>&lt;beanClass&gt;</CODE>, where &lt;name&gt; has its
- ** first letter capitalized by the constructor.<P>
- **
- ** <B>Implementation note:</B> If there is a get(int) method,
- ** then the return type of that method is used to find the
- ** remaining methods. If there is no get method, then the
- ** set(int) method is searched for exhaustively and that type
- ** is used to find the others.<P>
- **
- ** <B>Spec note:</B>
- ** If there is no get(int) method and multiple set(int) methods with
- ** the same name and the correct parameters (different type of course),
- ** then an IntrospectionException is thrown. While Sun's spec
- ** does not state this, it can make Bean behavior different on
- ** different systems (since method order is not guaranteed) and as
- ** such, can be treated as a bug in the spec. I am not aware of
- ** whether Sun's implementation catches this.
- **
- ** @param name the programmatic name of the property, usually
- ** starting with a lowercase letter (e.g. fooManChu
- ** instead of FooManChu).
- ** @param beanClass the class the get and set methods live in.
- ** @exception IntrospectionException if the methods are not found or invalid.
- **/
- public IndexedPropertyDescriptor(String name, Class<?> beanClass) throws IntrospectionException {
- super(name);
- String capitalized;
- try {
- capitalized = Character.toUpperCase(name.charAt(0)) + name.substring(1);
- } catch(StringIndexOutOfBoundsException e) {
- capitalized = "";
- }
- findMethods(beanClass, "get" + capitalized, "set" + capitalized, "get" + capitalized, "set" + capitalized);
- }
+ /**
+ * Create a new IndexedPropertyDescriptor by introspection.
+ * This form of constructor allows you to specify the
+ * names of the get and set methods to search for.<P>
+ *
+ * <B>Implementation note:</B> If there is a get(int) method,
+ * then the return type of that method is used to find the
+ * remaining methods. If there is no get method, then the
+ * set(int) method is searched for exhaustively and that type
+ * is used to find the others.<P>
+ *
+ * <B>Spec note:</B>
+ * If there is no get(int) method and multiple set(int) methods with
+ * the same name and the correct parameters (different type of course),
+ * then an IntrospectionException is thrown. While Sun's spec
+ * does not state this, it can make Bean behavior different on
+ * different systems (since method order is not guaranteed) and as
+ * such, can be treated as a bug in the spec. I am not aware of
+ * whether Sun's implementation catches this.
+ *
+ * @param name the programmatic name of the property, usually
+ * starting with a lowercase letter (e.g. fooManChu
+ * instead of FooManChu).
+ * @param beanClass the class the get and set methods live in.
+ * @param getMethodName the name of the get array method.
+ * @param setMethodName the name of the set array method.
+ * @param getIndexName the name of the get index method.
+ * @param setIndexName the name of the set index method.
+ *
+ * @exception IntrospectionException if the methods are not found or invalid.
+ */
+ public IndexedPropertyDescriptor(String name, Class<?> beanClass,
+ String getMethodName, String setMethodName,
+ String getIndexName, String setIndexName)
+ throws IntrospectionException
+ {
+ super(name);
+ findMethods(beanClass, getMethodName, setMethodName, getIndexName,
+ setIndexName);
+ }
- /** Create a new IndexedPropertyDescriptor by introspection.
- ** This form of constructor allows you to specify the
- ** names of the get and set methods to search for.<P>
- **
- ** <B>Implementation note:</B> If there is a get(int) method,
- ** then the return type of that method is used to find the
- ** remaining methods. If there is no get method, then the
- ** set(int) method is searched for exhaustively and that type
- ** is used to find the others.<P>
- **
- ** <B>Spec note:</B>
- ** If there is no get(int) method and multiple set(int) methods with
- ** the same name and the correct parameters (different type of course),
- ** then an IntrospectionException is thrown. While Sun's spec
- ** does not state this, it can make Bean behavior different on
- ** different systems (since method order is not guaranteed) and as
- ** such, can be treated as a bug in the spec. I am not aware of
- ** whether Sun's implementation catches this.
- **
- ** @param name the programmatic name of the property, usually
- ** starting with a lowercase letter (e.g. fooManChu
- ** instead of FooManChu).
- ** @param beanClass the class the get and set methods live in.
- ** @param getMethodName the name of the get array method.
- ** @param setMethodName the name of the set array method.
- ** @param getIndexName the name of the get index method.
- ** @param setIndexName the name of the set index method.
- ** @exception IntrospectionException if the methods are not found or invalid.
- **/
- public IndexedPropertyDescriptor(String name, Class<?> beanClass, String getMethodName, String setMethodName, String getIndexName, String setIndexName) throws IntrospectionException {
- super(name);
- findMethods(beanClass, getMethodName, setMethodName, getIndexName, setIndexName);
- }
+ /**
+ * Create a new PropertyDescriptor using explicit Methods.
+ * Note that the methods will be checked for conformance to standard
+ * Property method rules, as described above at the top of this class.
+ *
+ * @param name the programmatic name of the property, usually
+ * starting with a lowercase letter (e.g. fooManChu
+ * instead of FooManChu).
+ * @param getMethod the get array method.
+ * @param setMethod the set array method.
+ * @param getIndex the get index method.
+ * @param setIndex the set index method.
+ *
+ * @exception IntrospectionException if the methods are not found or invalid.
+ */
+ public IndexedPropertyDescriptor(String name, Method getMethod,
+ Method setMethod, Method getIndex,
+ Method setIndex)
+ throws IntrospectionException
+ {
+ super(name);
+ if(getMethod != null && getMethod.getParameterTypes().length > 0)
+ throw new IntrospectionException("get method has parameters");
+ if(getMethod != null && setMethod.getParameterTypes().length != 1)
+ throw new IntrospectionException("set method does not have exactly one parameter");
+ if(getMethod != null && setMethod != null)
+ {
+ if(!getMethod.getReturnType().equals(setMethod.getParameterTypes()[0]))
+ {
+ throw new IntrospectionException("set and get methods do not "
+ + "share the same type");
+ }
+ if(!getMethod.getDeclaringClass().isAssignableFrom
+ (setMethod.getDeclaringClass())
+ && !setMethod.getDeclaringClass().isAssignableFrom
+ (getMethod.getDeclaringClass()))
+ {
+ throw new IntrospectionException("set and get methods are not in "
+ + "the same class.");
+ }
+ }
- /** Create a new PropertyDescriptor using explicit Methods.
- ** Note that the methods will be checked for conformance to standard
- ** Property method rules, as described above at the top of this class.
- **
- ** @param name the programmatic name of the property, usually
- ** starting with a lowercase letter (e.g. fooManChu
- ** instead of FooManChu).
- ** @param getMethod the get array method.
- ** @param setMethod the set array method.
- ** @param getIndex the get index method.
- ** @param setIndex the set index method.
- ** @exception IntrospectionException if the methods are not found or invalid.
- **/
- public IndexedPropertyDescriptor(String name, Method getMethod, Method setMethod, Method getIndex, Method setIndex) throws IntrospectionException {
- super(name);
- if(getMethod != null && getMethod.getParameterTypes().length > 0) {
- throw new IntrospectionException("get method has parameters");
- }
- if(getMethod != null && setMethod.getParameterTypes().length != 1) {
- throw new IntrospectionException("set method does not have exactly one parameter");
- }
- if(getMethod != null && setMethod != null) {
- if(!getMethod.getReturnType().equals(setMethod.getParameterTypes()[0])) {
- throw new IntrospectionException("set and get methods do not share the same type");
- }
- if(!getMethod.getDeclaringClass().isAssignableFrom(setMethod.getDeclaringClass())
- && !setMethod.getDeclaringClass().isAssignableFrom(getMethod.getDeclaringClass())) {
- throw new IntrospectionException("set and get methods are not in the same class.");
- }
- }
+ if (getIndex != null
+ && (getIndex.getParameterTypes().length != 1
+ || !(getIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)))
+ {
+ throw new IntrospectionException("get index method has wrong "
+ + "parameters");
+ }
+ if (setIndex != null
+ && (setIndex.getParameterTypes().length != 2
+ || !(setIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)))
+ {
+ throw new IntrospectionException("set index method has wrong "
+ + "parameters");
+ }
+ if (getIndex != null && setIndex != null)
+ {
+ if(!getIndex.getReturnType().equals(setIndex.getParameterTypes()[1]))
+ {
+ throw new IntrospectionException("set index methods do not share "
+ + "the same type");
+ }
+ if(!getIndex.getDeclaringClass().isAssignableFrom
+ (setIndex.getDeclaringClass())
+ && !setIndex.getDeclaringClass().isAssignableFrom
+ (getIndex.getDeclaringClass()))
+ {
+ throw new IntrospectionException("get and set index methods are "
+ + "not in the same class.");
+ }
+ }
- if(getIndex != null && (getIndex.getParameterTypes().length != 1
- || !(getIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE))) {
- throw new IntrospectionException("get index method has wrong parameters");
- }
- if(setIndex != null && (setIndex.getParameterTypes().length != 2
- || !(setIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE))) {
- throw new IntrospectionException("set index method has wrong parameters");
- }
- if(getIndex != null && setIndex != null) {
- if(!getIndex.getReturnType().equals(setIndex.getParameterTypes()[1])) {
- throw new IntrospectionException("set index methods do not share the same type");
- }
- if(!getIndex.getDeclaringClass().isAssignableFrom(setIndex.getDeclaringClass())
- && !setIndex.getDeclaringClass().isAssignableFrom(getIndex.getDeclaringClass())) {
- throw new IntrospectionException("get and set index methods are not in the same class.");
- }
- }
+ if (getIndex != null && getMethod != null
+ && !getIndex.getDeclaringClass().isAssignableFrom
+ (getMethod.getDeclaringClass())
+ && !getMethod.getDeclaringClass().isAssignableFrom
+ (getIndex.getDeclaringClass()))
+ {
+ throw new IntrospectionException("methods are not in the same class.");
+ }
- if(getIndex != null && getMethod != null && !getIndex.getDeclaringClass().isAssignableFrom(getMethod.getDeclaringClass())
- && !getMethod.getDeclaringClass().isAssignableFrom(getIndex.getDeclaringClass())) {
- throw new IntrospectionException("methods are not in the same class.");
- }
+ if (getIndex != null && getMethod != null
+ && !Array.newInstance(getIndex.getReturnType(),0)
+ .getClass().equals(getMethod.getReturnType()))
+ {
+ throw new IntrospectionException("array methods do not match index "
+ + "methods.");
+ }
- if(getIndex != null && getMethod != null && !Array.newInstance(getIndex.getReturnType(),0).getClass().equals(getMethod.getReturnType())) {
- throw new IntrospectionException("array methods do not match index methods.");
- }
+ this.getMethod = getMethod;
+ this.setMethod = setMethod;
+ this.getIndex = getIndex;
+ this.setIndex = setIndex;
+ this.indexedPropertyType = getIndex != null ? getIndex.getReturnType()
+ : setIndex.getParameterTypes()[1];
+ this.propertyType = getMethod != null ? getMethod.getReturnType()
+ : (setMethod != null ? setMethod.getParameterTypes()[0]
+ : Array.newInstance(this.indexedPropertyType,0).getClass());
+ }
- this.getMethod = getMethod;
- this.setMethod = setMethod;
- this.getIndex = getIndex;
- this.setIndex = setIndex;
- this.indexedPropertyType = getIndex != null ? getIndex.getReturnType() : setIndex.getParameterTypes()[1];
- this.propertyType = getMethod != null ? getMethod.getReturnType() : (setMethod != null ? setMethod.getParameterTypes()[0] : Array.newInstance(this.indexedPropertyType,0).getClass());
- }
+ public Class<?> getIndexedPropertyType()
+ {
+ return indexedPropertyType;
+ }
- public Class<?> getIndexedPropertyType() {
- return indexedPropertyType;
- }
+ public Method getIndexedReadMethod()
+ {
+ return getIndex;
+ }
- public Method getIndexedReadMethod() {
- return getIndex;
- }
+ /**
+ * Sets the method that is used to read an indexed property.
+ *
+ * @param m the method to set
+ */
+ public void setIndexedReadMethod(Method m) throws IntrospectionException
+ {
+ getIndex = m;
+ }
- public Method getIndexedWriteMethod() {
- return setIndex;
- }
+ public Method getIndexedWriteMethod()
+ {
+ return setIndex;
+ }
- private void findMethods(Class beanClass, String getMethodName, String setMethodName, String getIndexName, String setIndexName) throws IntrospectionException {
- try {
- if(getIndexName != null) {
- try {
- Class[] getArgs = new Class[1];
- getArgs[0] = java.lang.Integer.TYPE;
- getIndex = beanClass.getMethod(getIndexName,getArgs);
- indexedPropertyType = getIndex.getReturnType();
- } catch(NoSuchMethodException E) {
- }
- }
- if(getIndex != null) {
- if(setIndexName != null) {
- try {
- Class[] setArgs = new Class[2];
- setArgs[0] = java.lang.Integer.TYPE;
- setArgs[1] = indexedPropertyType;
- setIndex = beanClass.getMethod(setIndexName,setArgs);
- if(!setIndex.getReturnType().equals(java.lang.Void.TYPE)) {
- throw new IntrospectionException(setIndexName + " has non-void return type");
- }
- } catch(NoSuchMethodException E) {
- }
- }
- } else if(setIndexName != null) {
- Method[] m = beanClass.getMethods();
- for(int i=0;i<m.length;i++) {
- Method current = m[i];
- if(current.getName().equals(setIndexName)
- && current.getParameterTypes().length == 2
- && (current.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)
- && current.getReturnType().equals(java.lang.Void.TYPE)) {
- if(setIndex != null) {
- throw new IntrospectionException("Multiple, different set methods found that fit the bill!");
- } else {
- setIndex = current;
- indexedPropertyType = current.getParameterTypes()[1];
- }
- }
- }
- if(setIndex == null) {
- throw new IntrospectionException("Cannot find get or set methods.");
- }
- } else {
- throw new IntrospectionException("Cannot find get or set methods.");
- }
+ /**
+ * Sets the method that is used to write an indexed property.
+ *
+ * @param m the method to set
+ */
+ public void setIndexedWriteMethod(Method m) throws IntrospectionException
+ {
+ setIndex = m;
+ }
- Class arrayType = Array.newInstance(indexedPropertyType,0).getClass();
+ private void findMethods(Class beanClass, String getMethodName,
+ String setMethodName, String getIndexName,
+ String setIndexName)
+ throws IntrospectionException
+ {
+ try
+ {
+ if(getIndexName != null)
+ {
+ try
+ {
+ Class[] getArgs = new Class[1];
+ getArgs[0] = java.lang.Integer.TYPE;
+ getIndex = beanClass.getMethod(getIndexName,getArgs);
+ indexedPropertyType = getIndex.getReturnType();
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+ }
+ if(getIndex != null)
+ {
+ if(setIndexName != null)
+ {
+ try
+ {
+ Class[] setArgs = new Class[2];
+ setArgs[0] = java.lang.Integer.TYPE;
+ setArgs[1] = indexedPropertyType;
+ setIndex = beanClass.getMethod(setIndexName,setArgs);
+ if(!setIndex.getReturnType().equals(java.lang.Void.TYPE))
+ {
+ throw new IntrospectionException(setIndexName
+ + " has non-void return type");
+ }
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+ }
+ }
+ else if(setIndexName != null)
+ {
+ Method[] m = beanClass.getMethods();
+ for(int i=0;i<m.length;i++)
+ {
+ Method current = m[i];
+ if(current.getName().equals(setIndexName)
+ && current.getParameterTypes().length == 2
+ && (current.getParameterTypes()[0])
+ .equals(java.lang.Integer.TYPE)
+ && current.getReturnType().equals(java.lang.Void.TYPE))
+ {
+ if(setIndex != null)
+ {
+ throw new IntrospectionException("Multiple, different "
+ + "set methods found that fit the bill!");
+ }
+ else
+ {
+ setIndex = current;
+ indexedPropertyType = current.getParameterTypes()[1];
+ }
+ }
+ }
+ if(setIndex == null)
+ {
+ throw new IntrospectionException("Cannot find get or set "
+ + "methods.");
+ }
+ }
+ else
+ {
+ throw new IntrospectionException("Cannot find get or set methods.");
+ }
- Class[] setArgs = new Class[1];
- setArgs[0] = arrayType;
- try {
- setMethod = beanClass.getMethod(setMethodName,setArgs);
- if(!setMethod.getReturnType().equals(java.lang.Void.TYPE)) {
- setMethod = null;
- }
- } catch(NoSuchMethodException E) {
- }
+ Class arrayType = Array.newInstance(indexedPropertyType,0).getClass();
- Class[] getArgs = new Class[0];
- try {
- getMethod = beanClass.getMethod(getMethodName,getArgs);
- if(!getMethod.getReturnType().equals(arrayType)) {
- getMethod = null;
- }
- } catch(NoSuchMethodException E) {
- }
- } catch(SecurityException E) {
- throw new IntrospectionException("SecurityException while trying to find methods.");
- }
- }
+ Class[] setArgs = new Class[1];
+ setArgs[0] = arrayType;
+ try
+ {
+ setMethod = beanClass.getMethod(setMethodName,setArgs);
+ if (!setMethod.getReturnType().equals(java.lang.Void.TYPE))
+ {
+ setMethod = null;
+ }
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+
+ Class[] getArgs = new Class[0];
+ try
+ {
+ getMethod = beanClass.getMethod(getMethodName,getArgs);
+ if (!getMethod.getReturnType().equals(arrayType))
+ {
+ getMethod = null;
+ }
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+ }
+ catch(SecurityException E)
+ {
+ throw new IntrospectionException("SecurityException while trying to "
+ + "find methods.");
+ }
+ }
}
diff --git a/java/beans/PropertyDescriptor.java b/java/beans/PropertyDescriptor.java
index f4166daec..a29775c64 100644
--- a/java/beans/PropertyDescriptor.java
+++ b/java/beans/PropertyDescriptor.java
@@ -61,7 +61,6 @@ import java.lang.reflect.Method;
** @since 1.1
** @status updated to 1.4
**/
-
public class PropertyDescriptor extends FeatureDescriptor
{
Class<?> propertyType;
@@ -521,6 +520,22 @@ public class PropertyDescriptor extends FeatureDescriptor
return newPropertyType;
}
+ /**
+ * Return a hash code for this object, conforming to the contract described
+ * in {@link Object#hashCode()}.
+ * @return the hash code
+ * @since 1.5
+ */
+ public int hashCode()
+ {
+ return ((propertyType == null ? 0 : propertyType.hashCode())
+ | (propertyEditorClass == null ? 0 : propertyEditorClass.hashCode())
+ | (bound ? Boolean.TRUE : Boolean.FALSE).hashCode()
+ | (constrained ? Boolean.TRUE : Boolean.FALSE).hashCode()
+ | (getMethod == null ? 0 : getMethod.hashCode())
+ | (setMethod == null ? 0 : setMethod.hashCode()));
+ }
+
/** Compares this <code>PropertyDescriptor</code> against the
* given object.
* Two PropertyDescriptors are equals if
diff --git a/java/beans/beancontext/BeanContextServicesSupport.java b/java/beans/beancontext/BeanContextServicesSupport.java
index b7c4a49d8..5455adbae 100644
--- a/java/beans/beancontext/BeanContextServicesSupport.java
+++ b/java/beans/beancontext/BeanContextServicesSupport.java
@@ -61,7 +61,7 @@ public class BeanContextServicesSupport
protected class BCSSChild
extends BeanContextSupport.BCSChild
{
- private static final long serialVersionUID = -6848044915271367103L;
+ private static final long serialVersionUID = -3263851306889194873L;
}
protected class BCSSProxyServiceProvider
diff --git a/java/beans/beancontext/BeanContextSupport.java b/java/beans/beancontext/BeanContextSupport.java
index 7e024e23a..60ccc3af3 100644
--- a/java/beans/beancontext/BeanContextSupport.java
+++ b/java/beans/beancontext/BeanContextSupport.java
@@ -79,7 +79,7 @@ public class BeanContextSupport extends BeanContextChildSupport
protected class BCSChild implements Serializable
{
- private static final long serialVersionUID = 3289144128843950629L;
+ private static final long serialVersionUID = -5815286101609939109L;
}
protected static final class BCSIterator implements Iterator
diff --git a/java/io/File.java b/java/io/File.java
index 9a27b74a9..dc06bcf09 100644
--- a/java/io/File.java
+++ b/java/io/File.java
@@ -100,6 +100,17 @@ public class File implements Serializable, Comparable<File>
* may be an absolute or relative path name.
*/
private String path;
+
+
+ /**
+ * The time (millisecond), when the last temporary file was created.
+ */
+ private static long last_tmp;
+
+ /**
+ * The number of files, created during the current millisecond.
+ */
+ private static int n_created;
/**
* This method tests whether or not the current thread is allowed to
@@ -1059,7 +1070,7 @@ public class File implements Serializable, Comparable<File>
*
* @since 1.2
*/
- public static File createTempFile(String prefix, String suffix,
+ public static synchronized File createTempFile(String prefix, String suffix,
File directory)
throws IOException
{
@@ -1091,10 +1102,23 @@ public class File implements Serializable, Comparable<File>
// Now identify a file name and make sure it doesn't exist.
File file;
if (!VMFile.IS_DOS_8_3)
- {
+ {
do
{
- String filename = prefix + System.currentTimeMillis() + suffix;
+ long now = System.currentTimeMillis();
+ if (now > last_tmp)
+ {
+ // The last temporary file was created more than 1 ms ago.
+ last_tmp = now;
+ n_created = 0;
+ }
+ else
+ n_created++;
+
+ String name = Long.toHexString(now);
+ if (n_created > 0)
+ name += '_'+Integer.toHexString(n_created);
+ String filename = prefix + name + suffix;
file = new File(directory, filename);
}
while (VMFile.exists(file.path));
diff --git a/java/io/FileWriter.java b/java/io/FileWriter.java
index b34db8323..ce18efe5e 100644
--- a/java/io/FileWriter.java
+++ b/java/io/FileWriter.java
@@ -119,7 +119,7 @@ public class FileWriter extends OutputStreamWriter
* This method intializes a new <code>FileWriter</code> object to
* write to the
* specified named file. This form of the constructor allows the caller
- * to determin whether data should be written starting at the beginning or
+ * to determine whether data should be written starting at the beginning or
* the end of the file.
*
* @param name The name of the file to write to
diff --git a/java/io/ObjectInputStream.java b/java/io/ObjectInputStream.java
index 9ab9c7cc6..80e74f482 100644
--- a/java/io/ObjectInputStream.java
+++ b/java/io/ObjectInputStream.java
@@ -52,6 +52,8 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.TreeSet;
import java.util.Vector;
/**
@@ -97,7 +99,6 @@ public class ObjectInputStream extends InputStream
}
this.resolveEnabled = false;
- this.isDeserializing = false;
this.blockDataPosition = 0;
this.blockDataBytes = 0;
this.blockData = new byte[BUFFER_SIZE];
@@ -105,7 +106,6 @@ public class ObjectInputStream extends InputStream
this.realInputStream = new DataInputStream(in);
this.nextOID = baseWireHandle;
this.objectLookupTable = new Hashtable<Integer,ObjectIdentityWrapper>();
- this.validators = new Vector<ValidatorAndPriority>();
this.classLookupTable = new Hashtable<Class,ObjectStreamClass>();
setBlockDataMode(true);
readStreamHeader();
@@ -133,42 +133,28 @@ public class ObjectInputStream extends InputStream
if (this.useSubclassMethod)
return readObjectOverride();
- boolean was_deserializing;
-
Object ret_val;
- was_deserializing = this.isDeserializing;
-
boolean old_mode = setBlockDataMode(false);
-
- this.isDeserializing = true;
-
byte marker = this.realInputStream.readByte();
- depth += 2;
+ if (DEBUG)
+ depth += 2;
if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " ");
try
{
ret_val = parseContent(marker);
- }
- finally
- {
+ }
+ finally
+ {
setBlockDataMode(old_mode);
-
- this.isDeserializing = was_deserializing;
-
- depth -= 2;
-
- if (! was_deserializing)
- {
- if (validators.size() > 0)
- invokeValidators();
- }
- }
-
- return ret_val;
- }
+ if (DEBUG)
+ depth -= 2;
+ }
+
+ return ret_val;
+ }
/**
* Handles a content block within the stream, which begins with a marker
@@ -242,7 +228,6 @@ public class ObjectInputStream extends InputStream
for (int i = 0; i < n_intf; i++)
{
intfs[i] = this.realInputStream.readUTF();
- System.out.println(intfs[i]);
}
boolean oldmode = setBlockDataMode(true);
@@ -250,6 +235,21 @@ public class ObjectInputStream extends InputStream
setBlockDataMode(oldmode);
ObjectStreamClass osc = lookupClass(cl);
+ if (osc.firstNonSerializableParentConstructor == null)
+ {
+ osc.realClassIsSerializable = true;
+ osc.fields = osc.fieldMapping = new ObjectStreamField[0];
+ try
+ {
+ osc.firstNonSerializableParentConstructor =
+ Object.class.getConstructor(new Class[0]);
+ }
+ catch (NoSuchMethodException x)
+ {
+ throw (InternalError)
+ new InternalError("Object ctor missing").initCause(x);
+ }
+ }
assignNewHandle(osc);
if (!is_consumed)
@@ -354,8 +354,11 @@ public class ObjectInputStream extends InputStream
int handle = assignNewHandle(obj);
Object prevObject = this.currentObject;
ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass;
+ TreeSet<ValidatorAndPriority> prevObjectValidators =
+ this.currentObjectValidators;
this.currentObject = obj;
+ this.currentObjectValidators = null;
ObjectStreamClass[] hierarchy =
inputGetObjectStreamClasses(clazz);
@@ -407,7 +410,10 @@ public class ObjectInputStream extends InputStream
this.currentObject = prevObject;
this.currentObjectStreamClass = prevObjectStreamClass;
ret_val = processResolution(osc, obj, handle);
-
+ if (currentObjectValidators != null)
+ invokeValidators();
+ this.currentObjectValidators = prevObjectValidators;
+
break;
}
@@ -739,8 +745,10 @@ public class ObjectInputStream extends InputStream
throw new InvalidObjectException("attempt to add a null "
+ "ObjectInputValidation object");
- this.validators.addElement(new ValidatorAndPriority (validator,
- priority));
+ if (currentObjectValidators == null)
+ currentObjectValidators = new TreeSet<ValidatorAndPriority>();
+
+ currentObjectValidators.add(new ValidatorAndPriority(validator, priority));
}
@@ -1844,18 +1852,19 @@ public class ObjectInputStream extends InputStream
// on OBJ
private void invokeValidators() throws InvalidObjectException
{
- Object[] validators = new Object[this.validators.size()];
- this.validators.copyInto (validators);
- Arrays.sort (validators);
-
try
{
- for (int i=0; i < validators.length; i++)
- ((ObjectInputValidation)validators[i]).validateObject();
+ Iterator<ValidatorAndPriority> it = currentObjectValidators.iterator();
+ while(it.hasNext())
+ {
+ ValidatorAndPriority vap = it.next();
+ ObjectInputValidation validator = vap.validator;
+ validator.validateObject();
+ }
}
finally
{
- this.validators.removeAllElements();
+ currentObjectValidators = null;
}
}
@@ -1904,10 +1913,9 @@ public class ObjectInputStream extends InputStream
private Hashtable<Integer,ObjectIdentityWrapper> objectLookupTable;
private Object currentObject;
private ObjectStreamClass currentObjectStreamClass;
+ private TreeSet<ValidatorAndPriority> currentObjectValidators;
private boolean readDataFromBlock;
- private boolean isDeserializing;
private boolean fieldsAlreadyRead;
- private Vector<ValidatorAndPriority> validators;
private Hashtable<Class,ObjectStreamClass> classLookupTable;
private GetField prereadFields;
diff --git a/java/io/ObjectOutputStream.java b/java/io/ObjectOutputStream.java
index 68ddf36cf..2a63d4980 100644
--- a/java/io/ObjectOutputStream.java
+++ b/java/io/ObjectOutputStream.java
@@ -367,7 +367,9 @@ public class ObjectOutputStream extends OutputStream
break;
}
- throw new NotSerializableException(clazz.getName ());
+ throw new NotSerializableException(clazz.getName()
+ + " in "
+ + obj.getClass());
} // end pseudo-loop
}
catch (ObjectStreamException ose)
@@ -552,7 +554,7 @@ public class ObjectOutputStream extends OutputStream
* version)</code> is provided to change the default protocol
* version.
*
- * For an explination of the differences beween the two protocols
+ * For an explanation of the differences between the two protocols
* see XXX: the Java ObjectSerialization Specification.
*
* @exception IOException if <code>version</code> is not a valid
diff --git a/java/io/OutputStreamWriter.java b/java/io/OutputStreamWriter.java
index a0ac3ff97..29fb631fa 100644
--- a/java/io/OutputStreamWriter.java
+++ b/java/io/OutputStreamWriter.java
@@ -122,52 +122,58 @@ public class OutputStreamWriter extends Writer
{
this.out = out;
try
- {
- // Don't use NIO if avoidable
- if(EncodingHelper.isISOLatin1(encoding_scheme))
{
- encodingName = "ISO8859_1";
- encoder = null;
- return;
- }
-
- /*
- * Workraround for encodings with a byte-order-mark.
- * We only want to write it once per stream.
- */
- try {
- if(encoding_scheme.equalsIgnoreCase("UnicodeBig") ||
- encoding_scheme.equalsIgnoreCase("UTF-16") ||
- encoding_scheme.equalsIgnoreCase("UTF16"))
- {
- encoding_scheme = "UTF-16BE";
- out.write((byte)0xFE);
- out.write((byte)0xFF);
- } else if(encoding_scheme.equalsIgnoreCase("UnicodeLittle")){
- encoding_scheme = "UTF-16LE";
- out.write((byte)0xFF);
- out.write((byte)0xFE);
- }
- } catch(IOException ioe){
- }
+ // Don't use NIO if avoidable
+ if(EncodingHelper.isISOLatin1(encoding_scheme))
+ {
+ encodingName = "ISO8859_1";
+ encoder = null;
+ return;
+ }
- outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
+ /*
+ * Workraround for encodings with a byte-order-mark.
+ * We only want to write it once per stream.
+ */
+ try
+ {
+ if(encoding_scheme.equalsIgnoreCase("UnicodeBig") ||
+ encoding_scheme.equalsIgnoreCase("UTF-16") ||
+ encoding_scheme.equalsIgnoreCase("UTF16"))
+ {
+ encoding_scheme = "UTF-16BE";
+ out.write((byte)0xFE);
+ out.write((byte)0xFF);
+ }
+ else if(encoding_scheme.equalsIgnoreCase("UnicodeLittle")){
+ encoding_scheme = "UTF-16LE";
+ out.write((byte)0xFF);
+ out.write((byte)0xFE);
+ }
+ }
+ catch(IOException ioe)
+ {
+ }
+
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
- Charset cs = EncodingHelper.getCharset(encoding_scheme);
- if(cs == null)
- throw new UnsupportedEncodingException("Encoding "+encoding_scheme+
- " unknown");
- encoder = cs.newEncoder();
- encodingName = EncodingHelper.getOldCanonical(cs.name());
+ Charset cs = EncodingHelper.getCharset(encoding_scheme);
+ if(cs == null)
+ throw new UnsupportedEncodingException("Encoding "+encoding_scheme+
+ " unknown");
+ encoder = cs.newEncoder();
+ encodingName = EncodingHelper.getOldCanonical(cs.name());
- encoder.onMalformedInput(CodingErrorAction.REPLACE);
- encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- } catch(RuntimeException e) {
- // Default to ISO Latin-1, will happen if this is called, for instance,
- // before the NIO provider is loadable.
- encoder = null;
- encodingName = "ISO8859_1";
- }
+ encoder.onMalformedInput(CodingErrorAction.REPLACE);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ }
+ catch(RuntimeException e)
+ {
+ // Default to ISO Latin-1, will happen if this is called, for instance,
+ // before the NIO provider is loadable.
+ encoder = null;
+ encodingName = "ISO8859_1";
+ }
}
/**
@@ -181,21 +187,55 @@ public class OutputStreamWriter extends Writer
this.out = out;
outputBuffer = null;
try
- {
- String encoding = System.getProperty("file.encoding");
- Charset cs = Charset.forName(encoding);
- encoder = cs.newEncoder();
- encodingName = EncodingHelper.getOldCanonical(cs.name());
- } catch(RuntimeException e) {
- encoder = null;
- encodingName = "ISO8859_1";
- }
+ {
+ String encoding = System.getProperty("file.encoding");
+ Charset cs = Charset.forName(encoding);
+ encoder = cs.newEncoder();
+ encodingName = EncodingHelper.getOldCanonical(cs.name());
+ }
+ catch(RuntimeException e)
+ {
+ encoder = null;
+ encodingName = "ISO8859_1";
+ }
+
if(encoder != null)
- {
- encoder.onMalformedInput(CodingErrorAction.REPLACE);
- encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
- }
+ {
+ encoder.onMalformedInput(CodingErrorAction.REPLACE);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
+ }
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using a given <code>Charset</code>.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ * @param cs The <code>Charset</code> of the encoding to use
+ */
+ public OutputStreamWriter(OutputStream out, Charset cs)
+ {
+ this.out = out;
+ encoder = cs.newEncoder();
+ encoder.onMalformedInput(CodingErrorAction.REPLACE);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using a given
+ * <code>CharsetEncoder</code>.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ * @param enc The <code>CharsetEncoder</code> to encode the output with
+ */
+ public OutputStreamWriter(OutputStream out, CharsetEncoder enc)
+ {
+ this.out = out;
+ encoder = enc;
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
}
/**
diff --git a/java/lang/Class.java b/java/lang/Class.java
index 23226e6c0..82d47819b 100644
--- a/java/lang/Class.java
+++ b/java/lang/Class.java
@@ -601,7 +601,8 @@ public final class Class<T>
ClassLoader cl = getClassLoader();
if (cl != null)
return cl.getPackage(getPackagePortion(getName()));
- return null;
+ else
+ return VMClassLoader.getPackage(getPackagePortion(getName()));
}
/**
diff --git a/java/lang/ClassLoader.java b/java/lang/ClassLoader.java
index ffba56b9a..fe2c7e1b9 100644
--- a/java/lang/ClassLoader.java
+++ b/java/lang/ClassLoader.java
@@ -470,6 +470,26 @@ public abstract class ClassLoader
return VMClassLoader.defineClass(this, name, data, offset, len, domain);
}
+ /**
+ * Helper to define a class using the contents of a byte buffer. If
+ * the domain is null, the default of
+ * <code>Policy.getPolicy().getPermissions(new CodeSource(null,
+ * null))</code> is used. Once a class has been defined in a
+ * package, all further classes in that package must have the same
+ * set of certificates or a SecurityException is thrown.
+ *
+ * @param name the name to give the class. null if unknown
+ * @param buf a byte buffer containing bytes that form a class.
+ * @param domain the ProtectionDomain to give to the class, null for the
+ * default protection domain
+ * @return the class that was defined
+ * @throws ClassFormatError if data is not in proper classfile format
+ * @throws NoClassDefFoundError if the supplied name is not the same as
+ * the one specified by the byte buffer.
+ * @throws SecurityException if name starts with "java.", or if certificates
+ * do not match up
+ * @since 1.5
+ */
protected final Class<?> defineClass(String name, ByteBuffer buf,
ProtectionDomain domain)
throws ClassFormatError
diff --git a/java/lang/StringBuffer.java b/java/lang/StringBuffer.java
index 6fef4f7a2..3aa84a21e 100644
--- a/java/lang/StringBuffer.java
+++ b/java/lang/StringBuffer.java
@@ -442,6 +442,7 @@ public final class StringBuffer
* @param code the code point to append
* @return this <code>StringBuffer</code>
* @see Character#toChars(int, char[], int)
+ * @since 1.5
*/
public synchronized StringBuffer appendCodePoint(int code)
{
diff --git a/java/lang/StringBuilder.java b/java/lang/StringBuilder.java
index 6c2c47e43..55010c396 100644
--- a/java/lang/StringBuilder.java
+++ b/java/lang/StringBuilder.java
@@ -463,6 +463,25 @@ public final class StringBuilder
}
/**
+ * Append the code point to this <code>StringBuilder</code>.
+ * This is like #append(char), but will append two characters
+ * if a supplementary code point is given.
+ *
+ * @param code the code point to append
+ * @return this <code>StringBuilder</code>
+ * @see Character#toChars(int, char[], int)
+ * @since 1.5
+ */
+ public synchronized StringBuilder appendCodePoint(int code)
+ {
+ int len = Character.charCount(code);
+ ensureCapacity(count + len);
+ Character.toChars(code, value, count);
+ count += len;
+ return this;
+ }
+
+ /**
* Append the <code>String</code> value of the argument to this
* <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
* to <code>String</code>.
@@ -704,6 +723,52 @@ public final class StringBuilder
}
/**
+ * Insert the <code>CharSequence</code> argument into this
+ * <code>StringBuilder</code>. If the sequence is null, the String
+ * "null" is used instead.
+ *
+ * @param offset the place to insert in this buffer
+ * @param sequence the <code>CharSequence</code> to insert
+ * @return this <code>StringBuilder</code>
+ * @throws IndexOutOfBoundsException if offset is out of bounds
+ */
+ public synchronized StringBuilder insert(int offset, CharSequence sequence)
+ {
+ if (sequence == null)
+ sequence = "null";
+ return insert(offset, sequence, 0, sequence.length());
+ }
+
+ /**
+ * Insert a subsequence of the <code>CharSequence</code> argument into this
+ * <code>StringBuilder</code>. If the sequence is null, the String
+ * "null" is used instead.
+ *
+ * @param offset the place to insert in this buffer
+ * @param sequence the <code>CharSequence</code> to insert
+ * @param start the starting index of the subsequence
+ * @param end one past the ending index of the subsequence
+ * @return this <code>StringBuilder</code>
+ * @throws IndexOutOfBoundsException if offset, start,
+ * or end are out of bounds
+ */
+ public synchronized StringBuilder insert(int offset, CharSequence sequence,
+ int start, int end)
+ {
+ if (sequence == null)
+ sequence = "null";
+ if (start < 0 || end < 0 || start > end || end > sequence.length())
+ throw new IndexOutOfBoundsException();
+ int len = end - start;
+ ensureCapacity(count + len);
+ VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+ for (int i = start; i < end; ++i)
+ value[offset++] = sequence.charAt(i);
+ count += len;
+ return this;
+ }
+
+ /**
* Insert the <code>char[]</code> argument into this
* <code>StringBuilder</code>.
*
diff --git a/java/lang/Thread.java b/java/lang/Thread.java
index e82f272d3..5430facf5 100644
--- a/java/lang/Thread.java
+++ b/java/lang/Thread.java
@@ -832,8 +832,11 @@ public class Thread implements Runnable
public static void sleep(long ms, int ns) throws InterruptedException
{
// Check parameters
- if (ms < 0 || ns < 0 || ns > 999999)
- throw new IllegalArgumentException();
+ if (ms < 0 )
+ throw new IllegalArgumentException("Negative milliseconds: " + ms);
+
+ if (ns < 0 || ns > 999999)
+ throw new IllegalArgumentException("Nanoseconds ouf of range: " + ns);
// Really sleep
VMThread.sleep(ms, ns);
diff --git a/java/lang/reflect/Proxy.java b/java/lang/reflect/Proxy.java
index 490730ffd..b1ef7429c 100644
--- a/java/lang/reflect/Proxy.java
+++ b/java/lang/reflect/Proxy.java
@@ -111,8 +111,8 @@ import java.util.Set;
* the only way to create an instance of the proxy class.</li>
* <li>The proxy class contains a single constructor, which takes as
* its only argument an {@link InvocationHandler}. The method
- * {@link #newInstance} is shorthand to do the necessary
- * reflection.</li>
+ * {@link #newProxyInstance(ClassLoader, Class[], InvocationHandler)}
+ * is shorthand to do the necessary reflection.</li>
* </ul>
*
* <h3>Proxy Instances</h3>
@@ -413,8 +413,6 @@ public class Proxy implements Serializable
*/
ProxyType(ClassLoader loader, Class[] interfaces)
{
- if (loader == null)
- loader = ClassLoader.getSystemClassLoader();
this.loader = loader;
this.interfaces = interfaces;
}
@@ -426,8 +424,7 @@ public class Proxy implements Serializable
*/
public int hashCode()
{
- //loader is always not null
- int hash = loader.hashCode();
+ int hash = loader == null ? 0 : loader.hashCode();
for (int i = 0; i < interfaces.length; i++)
hash = hash * 31 + interfaces[i].hashCode();
return hash;
diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java
index 75d869d48..5d83c0629 100644
--- a/java/math/BigDecimal.java
+++ b/java/math/BigDecimal.java
@@ -43,15 +43,24 @@ public class BigDecimal extends Number implements Comparable<BigDecimal>
private int scale;
private static final long serialVersionUID = 6108874887143696463L;
- /** @since 1.5 */
+ /**
+ * The constant zero as a BigDecimal with scale zero.
+ * @since 1.5
+ */
public static final BigDecimal ZERO =
new BigDecimal (BigInteger.valueOf (0), 0);
- /** @since 1.5 */
+ /**
+ * The constant one as a BigDecimal with scale zero.
+ * @since 1.5
+ */
public static final BigDecimal ONE =
new BigDecimal (BigInteger.valueOf (1), 0);
- /** @since 1.5 */
+ /**
+ * The constant ten as a BigDecimal with scale zero.
+ * @since 1.5
+ */
public static final BigDecimal TEN =
new BigDecimal (BigInteger.valueOf (10), 0);
diff --git a/java/math/BigInteger.java b/java/math/BigInteger.java
index c2ad1843a..582b3807d 100644
--- a/java/math/BigInteger.java
+++ b/java/math/BigInteger.java
@@ -76,7 +76,8 @@ public class BigInteger extends Number implements Comparable<BigInteger>
private static final long serialVersionUID = -8287574255936472291L;
- /** We pre-allocate integers in the range minFixNum..maxFixNum. */
+ /** We pre-allocate integers in the range minFixNum..maxFixNum.
+ * Note that we must at least preallocate 0, 1, and 10. */
private static final int minFixNum = -100;
private static final int maxFixNum = 1024;
private static final int numFixNum = maxFixNum-minFixNum+1;
@@ -88,13 +89,22 @@ public class BigInteger extends Number implements Comparable<BigInteger>
smallFixNums[i] = new BigInteger(i + minFixNum);
}
- /** @since 1.2 */
+ /**
+ * The constant zero as a BigInteger.
+ * @since 1.2
+ */
public static final BigInteger ZERO = smallFixNums[0 - minFixNum];
- /** @since 1.2 */
+ /**
+ * The constant one as a BigInteger.
+ * @since 1.2
+ */
public static final BigInteger ONE = smallFixNums[1 - minFixNum];
- /** @since 1.5 */
+ /**
+ * The constant ten as a BigInteger.
+ * @since 1.5
+ */
public static final BigInteger TEN = smallFixNums[10 - minFixNum];
/* Rounding modes: */
diff --git a/java/net/DatagramSocket.java b/java/net/DatagramSocket.java
index 875ddc778..40bafbb34 100644
--- a/java/net/DatagramSocket.java
+++ b/java/net/DatagramSocket.java
@@ -484,7 +484,6 @@ public class DatagramSocket
* @param address The address to connect this socket to.
* @param port The port to connect this socket to.
*
- * @exception SocketException If an error occurs.
* @exception IllegalArgumentException If address or port are invalid.
* @exception SecurityException If the caller is not allowed to send
* datagrams to or receive from this address and port.
diff --git a/java/net/Inet4Address.java b/java/net/Inet4Address.java
index 74ce6efb8..c80f1f175 100644
--- a/java/net/Inet4Address.java
+++ b/java/net/Inet4Address.java
@@ -70,7 +70,7 @@ public final class Inet4Address extends InetAddress
* only by static methods in this class.
*
* @param addr The IP number of this address as an array of bytes
- * @param hostname The hostname of this IP address.
+ * @param host The hostname of this IP address.
*/
Inet4Address(byte[] addr, String host)
{
diff --git a/java/net/ServerSocket.java b/java/net/ServerSocket.java
index f73c7482a..afc861403 100644
--- a/java/net/ServerSocket.java
+++ b/java/net/ServerSocket.java
@@ -316,7 +316,8 @@ public class ServerSocket
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkListen(impl.getLocalPort());
+ sm.checkAccept(impl.getInetAddress().getHostAddress(),
+ impl.getLocalPort());
Socket socket = new Socket();
@@ -369,6 +370,7 @@ public class ServerSocket
impl.accept(socket.impl);
socket.implCreated = true;
+ socket.bound = true;
}
/**
diff --git a/java/net/Socket.java b/java/net/Socket.java
index 9432a6be1..0ff6e6ea0 100644
--- a/java/net/Socket.java
+++ b/java/net/Socket.java
@@ -91,8 +91,9 @@ public class Socket
/**
* True if the socket is bound.
+ * Package private so it can be set from ServerSocket when accept is called.
*/
- private boolean bound;
+ boolean bound;
/**
* True if input is shutdown.
@@ -324,7 +325,9 @@ public class Socket
}
catch (IOException e)
{
- throw new SocketException(e.getMessage());
+ SocketException se = new SocketException(e.toString());
+ se.initCause(e);
+ throw se;
}
return impl;
@@ -481,7 +484,7 @@ public class Socket
/**
* Returns the local address to which this socket is bound. If this socket
* is not connected, then a wildcard address, for which
- * @see isAnyLocalAddress() is <code>true</code>, is returned.
+ * @see InetAddress#isAnyLocalAddress() is <code>true</code>, is returned.
*
* @return The local address
*
diff --git a/java/net/URLClassLoader.java b/java/net/URLClassLoader.java
index 73731bce7..5aaaedaa3 100644
--- a/java/net/URLClassLoader.java
+++ b/java/net/URLClassLoader.java
@@ -235,12 +235,10 @@ public class URLClassLoader extends SecureClassLoader
abstract static class Resource
{
final URLLoader loader;
- final String name;
- Resource(URLLoader loader, String name)
+ Resource(URLLoader loader)
{
this.loader = loader;
- this.name = name;
}
/**
@@ -391,11 +389,13 @@ public class URLClassLoader extends SecureClassLoader
static final class JarURLResource extends Resource
{
private final JarEntry entry;
+ private final String name;
JarURLResource(JarURLLoader loader, String name, JarEntry entry)
{
- super(loader, name);
+ super(loader);
this.entry = entry;
+ this.name = name;
}
InputStream getInputStream() throws IOException
@@ -496,7 +496,7 @@ public class URLClassLoader extends SecureClassLoader
RemoteResource(RemoteURLLoader loader, String name, URL url,
InputStream stream, int length)
{
- super(loader, name);
+ super(loader);
this.url = url;
this.stream = stream;
this.length = length;
@@ -539,7 +539,7 @@ public class URLClassLoader extends SecureClassLoader
{
File file = new File(dir, name).getCanonicalFile();
if (file.exists() && !file.isDirectory())
- return new FileResource(this, file.getPath(), file);
+ return new FileResource(this, file);
}
catch (IOException e)
{
@@ -553,9 +553,9 @@ public class URLClassLoader extends SecureClassLoader
{
final File file;
- FileResource(FileURLLoader loader, String name, File file)
+ FileResource(FileURLLoader loader, File file)
{
- super(loader, name);
+ super(loader);
this.file = file;
}
@@ -573,8 +573,7 @@ public class URLClassLoader extends SecureClassLoader
{
try
{
- return new URL(loader.baseURL, name,
- loader.classloader.getURLStreamHandler("file"));
+ return file.toURL();
}
catch (MalformedURLException e)
{
@@ -755,13 +754,21 @@ public class URLClassLoader extends SecureClassLoader
}
/**
- * Adds an array of new locations to the end of the internal URL store.
+ * Adds an array of new locations to the end of the internal URL
+ * store. Called from the the constructors. Should not call to the
+ * protected addURL() method since that can be overridden and
+ * subclasses are not yet in a good state at this point.
+ * jboss 4.0.3 for example depends on this.
+ *
* @param newUrls the locations to add
*/
private void addURLs(URL[] newUrls)
{
for (int i = 0; i < newUrls.length; i++)
- addURL(newUrls[i]);
+ {
+ urls.add(newUrls[i]);
+ addURLImpl(newUrls[i]);
+ }
}
/**
@@ -786,13 +793,13 @@ public class URLClassLoader extends SecureClassLoader
* package is sealed. If the Manifest indicates that the package is sealed
* then the Package will be sealed with respect to the supplied URL.
*
- * @exception IllegalArgumentException If this package name already exists
- * in this class loader
* @param name The name of the package
* @param manifest The manifest describing the specification,
* implementation and sealing details of the package
* @param url the code source url to seal the package
* @return the defined Package
+ * @throws IllegalArgumentException If this package name already exists
+ * in this class loader
*/
protected Package definePackage(String name, Manifest manifest, URL url)
throws IllegalArgumentException
diff --git a/java/net/URLConnection.java b/java/net/URLConnection.java
index 34302613d..2b727c20d 100644
--- a/java/net/URLConnection.java
+++ b/java/net/URLConnection.java
@@ -531,7 +531,7 @@ public abstract class URLConnection
}
/**
- * Returns the value of a flag indicating whether or not input is going
+ * Sets the value of a flag indicating whether or not input is going
* to be done for this connection. This default to true unless the
* doOutput flag is set to false, in which case this defaults to false.
*
@@ -561,7 +561,7 @@ public abstract class URLConnection
}
/**
- * Returns a boolean flag indicating whether or not output will be done
+ * Sets a boolean flag indicating whether or not output will be done
* on this connection. The default value is false, so this method can
* be used to override the default
*
@@ -852,7 +852,7 @@ public abstract class URLConnection
}
/**
- * Set's the ContentHandlerFactory for an application. This can be called
+ * Sets the ContentHandlerFactory for an application. This can be called
* once and only once. If it is called again, then an Error is thrown.
* Unlike for other set factory methods, this one does not do a security
* check prior to setting the factory.
@@ -934,7 +934,7 @@ public abstract class URLConnection
}
/**
- * This method set the <code>FileNameMap</code> object being used
+ * This method sets the <code>FileNameMap</code> object being used
* to decode MIME types by file extension.
*
* @param map The <code>FileNameMap</code>.
diff --git a/java/net/URLStreamHandler.java b/java/net/URLStreamHandler.java
index 4b0ee49dd..ed9509221 100644
--- a/java/net/URLStreamHandler.java
+++ b/java/net/URLStreamHandler.java
@@ -411,8 +411,6 @@ public abstract class URLStreamHandler
* @param url2 The second URL.
*
* @return True if both URLs contain the same host.
- *
- * @exception UnknownHostException If an unknown host is found
*/
protected boolean hostsEqual(URL url1, URL url2)
{
@@ -517,12 +515,18 @@ public abstract class URLStreamHandler
sb.append(":");
}
- if (authority.length() != 0)
- {
- sb.append("//").append(authority);
- }
-
- sb.append(file);
+ // If we have superfluous leading slashes (that means, at least 2)
+ // we always add the authority component ("//" + host) to
+ // avoid ambiguity. Otherwise we would generate an URL like
+ // proto://home/foo
+ // where we meant:
+ // host: <empty> - file: //home/foo
+ // but URL spec says it is:
+ // host: home - file: /foo
+ if (authority.length() != 0 || file.startsWith("//") )
+ sb.append("//").append(authority).append(file);
+ else
+ sb.append(file);
if (ref != null)
sb.append('#').append(ref);
diff --git a/java/nio/channels/spi/AbstractSelectableChannel.java b/java/nio/channels/spi/AbstractSelectableChannel.java
index 42ceab7e2..847c02cce 100644
--- a/java/nio/channels/spi/AbstractSelectableChannel.java
+++ b/java/nio/channels/spi/AbstractSelectableChannel.java
@@ -43,6 +43,7 @@ import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
+import java.nio.channels.IllegalBlockingModeException;
import java.util.LinkedList;
import java.util.ListIterator;
@@ -209,6 +210,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel
* @return the registered selection key
*
* @exception ClosedChannelException If the channel is already closed.
+ * @exception IllegalBlockingModeException If the channel is configured in
+ * blocking mode.
*/
public final SelectionKey register(Selector selin, int ops, Object att)
throws ClosedChannelException
@@ -224,6 +227,9 @@ public abstract class AbstractSelectableChannel extends SelectableChannel
synchronized (blockingLock())
{
+ if (blocking)
+ throw new IllegalBlockingModeException();
+
key = locate(selector);
if (key != null && key.isValid())
diff --git a/java/rmi/activation/ActivationGroup_Stub.java b/java/rmi/activation/ActivationGroup_Stub.java
new file mode 100644
index 000000000..249137b08
--- /dev/null
+++ b/java/rmi/activation/ActivationGroup_Stub.java
@@ -0,0 +1,110 @@
+/* ActivationGroup_Stub.java -- Stub class for ActivationGroup impls.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.lang.reflect.Method;
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+
+/**
+ * A stub class for {@link ActivationGroup} implementations.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class ActivationGroup_Stub extends RemoteStub
+ implements ActivationInstantiator, Remote
+{
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Creates a new instance of ActivationGroup_Stub.
+ *
+ * @param ref the remote reference
+ */
+ public ActivationGroup_Stub(RemoteRef ref)
+ {
+ super(ref);
+ }
+
+ /**
+ * Stub method for <code>ActivationGroup.newInstance()</code>.
+ *
+ * @param id the activation ID
+ * @param desc the activation description
+ *
+ * @return the return value of the invocation
+ *
+ * @throws RemoteException if the invocation throws a RemoteException
+ * @throws ActivationException if the invocation throws an
+ * ActivationException
+ */
+ public MarshalledObject newInstance(ActivationID id, ActivationDesc desc)
+ throws RemoteException, ActivationException
+ {
+ try
+ {
+ Method method = ActivationGroup_Stub.class.getDeclaredMethod
+ ("newInstance", new Class[]{ ActivationID.class,
+ ActivationDesc.class });
+ return (MarshalledObject) ref.invoke(this, method,
+ new Object[]{id, desc},
+ -5274445189091581345L);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (RemoteException ex)
+ {
+ throw ex;
+ }
+ catch (ActivationException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new UnexpectedException("Unexpected exception", ex);
+ }
+ }
+}
diff --git a/java/rmi/server/LoaderHandler.java b/java/rmi/server/LoaderHandler.java
index 189085710..0489cd166 100644
--- a/java/rmi/server/LoaderHandler.java
+++ b/java/rmi/server/LoaderHandler.java
@@ -45,7 +45,11 @@ import java.net.URL;
*/
public interface LoaderHandler
{
- String packagePrefix = "";
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
/**
* @deprecated
diff --git a/java/rmi/server/RMIClassLoader.java b/java/rmi/server/RMIClassLoader.java
index a7a7cb84a..f8997fd7e 100644
--- a/java/rmi/server/RMIClassLoader.java
+++ b/java/rmi/server/RMIClassLoader.java
@@ -38,14 +38,10 @@ exception statement from your version. */
package java.rmi.server;
+import gnu.java.rmi.server.RMIClassLoaderImpl;
+
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.StringTokenizer;
-
/**
* This class provides a set of public static utility methods for supporting
@@ -60,221 +56,77 @@ public class RMIClassLoader
*/
private RMIClassLoader() {}
- private static class MyClassLoader extends URLClassLoader
- {
- // Package-private to avoid a trampoline constructor.
- MyClassLoader (URL[] urls, ClassLoader parent, String annotation)
- {
- super (urls, parent);
- this.annotation = annotation;
- }
-
- private MyClassLoader (URL[] urls, ClassLoader parent)
- {
- super (urls, parent);
- this.annotation = urlToAnnotation (urls);
- }
-
- public static String urlToAnnotation (URL[] urls)
- {
- if (urls.length == 0)
- return null;
-
- StringBuffer annotation = new StringBuffer (64 * urls.length);
-
- for (int i = 0; i < urls.length; i++)
- {
- annotation.append (urls [i].toExternalForm());
- annotation.append (' ');
- }
-
- return annotation.toString();
- }
-
- public final String getClassAnnotation()
- {
- return annotation;
- }
-
- private final String annotation;
- }
-
- /**
- * This class is used to identify a cached classloader by its codebase and
- * the context classloader that is its parent.
- */
- private static class CacheKey
- {
- private String mCodeBase;
- private ClassLoader mContextClassLoader;
-
- public CacheKey (String theCodebase, ClassLoader theContextClassLoader)
- {
- mCodeBase = theCodebase;
- mContextClassLoader = theContextClassLoader;
- }
-
- /**
- * @return true if the codebase and the context classloader are equal
- */
- public boolean equals (Object theOther)
- {
- if (theOther instanceof CacheKey)
- {
- CacheKey key = (CacheKey) theOther;
-
- return (equals (this.mCodeBase,key.mCodeBase)
- && equals (this.mContextClassLoader, key.mContextClassLoader));
- }
- return false;
- }
-
- /**
- * Test if the two objects are equal or both null.
- * @param theOne
- * @param theOther
- * @return
- */
- private boolean equals (Object theOne, Object theOther)
- {
- return theOne != null ? theOne.equals (theOther) : theOther == null;
- }
-
- /**
- * @return hashCode
- */
- public int hashCode()
- {
- return ((mCodeBase != null ? mCodeBase.hashCode() : 0)
- ^(mContextClassLoader != null ? mContextClassLoader.hashCode() : -1));
- }
-
- public String toString()
- {
- return "[" + mCodeBase + "," + mContextClassLoader + "]";
- }
-
- }
-
- private static Map cacheLoaders; //map annotations to loaders
- private static Map cacheAnnotations; //map loaders to annotations
-
- //defaultAnnotation is got from system property
- // "java.rmi.server.defaultAnnotation"
- private static String defaultAnnotation;
-
- //URL object for defaultAnnotation
- private static URL defaultCodebase;
-
- //class loader for defaultAnnotation
- private static MyClassLoader defaultLoader;
-
- static
- {
- // 89 is a nice prime number for Hashtable initial capacity
- cacheLoaders = new Hashtable (89);
- cacheAnnotations = new Hashtable (89);
-
- defaultAnnotation = System.getProperty ("java.rmi.server.defaultAnnotation");
-
- try
- {
- if (defaultAnnotation != null)
- defaultCodebase = new URL (defaultAnnotation);
- }
- catch (Exception _)
- {
- defaultCodebase = null;
- }
-
- if (defaultCodebase != null)
- {
- defaultLoader = new MyClassLoader (new URL[] { defaultCodebase }, null,
- defaultAnnotation);
- cacheLoaders.put (new CacheKey (defaultAnnotation,
- Thread.currentThread().getContextClassLoader()),
- defaultLoader);
- }
- }
-
/**
* @deprecated
*/
- public static Class loadClass (String name)
+ public static Class loadClass(String name)
throws MalformedURLException, ClassNotFoundException
{
- return loadClass ("", name);
+ return loadClass("", name);
}
- public static Class loadClass (String codebases, String name)
+ public static Class loadClass(String codebase, String name)
throws MalformedURLException, ClassNotFoundException
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- //try context class loader first
- try
- {
- return Class.forName(name, false, loader);
- }
- catch (ClassNotFoundException e)
- {
- // class not found in the local classpath
- }
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, null);
+ }
- if (codebases.length() == 0) //==""
- {
- loader = defaultLoader;
- }
- else
- {
- loader = getClassLoader(codebases);
- }
+ public static Class loadClass(String codebase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, defaultLoader);
+ }
- if (loader == null)
- {
- //do not throw NullPointerException
- throw new ClassNotFoundException ("Could not find class (" + name +
- ") at codebase (" + codebases + ")");
- }
-
- return Class.forName(name, false, loader);
+ /**
+ * Loads a class from <code>codeBase</code>.
+ *
+ * This method delegates to
+ * {@link RMIClassLoaderSpi#loadClass(String, String, ClassLoader)} and
+ * passes <code>codeBase.toString()</code> as first argument,
+ * <code>name</code> as second argument and <code>null</code> as third
+ * argument.
+ *
+ * @param codeBase the code base from which to load the class
+ * @param name the name of the class
+ *
+ * @return the loaded class
+ *
+ * @throws MalformedURLException if the URL is not well formed
+ * @throws ClassNotFoundException if the requested class cannot be found
+ */
+ public static Class loadClass(URL codeBase, String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codeBase.toString(), name, null);
}
/**
* Gets a classloader for the given codebase and with the current
* context classloader as parent.
*
- * @param codebases
+ * @param codebase
*
* @return a classloader for the given codebase
*
* @throws MalformedURLException if the codebase contains a malformed URL
*/
- public static ClassLoader getClassLoader (String codebases)
+ public static ClassLoader getClassLoader(String codebase)
throws MalformedURLException
{
- ClassLoader loader;
- CacheKey loaderKey = new CacheKey
- (codebases, Thread.currentThread().getContextClassLoader());
- loader = (ClassLoader) cacheLoaders.get (loaderKey);
-
- if (loader == null)
- {
- //create an entry in cacheLoaders mapping a loader to codebases.
- // codebases are separated by " "
- StringTokenizer tok = new StringTokenizer (codebases, " ");
- ArrayList urls = new ArrayList();
-
- while (tok.hasMoreTokens())
- urls.add (new URL (tok.nextToken()));
-
- loader = new MyClassLoader ((URL[]) urls.toArray (new URL [urls.size()]),
- Thread.currentThread().getContextClassLoader(),
- codebases);
- cacheLoaders.put (loaderKey, loader);
- }
-
- return loader;
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassLoader(codebase);
}
/**
@@ -286,47 +138,12 @@ public class RMIClassLoader
* @return a space seperated list of URLs where the class-definition
* of cl may be found
*/
- public static String getClassAnnotation (Class cl)
+ public static String getClassAnnotation(Class cl)
{
- ClassLoader loader = cl.getClassLoader();
-
- if (loader == null
- || loader == ClassLoader.getSystemClassLoader())
- {
- return System.getProperty ("java.rmi.server.codebase");
- }
-
- if (loader instanceof MyClassLoader)
- {
- return ((MyClassLoader) loader).getClassAnnotation();
- }
-
- String s = (String) cacheAnnotations.get (loader);
-
- if (s != null)
- return s;
-
- if (loader instanceof URLClassLoader)
- {
- URL[] urls = ((URLClassLoader) loader).getURLs();
-
- if (urls.length == 0)
- return null;
-
- StringBuffer annotation = new StringBuffer (64 * urls.length);
-
- for (int i = 0; i < urls.length; i++)
- {
- annotation.append (urls [i].toExternalForm());
- annotation.append (' ');
- }
-
- s = annotation.toString();
- cacheAnnotations.put (loader, s);
- return s;
- }
-
- return System.getProperty ("java.rmi.server.codebase");
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassAnnotation(cl);
}
/**
@@ -336,4 +153,25 @@ public class RMIClassLoader
{
throw new Error ("Not implemented");
}
+
+ /**
+ * Returns the default service provider for <code>RMIClassLoader</code>.
+ *
+ * @return the default provider for <code>RMIClassLoader</code>
+ */
+ public static RMIClassLoaderSpi getDefaultProviderInstance()
+ {
+ return RMIClassLoaderImpl.getInstance();
+ }
+
+ /**
+ * Chooses, instantiates and returns a service provider.
+ *
+ * @return a service provider
+ */
+ private static RMIClassLoaderSpi getProviderInstance()
+ {
+ // TODO: Do something more useful here.
+ return null;
+ }
}
diff --git a/java/rmi/server/RemoteObject.java b/java/rmi/server/RemoteObject.java
index 0b3c229c9..60e57dc24 100644
--- a/java/rmi/server/RemoteObject.java
+++ b/java/rmi/server/RemoteObject.java
@@ -120,7 +120,9 @@ public boolean equals(Object obj) {
in.read (); //some unknown UnicastRef2 field
}
- cname = RemoteRef.packagePrefix + '.' + cname;
+ // It would be nice to use RemoteRef.packagePrefix here, but for binary
+ // compatibility with the JDK that has to contain "sun.rmi.server"...
+ cname = "gnu.java.rmi.server." + cname;
try
{
Class cls = Class.forName(cname);
diff --git a/java/rmi/server/RemoteRef.java b/java/rmi/server/RemoteRef.java
index 7e34db39e..f33f9d374 100644
--- a/java/rmi/server/RemoteRef.java
+++ b/java/rmi/server/RemoteRef.java
@@ -48,7 +48,11 @@ public interface RemoteRef extends Externalizable
{
long serialVersionUID = 3632638527362204081L;
- String packagePrefix = "gnu.java.rmi.server";
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
/**
* @deprecated
diff --git a/java/security/AccessControlContext.java b/java/security/AccessControlContext.java
index 9a6ad2081..3b51e9412 100644
--- a/java/security/AccessControlContext.java
+++ b/java/security/AccessControlContext.java
@@ -77,14 +77,23 @@ public final class AccessControlContext
/**
* Construct a new AccessControlContext with the specified
- * ProtectionDomains and DomainCombiner
+ * {@link ProtectionDomain}s and {@link DomainCombiner}.
*
+ * <p>Code calling this constructor must have a {@link
+ * SecurityPermission} of <i>createAccessControlContext</i>.</p>
+ *
+ * @throws SecurityException If the caller does not have permission
+ * to create an access control context.
* @since 1.3
*/
public AccessControlContext(AccessControlContext acc,
DomainCombiner combiner)
{
- // XXX check permission to call this.
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ {
+ sm.checkPermission (new SecurityPermission ("createAccessControlContext"));
+ }
AccessControlContext acc2 = AccessController.getContext();
protectionDomains = combiner.combine (acc2.protectionDomains,
acc.protectionDomains);
@@ -119,10 +128,20 @@ public final class AccessControlContext
public void checkPermission(Permission perm) throws AccessControlException
{
if (protectionDomains.length == 0)
- throw new AccessControlException ("permission not granted");
+ throw new AccessControlException ("permission "
+ + perm
+ + " not granted: no protection domains");
+
for (int i = 0; i < protectionDomains.length; i++)
- if (!protectionDomains[i].implies(perm))
- throw new AccessControlException ("permission not granted");
+ {
+ final ProtectionDomain domain = protectionDomains[i];
+ if (!domain.implies(perm))
+ throw new AccessControlException ("permission "
+ + perm
+ + " not granted: "
+ + domain
+ + " does not imply it.");
+ }
}
/**
@@ -173,4 +192,9 @@ public final class AccessControlContext
return h;
}
+
+ ProtectionDomain[] getProtectionDomains ()
+ {
+ return protectionDomains;
+ }
}
diff --git a/java/security/AccessController.java b/java/security/AccessController.java
index bc9c2deef..93e34b87c 100644
--- a/java/security/AccessController.java
+++ b/java/security/AccessController.java
@@ -142,8 +142,8 @@ public final class AccessController
* @param action the <code>PrivilegedExceptionAction</code> whose
* <code>run()</code> should be be called.
* @return the result of the <code>action.run()</code> method.
- * @exception PrivilegedActionException wrapped around any exception that
- * is thrown in the <code>run()</code> method.
+ * @exception PrivilegedActionException wrapped around any checked exception
+ * that is thrown in the <code>run()</code> method.
*/
public static Object doPrivileged(PrivilegedExceptionAction action)
throws PrivilegedActionException
@@ -153,6 +153,10 @@ public final class AccessController
{
return action.run();
}
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
throw new PrivilegedActionException(e);
@@ -178,8 +182,8 @@ public final class AccessController
* @param context the <code>AccessControlContext</code> whose protection
* domains should be added to the protection domain of the calling class.
* @return the result of the <code>action.run()</code> method.
- * @exception PrivilegedActionException wrapped around any exception that
- * is thrown in the <code>run()</code> method.
+ * @exception PrivilegedActionException wrapped around any checked exception
+ * that is thrown in the <code>run()</code> method.
*/
public static Object doPrivileged(PrivilegedExceptionAction action,
AccessControlContext context)
@@ -190,6 +194,10 @@ public final class AccessController
{
return action.run();
}
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
throw new PrivilegedActionException(e);
diff --git a/java/text/AttributedString.java b/java/text/AttributedString.java
index 9f0d5af1c..c751ab43c 100644
--- a/java/text/AttributedString.java
+++ b/java/text/AttributedString.java
@@ -49,7 +49,7 @@ import java.util.Set;
/**
* This class models a <code>String</code> with attributes over various
* subranges of the string. It allows applications to access this
- * information via the <code>AttributedCharcterIterator</code> interface.
+ * information via the <code>AttributedCharacterIterator</code> interface.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
@@ -166,16 +166,16 @@ public class AttributedString
*
* @param aci The <code>AttributedCharacterIterator</code> containing the
* text and attribute information.
- * @param begin_index The beginning index of the text subrange.
- * @param end_index The ending index of the text subrange.
+ * @param begin The beginning index of the text subrange.
+ * @param end The ending index of the text subrange.
* @param attributes A list of attributes to include from the iterator, or
* <code>null</code> to include all attributes.
*/
- public AttributedString(AttributedCharacterIterator aci, int begin_index,
- int end_index, AttributedCharacterIterator.Attribute[] attributes)
+ public AttributedString(AttributedCharacterIterator aci, int begin, int end,
+ AttributedCharacterIterator.Attribute[] attributes)
{
// Validate some arguments
- if ((begin_index < 0) || (end_index < begin_index))
+ if ((begin < 0) || (end < begin) || end > aci.getEndIndex())
throw new IllegalArgumentException("Bad index values");
StringBuffer sb = new StringBuffer("");
@@ -186,7 +186,7 @@ public class AttributedString
all_attribs.retainAll(Arrays.asList(attributes));
// Loop through and extract the attributes
- char c = aci.setIndex(begin_index);
+ char c = aci.setIndex(begin);
ArrayList accum = new ArrayList();
do
@@ -209,28 +209,28 @@ public class AttributedString
int rl = aci.getRunLimit(attrib);
if (rl == -1)
continue;
- if (rl > end_index)
- rl = end_index;
- rl -= begin_index;
+ if (rl > end)
+ rl = end;
+ rl -= begin;
// Check to see if we already processed this one
int rs = aci.getRunStart(attrib);
- if ((rs < aci.getIndex()) && (aci.getIndex() != begin_index))
+ if ((rs < aci.getIndex()) && (aci.getIndex() != begin))
continue;
// If the attribute run starts before the beginning index, we
// need to junk it if it is an Annotation.
Object attrib_obj = aci.getAttribute(attrib);
- if (rs < begin_index)
+ if (rs < begin)
{
if (attrib_obj instanceof Annotation)
continue;
- rs = begin_index;
+ rs = begin;
}
else
{
- rs -= begin_index;
+ rs -= begin;
}
// Create a map object. Yes this will only contain one attribute
@@ -269,22 +269,23 @@ public class AttributedString
*
* @param attrib The attribute to add.
* @param value The value of the attribute, which may be <code>null</code>.
- * @param begin_index The beginning index of the subrange.
- * @param end_index The ending index of the subrange.
+ * @param begin The beginning index of the subrange.
+ * @param end The ending index of the subrange.
*
* @exception IllegalArgumentException If attribute is <code>null</code> or
* the subrange is not valid.
*/
public void addAttribute(AttributedCharacterIterator.Attribute attrib,
- Object value, int begin_index, int end_index)
+ Object value, int begin, int end)
{
if (attrib == null)
throw new IllegalArgumentException("null attribute");
-
+ if (end <= begin)
+ throw new IllegalArgumentException("Requires end > begin");
HashMap hm = new HashMap();
hm.put(attrib, value);
- addAttributes(hm, begin_index, end_index);
+ addAttributes(hm, begin, end);
}
/**
@@ -295,16 +296,17 @@ public class AttributedString
* @param begin_index The beginning index.
* @param end_index The ending index
*
- * @throws IllegalArgumentException If the list is <code>null</code> or the
- * subrange is not valid.
+ * @throws NullPointerException if <code>attributes</code> is
+ * <code>null</code>.
+ * @throws IllegalArgumentException if the subrange is not valid.
*/
public void addAttributes(Map attributes, int begin_index, int end_index)
{
if (attributes == null)
- throw new IllegalArgumentException("null attribute");
+ throw new NullPointerException("null attribute");
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
- (end_index < begin_index))
+ (end_index <= begin_index))
throw new IllegalArgumentException("bad range");
AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
diff --git a/java/text/AttributedStringIterator.java b/java/text/AttributedStringIterator.java
index 7fba5d63c..f6b9b1868 100644
--- a/java/text/AttributedStringIterator.java
+++ b/java/text/AttributedStringIterator.java
@@ -188,30 +188,44 @@ class AttributedStringIterator implements AttributedCharacterIterator
return(getRunLimit(s));
}
- public synchronized int getRunLimit(Set attribute_set)
+ public synchronized int getRunLimit(Set attributeSet)
{
- boolean hit = false;
- int runLimit = ci.getEndIndex ();
- int pos = ci.getIndex ();
-
- for (int i = 0; i < attribs.length; ++i)
+ if (attributeSet == null)
+ return ci.getEndIndex();
+
+ int current = ci.getIndex();
+ int end = ci.getEndIndex();
+ int limit = current;
+ if (current == end)
+ return end;
+ Map runValues = getAttributes();
+ while (limit < end)
+ {
+ Iterator iterator = attributeSet.iterator();
+ while (iterator.hasNext())
{
- if (pos >= attribs[i].begin_index &&
- pos < attribs[i].end_index)
+ // Qualified name is a workaround for a gcj 4.0 bug.
+ AttributedCharacterIterator.Attribute attributeKey
+ = (AttributedCharacterIterator.Attribute) iterator.next();
+ Object v1 = runValues.get(attributeKey);
+ Object v2 = getAttribute(attributeKey, limit + 1);
+ boolean changed = false;
+ // check for equal or both null, if NO return start
+ if (v1 != null)
+ {
+ changed = !v1.equals(v2);
+ }
+ else
{
- Iterator iter = attribute_set.iterator();
- while(iter.hasNext())
- if (attribs[i].attribs.containsKey(iter.next()))
- {
- hit = true;
- runLimit = Math.min(runLimit, attribs[i].end_index);
- }
+ changed = (v2 != null);
}
+ if (changed)
+ return limit + 1;
}
- if (hit)
- return runLimit;
- else
- return ci.getEndIndex();
+ // no differences, so increment limit and next and loop again
+ limit++;
+ }
+ return end;
}
/*************************************************************************/
@@ -221,69 +235,128 @@ class AttributedStringIterator implements AttributedCharacterIterator
* attribute combinations.
*/
+ /**
+ * Returns the index of the first character in the run containing the current
+ * character and defined by all the attributes defined for that character
+ * position.
+ *
+ * @return The run start index.
+ */
public int getRunStart()
{
return(getRunStart(getAttributes().keySet()));
}
+ /**
+ * Returns the index of the first character in the run, defined by the
+ * specified attribute, that contains the current character.
+ *
+ * @param attrib the attribute (<code>null</code> permitted).
+ *
+ * return The index of the first character in the run.
+ */
public int getRunStart(AttributedCharacterIterator.Attribute attrib)
{
+ if (attrib == null)
+ return ci.getBeginIndex();
HashSet s = new HashSet();
s.add(attrib);
-
return(getRunStart(s));
}
- public int getRunStart(Set attribute_set)
+ /**
+ * Returns the index of the first character in the run, defined by the
+ * specified attribute set, that contains the current character.
+ *
+ * @param attributeSet the attribute set (<code>null</code> permitted).
+ *
+ * return The index of the first character in the run.
+ */
+ public int getRunStart(Set attributeSet)
{
- boolean hit = false;
- int runBegin = 0;
- int pos = ci.getIndex();
-
- for (int i = 0; i < attribs.length; ++i)
+ if (attributeSet == null)
+ return ci.getBeginIndex();
+
+ int current = ci.getIndex();
+ int begin = ci.getBeginIndex();
+ int start = current;
+ if (start == begin)
+ return begin;
+ Map runValues = getAttributes();
+ int prev = start - 1;
+ while (start > begin)
+ {
+ Iterator iterator = attributeSet.iterator();
+ while (iterator.hasNext())
{
- if (pos >= attribs[i].begin_index &&
- pos <= attribs[i].end_index)
+ // Qualified name is a workaround for a gcj 4.0 bug.
+ AttributedCharacterIterator.Attribute attributeKey
+ = (AttributedCharacterIterator.Attribute) iterator.next();
+ Object v1 = runValues.get(attributeKey);
+ Object v2 = getAttribute(attributeKey, prev);
+ boolean changed = false;
+ // check for equal or both null, if NO return start
+ if (v1 != null)
+ {
+ changed = !v1.equals(v2);
+ }
+ else
{
- Iterator iter = attribute_set.iterator();
- while(iter.hasNext())
- if (attribs[i].attribs.containsKey(iter.next()))
- {
- hit = true;
- runBegin = Math.max(runBegin, attribs[i].begin_index);
- }
+ changed = (v2 != null);
}
+ if (changed)
+ return start;
}
- if (hit)
- return runBegin;
- else
- return -1;
+ // no differences, so decrement start and prev and loop again
+ start--;
+ prev--;
+ }
+ return start;
}
/*************************************************************************/
- public Object getAttribute(AttributedCharacterIterator.Attribute attrib)
+ /**
+ * Returns the value for an attribute at the specified position. If the
+ * attribute key (<code>key</code>) is <code>null</code>, the method returns
+ * <code>null</code>.
+ *
+ * @param key the key (<code>null</code> permitted).
+ * @param pos the character position.
+ *
+ * @return The attribute value (possibly <code>null</code>).
+ */
+ private Object getAttribute(AttributedCharacterIterator.Attribute key,
+ int pos)
{
if (attribs == null)
- return(null);
-
- for (int i = 0; i < attribs.length; i++)
+ return null;
+ for (int i = attribs.length - 1; i >= 0; i--)
{
- Set key_set = attribs[i].attribs.keySet();
- Iterator iter = key_set.iterator();
- while (iter.hasNext())
+ if (pos >= attribs[i].begin_index && pos < attribs[i].end_index)
{
- Object obj = iter.next();
-
- // Check for attribute match and range match
- if (obj.equals(attrib))
- if ((ci.getIndex() >= attribs[i].begin_index) &&
- (ci.getIndex() < attribs[i].end_index))
- return(attribs[i].attribs.get(obj));
+ Set keys = attribs[i].attribs.keySet();
+ if (keys.contains(key))
+ {
+ return attribs[i].attribs.get(key);
+ }
}
}
-
- return(null);
+ return null;
+ }
+
+ /**
+ * Returns the value for an attribute at the current position. If the
+ * attribute key (<code>key</code>) is <code>null</code>, the method returns
+ * <code>null</code>.
+ *
+ * @param key the key (<code>null</code> permitted).
+ *
+ * @return The attribute value (possibly <code>null</code>).
+ */
+ public Object getAttribute(AttributedCharacterIterator.Attribute key)
+ {
+ return getAttribute(key, ci.getIndex());
}
/*************************************************************************/
diff --git a/java/text/CharacterIterator.java b/java/text/CharacterIterator.java
index 58d6ddc39..42da33c43 100644
--- a/java/text/CharacterIterator.java
+++ b/java/text/CharacterIterator.java
@@ -68,7 +68,7 @@ public interface CharacterIterator extends Cloneable
* <code>getEndIndex() - 1</code>, it will not be incremented.
*
* @return The character at the position of the incremented index value,
- * or <code>DONE</code> if the index has reached getEndIndex() - 1
+ * or {@link #DONE} if the index has reached getEndIndex() - 1
*/
char next();
diff --git a/java/util/Calendar.java b/java/util/Calendar.java
index 700aab10c..52499ce1a 100644
--- a/java/util/Calendar.java
+++ b/java/util/Calendar.java
@@ -915,8 +915,19 @@ public abstract class Calendar
*/
public boolean equals(Object o)
{
- return (o instanceof Calendar)
- && getTimeInMillis() == ((Calendar) o).getTimeInMillis();
+ if (! (o instanceof Calendar))
+ return false;
+ Calendar cal = (Calendar) o;
+ if (getTimeInMillis() == ((Calendar) o).getTimeInMillis()
+ && cal.getFirstDayOfWeek() == getFirstDayOfWeek()
+ && cal.isLenient() == isLenient()
+ && cal.getMinimalDaysInFirstWeek() == getMinimalDaysInFirstWeek())
+ {
+ TimeZone self = getTimeZone();
+ TimeZone oth = cal.getTimeZone();
+ return self == null ? oth == null : self.equals(oth);
+ }
+ return false;
}
/**
@@ -927,7 +938,13 @@ public abstract class Calendar
public int hashCode()
{
long time = getTimeInMillis();
- return (int) ((time & 0xffffffffL) ^ (time >> 32));
+ int val = (int) ((time & 0xffffffffL) ^ (time >> 32));
+ val += (getFirstDayOfWeek() + (isLenient() ? 1230 : 1237)
+ + getMinimalDaysInFirstWeek());
+ TimeZone self = getTimeZone();
+ if (self != null)
+ val ^= self.hashCode();
+ return val;
}
/**
diff --git a/java/util/GregorianCalendar.java b/java/util/GregorianCalendar.java
index 97ee29b13..85d00f1ca 100644
--- a/java/util/GregorianCalendar.java
+++ b/java/util/GregorianCalendar.java
@@ -868,6 +868,17 @@ public class GregorianCalendar extends Calendar
areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true;
}
+
+ /**
+ * Return a hash code for this object, following the general contract
+ * specified by {@link Object#hashCode()}.
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ int val = (int) ((gregorianCutover >>> 32) ^ (gregorianCutover & 0xffffffff));
+ return super.hashCode() ^ val;
+ }
/**
* Compares the given calendar with this. An object, o, is
@@ -890,7 +901,8 @@ public class GregorianCalendar extends Calendar
return false;
GregorianCalendar cal = (GregorianCalendar) o;
- return (cal.getTimeInMillis() == getTimeInMillis());
+ return (cal.gregorianCutover == gregorianCutover
+ && super.equals(o));
}
/**
diff --git a/java/util/Map.java b/java/util/Map.java
index 302e88104..67b3d8aa5 100644
--- a/java/util/Map.java
+++ b/java/util/Map.java
@@ -324,10 +324,10 @@ public interface Map<K, V>
* this must be:
*
<p><pre>(o instanceof Map.Entry)
-&& (getKey() == null ? ((HashMap) o).getKey() == null
- : getKey().equals(((HashMap) o).getKey()))
-&& (getValue() == null ? ((HashMap) o).getValue() == null
- : getValue().equals(((HashMap) o).getValue()))</pre>
+&& (getKey() == null ? ((Map.Entry) o).getKey() == null
+ : getKey().equals(((Map.Entry) o).getKey()))
+&& (getValue() == null ? ((Map.Entry) o).getValue() == null
+ : getValue().equals(((Map.Entry) o).getValue()))</pre>
*
* @param o the object to compare
*
diff --git a/java/util/Properties.java b/java/util/Properties.java
index f50efc115..9f0f5c70c 100644
--- a/java/util/Properties.java
+++ b/java/util/Properties.java
@@ -47,6 +47,25 @@ import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.DefaultHandler2;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Element;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
/**
* A set of persistent properties, which can be saved or loaded from a stream.
* A property list may also contain defaults, searched if the main list
@@ -579,4 +598,299 @@ label = Name:\\u0020</pre>
head = key;
}
}
+
+ /**
+ * <p>
+ * Encodes the properties as an XML file using the UTF-8 encoding.
+ * The format of the XML file matches the DTD
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ * </p>
+ * <p>
+ * Invoking this method provides the same behaviour as invoking
+ * <code>storeToXML(os, comment, "UTF-8")</code>.
+ * </p>
+ *
+ * @param os the stream to output to.
+ * @param comment a comment to include at the top of the XML file, or
+ * <code>null</code> if one is not required.
+ * @throws IOException if the serialization fails.
+ * @throws NullPointerException if <code>os</code> is null.
+ * @since 1.5
+ */
+ public void storeToXML(OutputStream os, String comment)
+ throws IOException
+ {
+ storeToXML(os, comment, "UTF-8");
+ }
+
+ /**
+ * <p>
+ * Encodes the properties as an XML file using the supplied encoding.
+ * The format of the XML file matches the DTD
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ * </p>
+ *
+ * @param os the stream to output to.
+ * @param comment a comment to include at the top of the XML file, or
+ * <code>null</code> if one is not required.
+ * @param encoding the encoding to use for the XML output.
+ * @throws IOException if the serialization fails.
+ * @throws NullPointerException if <code>os</code> or <code>encoding</code>
+ * is null.
+ * @since 1.5
+ */
+ public void storeToXML(OutputStream os, String comment, String encoding)
+ throws IOException
+ {
+ if (os == null)
+ throw new NullPointerException("Null output stream supplied.");
+ if (encoding == null)
+ throw new NullPointerException("Null encoding supplied.");
+ try
+ {
+ DOMImplementationRegistry registry =
+ DOMImplementationRegistry.newInstance();
+ DOMImplementation domImpl = registry.getDOMImplementation("LS 3.0");
+ DocumentType doctype =
+ domImpl.createDocumentType("properties", null,
+ "http://java.sun.com/dtd/properties.dtd");
+ Document doc = domImpl.createDocument(null, "properties", doctype);
+ Element root = doc.getDocumentElement();
+ if (comment != null)
+ {
+ Element commentElement = doc.createElement("comment");
+ commentElement.appendChild(doc.createTextNode(comment));
+ root.appendChild(commentElement);
+ }
+ Iterator iterator = entrySet().iterator();
+ while (iterator.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ Element entryElement = doc.createElement("entry");
+ entryElement.setAttribute("key", (String) entry.getKey());
+ entryElement.appendChild(doc.createTextNode((String)
+ entry.getValue()));
+ root.appendChild(entryElement);
+ }
+ DOMImplementationLS loadAndSave = (DOMImplementationLS) domImpl;
+ LSSerializer serializer = loadAndSave.createLSSerializer();
+ LSOutput output = loadAndSave.createLSOutput();
+ output.setByteStream(os);
+ output.setEncoding(encoding);
+ serializer.write(doc, output);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw (IOException)
+ new IOException("The XML classes could not be found.").initCause(e);
+ }
+ catch (InstantiationException e)
+ {
+ throw (IOException)
+ new IOException("The XML classes could not be instantiated.")
+ .initCause(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw (IOException)
+ new IOException("The XML classes could not be accessed.")
+ .initCause(e);
+ }
+ }
+
+ /**
+ * <p>
+ * Decodes the contents of the supplied <code>InputStream</code> as
+ * an XML file, which represents a set of properties. The format of
+ * the XML file must match the DTD
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ * </p>
+ *
+ * @param in the input stream from which to receive the XML data.
+ * @throws IOException if an I/O error occurs in reading the input data.
+ * @throws InvalidPropertiesFormatException if the input data does not
+ * constitute an XML properties
+ * file.
+ * @throws NullPointerException if <code>in</code> is null.
+ * @since 1.5
+ */
+ public void loadFromXML(InputStream in)
+ throws IOException, InvalidPropertiesFormatException
+ {
+ if (in == null)
+ throw new NullPointerException("Null input stream supplied.");
+ try
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false); /* Don't use the URI */
+ XMLReader parser = factory.newSAXParser().getXMLReader();
+ PropertiesHandler handler = new PropertiesHandler();
+ parser.setContentHandler(handler);
+ parser.setProperty("http://xml.org/sax/properties/lexical-handler",
+ handler);
+ parser.parse(new InputSource(in));
+ }
+ catch (SAXException e)
+ {
+ throw (InvalidPropertiesFormatException)
+ new InvalidPropertiesFormatException("Error in parsing XML.").
+ initCause(e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw (IOException)
+ new IOException("An XML parser could not be found.").
+ initCause(e);
+ }
+ }
+
+ /**
+ * This class deals with the parsing of XML using
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+ private class PropertiesHandler
+ extends DefaultHandler2
+ {
+
+ /**
+ * The current key.
+ */
+ private String key;
+
+ /**
+ * The current value.
+ */
+ private String value;
+
+ /**
+ * A flag to check whether a valid DTD declaration has been seen.
+ */
+ private boolean dtdDeclSeen;
+
+ /**
+ * Constructs a new Properties handler.
+ */
+ public PropertiesHandler()
+ {
+ key = null;
+ value = null;
+ dtdDeclSeen = false;
+ }
+
+ /**
+ * <p>
+ * Captures the start of the DTD declarations, if they exist.
+ * A valid properties file must declare the following doctype:
+ * </p>
+ * <p>
+ * <code>!DOCTYPE properties SYSTEM
+ * "http://java.sun.com/dtd/properties.dtd"</code>
+ * </p>
+ *
+ * @param name the name of the document type.
+ * @param publicId the public identifier that was declared, or
+ * null if there wasn't one.
+ * @param systemId the system identifier that was declared, or
+ * null if there wasn't one.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException
+ {
+ if (name.equals("properties") &&
+ publicId == null &&
+ systemId.equals("http://java.sun.com/dtd/properties.dtd"))
+ {
+ dtdDeclSeen = true;
+ }
+ else
+ throw new SAXException("Invalid DTD declaration: " + name);
+ }
+
+ /**
+ * Captures the start of an XML element.
+ *
+ * @param uri the namespace URI.
+ * @param localName the local name of the element inside the namespace.
+ * @param qName the local name qualified with the namespace URI.
+ * @param attributes the attributes of this element.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void startElement(String uri, String localName,
+ String qName, Attributes attributes)
+ throws SAXException
+ {
+ if (qName.equals("entry"))
+ {
+ int index = attributes.getIndex("key");
+ if (index != -1)
+ key = attributes.getValue(index);
+ }
+ else if (qName.equals("comment") || qName.equals("properties"))
+ {
+ /* Ignore it */
+ }
+ else
+ throw new SAXException("Invalid tag: " + qName);
+ }
+
+ /**
+ * Captures characters within an XML element.
+ *
+ * @param ch the array of characters.
+ * @param start the start index of the characters to use.
+ * @param length the number of characters to use from the start index on.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void characters(char[] ch, int start, int length)
+ throws SAXException
+ {
+ if (key != null)
+ value = new String(ch,start,length);
+ }
+
+ /**
+ * Captures the end of an XML element.
+ *
+ * @param uri the namespace URI.
+ * @param localName the local name of the element inside the namespace.
+ * @param qName the local name qualified with the namespace URI.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void endElement(String uri, String localName,
+ String qName)
+ throws SAXException
+ {
+ if (qName.equals("entry"))
+ {
+ if (value == null)
+ value = "";
+ setProperty(key, value);
+ key = null;
+ value = null;
+ }
+ }
+
+ /**
+ * Captures the end of the XML document. If a DTD declaration has
+ * not been seen, the document is erroneous and an exception is thrown.
+ *
+ * @throws SAXException if the correct DTD declaration didn't appear.
+ */
+ public void endDocument()
+ throws SAXException
+ {
+ if (!dtdDeclSeen)
+ throw new SAXException("No appropriate DTD declaration was seen.");
+ }
+
+ } // class PropertiesHandler
+
} // class Properties
diff --git a/java/util/ResourceBundle.java b/java/util/ResourceBundle.java
index 070f9e945..a607a8ec8 100644
--- a/java/util/ResourceBundle.java
+++ b/java/util/ResourceBundle.java
@@ -419,7 +419,11 @@ public abstract class ResourceBundle
}
}
- throw new MissingResourceException("Bundle " + baseName + " not found",
+ throw new MissingResourceException("Bundle " + baseName
+ + " not found for locale "
+ + locale
+ + " by classloader "
+ + classLoader,
baseName, "");
}
diff --git a/java/util/SimpleTimeZone.java b/java/util/SimpleTimeZone.java
index 76292996f..0bda44c33 100644
--- a/java/util/SimpleTimeZone.java
+++ b/java/util/SimpleTimeZone.java
@@ -468,6 +468,7 @@ public class SimpleTimeZone extends TimeZone
* @param dayOfWeek The day of week where daylight savings start.
* @param time The time in milliseconds standard time where daylight
* savings start.
+ * @exception IllegalArgumentException if parameters are out of range.
* @see SimpleTimeZone
*/
public void setStartRule(int month, int day, int dayOfWeek, int time)
diff --git a/javax/imageio/IIOException.java b/javax/imageio/IIOException.java
index 8f8dd0344..b281db1b0 100644
--- a/javax/imageio/IIOException.java
+++ b/javax/imageio/IIOException.java
@@ -39,8 +39,9 @@ package javax.imageio;
import java.io.IOException;
-
/**
+ * A runtime exception to indicate image reading and writing failures.
+ *
* @author Michael Koch (konqueror@gmx.de)
*/
public class IIOException extends IOException
diff --git a/javax/imageio/IIOImage.java b/javax/imageio/IIOImage.java
index 651c9baaa..0d9874762 100644
--- a/javax/imageio/IIOImage.java
+++ b/javax/imageio/IIOImage.java
@@ -45,13 +45,53 @@ import java.util.List;
import javax.imageio.metadata.IIOMetadata;
+/**
+ * IIOImage is a container class for components of an image file that
+ * stores image data, image metadata and thumbnails.
+ *
+ * The image data can be either a RenderedImage or a Raster but not
+ * both. Image readers that produce IIOImages will always produce
+ * BufferedImages from the RenderedImage field. Image writers that
+ * accept IIOImages will always accept RenderedImages and may
+ * optionally accept Rasters.
+ *
+ * @author Thomas Fitzsimmons (fitzsim@redhat.com)
+ */
public class IIOImage
{
+ /**
+ * Image data as a RenderedImage. null if this IIOImage uses the
+ * Raster representation.
+ */
protected RenderedImage image;
+
+ /**
+ * Image metadata.
+ */
protected IIOMetadata metadata;
+
+ /**
+ * Image data as a Raster. null if this IIOImage uses the
+ * RenderedImage representation.
+ */
protected Raster raster;
+
+ /**
+ * A list of BufferedImage thumbnails of this image.
+ */
+ // for 1.5 these lists are List<? extends BufferedImage>
protected List thumbnails;
-
+
+ /**
+ * Construct an IIOImage containing raster image data, thumbnails
+ * and metadata.
+ *
+ * @param raster image data
+ * @param thumbnails a list of BufferedImage thumbnails or null
+ * @param metadata image metadata or null
+ *
+ * @exception IllegalArgumentException if raster is null
+ */
public IIOImage (Raster raster, List thumbnails, IIOMetadata metadata)
{
if (raster == null)
@@ -62,6 +102,16 @@ public class IIOImage
this.metadata = metadata;
}
+ /**
+ * Construct an IIOImage containing rendered image data, thumbnails
+ * and metadata.
+ *
+ * @param image rendered image data
+ * @param thumbnails a list of BufferedImage thumbnails or null
+ * @param metadata image metadata or null
+ *
+ * @exception IllegalArgumentException if image is null
+ */
public IIOImage (RenderedImage image, List thumbnails, IIOMetadata metadata)
{
if (image == null)
@@ -72,46 +122,111 @@ public class IIOImage
this.metadata = metadata;
}
+ /**
+ * Retrieve the image metadata or null if there is no metadata
+ * associated with this IIOImage.
+ *
+ * @return image metadata or null
+ */
public IIOMetadata getMetadata()
{
return metadata;
}
+ /**
+ * Retrieve the number of thumbnails in this IIOImage.
+ *
+ * @return the number of thumbnails
+ */
public int getNumThumbnails()
{
- return thumbnails.size();
+ return thumbnails == null ? 0 : thumbnails.size();
}
+ /**
+ * Retrieve the raster image data stored in this IIOImage or null if
+ * this image stores data using the RenderedImage representation.
+ *
+ * @return the raster image data or null
+ */
public Raster getRaster()
{
return raster;
}
+ /**
+ * Retrieve the rendered image data stored in this IIOImage or null
+ * if this image stores data using the Raster representation.
+ *
+ * @return the rendered image data or null
+ */
public RenderedImage getRenderedImage()
{
return image;
}
+ /**
+ * Retrieve the thumbnail stored at the specified index in the
+ * thumbnails list.
+ *
+ * @param index the index of the thumbnail to retrieve
+ *
+ * @return the buffered image thumbnail
+ *
+ * @exception IndexOutOfBoundsException if index is out-of-bounds
+ * @exception ClassCastException if the object returned from the
+ * thumbnails list is not a BufferedImage
+ */
public BufferedImage getThumbnail (int index)
{
+ // This throws a ClassCastException if the returned object is not
+ // a BufferedImage or an IndexOutOfBoundsException if index is
+ // out-of-bounds.
return (BufferedImage) thumbnails.get (index);
}
+ /**
+ * Retrieve the list of thumbnails or null if there are no
+ * thumbnails associated with this IIOImage. The returned reference
+ * can be used to update the thumbnails list.
+ *
+ * @return a list of thumbnails or null
+ */
public List getThumbnails()
{
return thumbnails;
}
+ /**
+ * Check whether this IIOImage stores its image data as a Raster or
+ * as a RenderedImage.
+ *
+ * @return true if this IIOImage uses the Raster representation,
+ * false if it uses the RenderedImage representation.
+ */
public boolean hasRaster()
{
return raster != null;
}
+ /**
+ * Set this IIOImage's metadata.
+ *
+ * @param metadata the image metadata
+ */
public void setMetadata (IIOMetadata metadata)
{
this.metadata = metadata;
}
+ /**
+ * Set the raster data for this image. This disposes of any
+ * existing rendered image data stored in this IIOImage.
+ *
+ * @param raster the image raster data
+ *
+ * @exception IllegalArgumentException if raster is null
+ */
public void setRaster (Raster raster)
{
if (raster == null)
@@ -121,6 +236,14 @@ public class IIOImage
this.raster = raster;
}
+ /**
+ * Set the rendered image data for this image. This disposes of any
+ * existing raster data stored in this IIOImage.
+ *
+ * @param image the rendered image data
+ *
+ * @exception IllegalArgumentException if image is null
+ */
public void setRenderedImage (RenderedImage image)
{
if (image == null)
@@ -130,9 +253,15 @@ public class IIOImage
this.raster = null;
}
+ /**
+ * Set the list of thumbnails for this IIOImage to a new list of
+ * BufferedImages or to null. Any existing thumbnails list is
+ * disposed.
+ *
+ * @param thumbnails a new list of thumbnails or null
+ */
public void setThumbnails (List thumbnails)
{
this.thumbnails = thumbnails;
}
-
-} // class IIOParam
+}
diff --git a/javax/imageio/IIOParam.java b/javax/imageio/IIOParam.java
index 01f616605..f6460b4e7 100644
--- a/javax/imageio/IIOParam.java
+++ b/javax/imageio/IIOParam.java
@@ -42,97 +42,317 @@ import java.awt.Point;
import java.awt.Rectangle;
/**
+ * An IIOParam stores parameters used when encoding or decoding image
+ * streams. ImageReadParam and ImageWriteParam extend this abstract
+ * base class.
+ *
+ * IIOParams allow control over how source pixels converted into
+ * destination pixels. This conversion can take place between a
+ * stream and in-memory image data, when an image reader is doing the
+ * conversion, or a writer can be doing the conversion from an
+ * in-memory source to a stream destination.
+ *
+ * An image reader can be restricted to only read from a given region;
+ * likewise a writer can be restricted to only write output to a given
+ * region.
+ *
+ * For image readers and writers, IIOParam supports image pixelation
+ * -- where the input image is approximated by the output image using
+ * larger-sized pixel blocks. For example: FIXME
+ *
+ * IIOParams can control how pixels are combined into larger blocks
+ * using sub-sampling matrices. For example: FIXME
+ *
+ * They can also control which source bands are read and written; this
+ * example reads the RGBA (red, green, blue, transparency) data from a
+ * PNG image and outputs just the red and transparency bands: FIXME
+ *
+ * @author Thomas Fitzsimmons (fitzsim@redhat.com)
* @author Michael Koch (konqueror@gmx.de)
*/
public abstract class IIOParam
{
- protected IIOParamController controller;
- protected IIOParamController defaultController;
+ /**
+ * The controller called by this IIOParam to retrieve parameters.
+ */
+ protected IIOParamController controller = null;
+
+ /**
+ * The default controller called by this IIOParam to retrieve
+ * parameters.
+ */
+ protected IIOParamController defaultController = null;
+
+ /**
+ * The offset in the destination where the upper-left
+ * decoded/encoded pixel should be located.
+ */
protected Point destinationOffset = new Point(0, 0);
- protected ImageTypeSpecifier destinationType;
- protected int[] sourceBands;
- protected Rectangle sourceRegion;
- protected int sourceXSubsampling;
- protected int sourceYSubsampling;
- protected int subsamplingXOffset;
- protected int subsamplingYOffset;
/**
- * Initializes an <code>IIOParam</code> object.
+ * Sets the output colour type when writing or the destination image
+ * type when reading.
+ */
+ protected ImageTypeSpecifier destinationType = null;
+
+ /**
+ * An array indicating which source bands will be used or null.
+ */
+ protected int[] sourceBands = null;
+
+ /**
+ * The source pixel region or null.
+ */
+ protected Rectangle sourceRegion = null;
+
+ /**
+ * Sample every sourceXSubsampling'th pixel in the source image when
+ * pixelating the destination image in the horizontal direction.
+ */
+ protected int sourceXSubsampling = 1;
+
+ /**
+ * Sample every sourceYSubsampling'th pixel in the source image when
+ * pixelating the destination image in the vertical direction.
+ */
+ protected int sourceYSubsampling = 1;
+
+ /**
+ * Start sampling at this horizontal offset within the source region
+ * when pixelating the destination image in the horizontal
+ * direction.
+ */
+ protected int subsamplingXOffset = 0;
+
+ /**
+ * Start sampling at this vertical offset within the source region
+ * when pixelating the destination image in the vertical direction.
+ */
+ protected int subsamplingYOffset = 0;
+
+ /**
+ * Indicates whether or not the controller has been explicitly set
+ * to null.
+ */
+ private boolean no_controller = false;
+
+ /**
+ * Constructs an IIOParam object.
*/
protected IIOParam()
{
- // Do nothing here.
}
+ /**
+ * Activates the parameter controller by calling its activate method
+ * and passing it this IIOParam. A true return value indicates that
+ * this IIOParam's values are ready for the next read or write
+ * operation. A return value of false means that this IIOParam's
+ * values have not been affected because the controller operations
+ * were cancelled.
+ *
+ * @return true if parameters were successfully set, false if
+ * parameters were not changed
+ */
public boolean activateController()
{
if (controller == null)
- return false;
-
- return controller.activate(this);
+ {
+ if (defaultController == null || no_controller)
+ return false;
+ else
+ return defaultController.activate (this);
+ }
+ else
+ return controller.activate(this);
}
-
+
+ /**
+ * Retrieve the currently set controller if one has been set, or the
+ * default controller, or null if the controller has been explicitly
+ * set to null.
+ *
+ * @return the currently used controller or null
+ */
public IIOParamController getController()
{
- return controller;
+ return controller == null ?
+ (no_controller ? null : defaultController) : controller;
}
+ /**
+ * Retrieve the default controller regardless of whether or not a
+ * non-default controller has been set. The default controller may
+ * be null.
+ *
+ * @return the default controller or null
+ */
public IIOParamController getDefaultController()
{
return defaultController;
}
+ /**
+ * Retrieve the offset in the destination where the upper-left
+ * decoded/encoded pixel should be located. (0, 0) by default.
+ *
+ * @return the destination offset
+ */
public Point getDestinationOffset()
{
return destinationOffset;
}
+ /**
+ * Retrieve the currently set image-type specifier or null if none
+ * has been set.
+ *
+ * @return the current image-type specifier or null
+ */
public ImageTypeSpecifier getDestinationType()
{
return destinationType;
}
+ /**
+ * Retrieve the current source band values or null if source band
+ * values have not been set.
+ *
+ * The returned array is a copy of this IIOParam's source band
+ * array.
+ *
+ * @return the current set of source band values or null
+ */
public int[] getSourceBands()
{
- return sourceBands;
+ if (sourceBands == null)
+ return null;
+
+ int[] sourceBandsCopy = new int[sourceBands.length];
+ System.arraycopy (sourceBands, 0, sourceBandsCopy, 0, sourceBands.length);
+ return sourceBandsCopy;
}
+ /**
+ * Retrieve the source rectangle from which pixels should be read or
+ * null if no source region has been set.
+ *
+ * @return the current source region or null
+ */
public Rectangle getSourceRegion()
{
return sourceRegion;
}
+ /**
+ * Retrieve the number of pixel columns to advance before taking a
+ * pixel sample.
+ *
+ * @return the horizontal sub-sampling interval
+ */
public int getSourceXSubsampling()
{
return sourceXSubsampling;
}
+ /**
+ * Retrieve the number of pixel rows to advance before taking a
+ * pixel sample.
+ *
+ * @return the vertical sub-sampling interval
+ */
public int getSourceYSubsampling()
{
return sourceYSubsampling;
}
+ /**
+ * Retrieve the number of pixel columns to advance before taking any
+ * pixel samples.
+ *
+ * @return the horizontal sub-sampling offset
+ */
public int getSubsamplingXOffset()
{
return subsamplingXOffset;
}
-
+
+ /**
+ * Retrieve the number of pixel rows to advance before taking any
+ * pixel samples.
+ *
+ * @return the vertical sub-sampling offset
+ */
public int getSubsamplingYOffset()
{
return subsamplingYOffset;
}
+ /**
+ * Check if a non-null controller is currently available.
+ *
+ * @return true if getController returns a non-null value, false if
+ * getController returns null
+ */
public boolean hasController()
{
return getController() != null;
}
+ /**
+ * Sets the controller for this IIOParam. This is the controller
+ * that will be activated when activateController is called. The
+ * argument controller overrides this IIOParam's default controller.
+ * If the argument is null then no controller will be set, not even
+ * the default one. To reset the default controller call
+ * setController(getDefaultController()).
+ *
+ * @param controller the controller to set or null
+ */
public void setController(IIOParamController controller)
{
- this.controller = controller;
+ if (controller == defaultController)
+ {
+ this.controller = null;
+ no_controller = false;
+ }
+ else
+ {
+ no_controller = (controller == null);
+ this.controller = controller;
+ }
}
+ /**
+ * Set the destination image type.
+ *
+ * If this value is set on an image reader then its read method will
+ * return a new BufferedImage of the specified destination type. In
+ * this case any destination image set using setDestination() is
+ * ignored.
+ *
+ * If this is set on an image writer then the destination type
+ * affects only the colour model of the destination image. The
+ * destination type's SampleModel is ignored. The destination
+ * type's ColorModel will override the source image's colour model.
+ *
+ * @param destinationType the sample and colour models of the
+ * destination image
+ */
+ public void setDestinationType (ImageTypeSpecifier destinationType)
+ {
+ this.destinationType = destinationType;
+ }
+
+ /**
+ * Specify the destination pixel offset. Image writers are only
+ * affected by this setting when ImageWriter.replacePixels is called
+ * in which case the offset is into the region of pixels being
+ * changed.
+ *
+ * @param destinationOffset the offset where pixel writing should
+ * begin
+ */
public void setDestinationOffset(Point destinationOffset)
{
if (destinationOffset == null)
@@ -141,11 +361,43 @@ public abstract class IIOParam
this.destinationOffset = destinationOffset;
}
+ /**
+ * Set the indices of the source bands to be used. Duplicate
+ * indices are not allowed. A value of null means use all source
+ * bands. The argument array is copied and stored, so subsequent
+ * updates to it will not be reflected in this IIOParam.
+ *
+ * @param sourceBands the array of source bands to use
+ */
public void setSourceBands(int[] sourceBands)
{
- this.sourceBands = sourceBands;
+ int[] sourceBandsCopy = new int[sourceBands.length];
+ System.arraycopy (sourceBands, 0, sourceBandsCopy, 0, sourceBands.length);
+ this.sourceBands = sourceBandsCopy;
}
+ /**
+ * Set the source region from which to read. The number of pixels
+ * sampled from the source region depends on the source sub-sampling
+ * settings. If the combination of this sourceRegion and the
+ * current sub-sampling settings would result in no pixels being
+ * sampled then an IllegalStateException will be thrown.
+ *
+ * The source region is specified in the source image coordinate
+ * system which has point (0, 0) at the top-left and increases down
+ * and to the right. The argument source region is clipped to the
+ * image boundaries at read-time.
+ *
+ * A null argument sets the source region to null meaning that the
+ * whole image should be read.
+ *
+ * @param sourceRegion the rectangular source region
+ *
+ * @exception IllegalArgumentException if sourceRegion has width or
+ * height <= 0 or x or y < 0
+ * @exception IllegalStateException if the given sourceRegion and
+ * the current sampling settings would produce zero samples
+ */
public void setSourceRegion(Rectangle sourceRegion)
{
if (sourceRegion != null
@@ -154,15 +406,83 @@ public abstract class IIOParam
|| sourceRegion.width <= 0
|| sourceRegion.height <= 0))
throw new IllegalArgumentException("illegal source region");
-
- // FIXME: Throw IllegalStateException.
+
+ if (sourceRegion != null)
+ {
+ int num_rows =
+ (sourceRegion.height - subsamplingYOffset + sourceYSubsampling - 1)
+ / sourceYSubsampling;
+
+ int num_columns =
+ (sourceRegion.width - subsamplingXOffset + sourceXSubsampling - 1)
+ / sourceXSubsampling;
+
+ if (num_rows <= 0 || num_columns <= 0)
+ throw new IllegalStateException("zero pixels in source region");
+ }
this.sourceRegion = sourceRegion;
}
+ /**
+ * Set the source sampling intervals and offsets. Every
+ * sourceXSubsampling'th pixel horizontally and
+ * sourceYSubsampling'th pixel vertically will be sampled. Sampling
+ * will being a the subsamplingXOffset'th column and the
+ * subsamplingYOffset'th row.
+ *
+ * Horizontally, the number of sampled pixels will be:
+ *
+ * floor((width - subsamplingXOffset + sourceXSubsampling - 1) / sourceXSubsampling)
+ *
+ * Vertically:
+ *
+ * floor((height - subsamplingYOffset + sourceYSubsampling - 1) / sourceYSubsampling)
+ *
+ * If the current source region setting is such that the given
+ * sub-sampling arguments would produce zero pixel samples, an
+ * IllegalStateException is thrown.
+ *
+ * The offset parameters can be used to make source regions overlap
+ * when tiling across an image. This can eliminate seams and
+ * better-tile images whose width or height is not a multiple of the
+ * sampling interval.
+ *
+ * @param sourceXSubsampling the horizontal sampling interval
+ * @param sourceYSubsampling the vertical sampling interval
+ * @param subsamplingXOffset the horizontal offset of the initial
+ * sample
+ * @param subsamplingYOffset the vertical offset of the initial
+ * sample
+ *
+ * @exception IllegalArgumentException if either subsamplingXOffset
+ * or subsamplingYOffset is < 0
+ * @exception IllegalStateException if the current source region
+ * combined with the given sub-sampling parameters would produce
+ * zero pixel samples
+ */
public void setSourceSubsampling(int sourceXSubsampling, int sourceYSubsampling,
int subsamplingXOffset, int subsamplingYOffset)
{
+ if (subsamplingXOffset < 0 || subsamplingYOffset < 0)
+ throw new IllegalArgumentException("subsampling offset < 0");
+
+ if (sourceRegion != null)
+ {
+ int num_rows =
+ (sourceRegion.height - subsamplingYOffset + sourceYSubsampling - 1)
+ / sourceYSubsampling;
+
+ int num_columns =
+ (sourceRegion.width - subsamplingXOffset + sourceXSubsampling - 1)
+ / sourceXSubsampling;
+
+ if (num_rows <= 0 || num_columns <= 0)
+ throw new IllegalStateException("subsampling parameters would"
+ + " produce zero pixel samples"
+ + " in source region");
+ }
+
this.sourceXSubsampling = sourceXSubsampling;
this.sourceYSubsampling = sourceYSubsampling;
this.subsamplingXOffset = subsamplingXOffset;
diff --git a/javax/imageio/IIOParamController.java b/javax/imageio/IIOParamController.java
index 125520e73..0ee54df40 100644
--- a/javax/imageio/IIOParamController.java
+++ b/javax/imageio/IIOParamController.java
@@ -39,12 +39,23 @@ exception statement from your version. */
package javax.imageio;
/**
+ * An interface to set image parameters. An IIOParamController may be
+ * a GUI component, a database reader, command-line parser or any
+ * other means of getting parameter settings. For exampe, a dialog
+ * box could implement IIOParamController to allow a user to adjust
+ * JPEG compression levels.
+ *
+ * The activate method should always behave modally; it should only
+ * return when the action has been either cancelled or completed.
+ *
* @author Michael Koch (konqueror@gmx.de)
*/
public interface IIOParamController
{
/**
- * Activates the controller.
+ * Activates the controller. A return value of false should mean
+ * that no changes were made to param. A return value of true
+ * should mean that the image is ready to be read or written.
*
* @param param the <code>IIOParam</code> to be modified
*
diff --git a/javax/imageio/ImageIO.java b/javax/imageio/ImageIO.java
index 95c7c3251..3ea7e8585 100644
--- a/javax/imageio/ImageIO.java
+++ b/javax/imageio/ImageIO.java
@@ -52,7 +52,10 @@ import java.util.Collections;
import java.util.Iterator;
import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ImageInputStreamSpi;
+import javax.imageio.spi.ImageOutputStreamSpi;
import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.ImageTranscoderSpi;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.spi.ServiceRegistry;
import javax.imageio.stream.ImageInputStream;
@@ -60,12 +63,18 @@ import javax.imageio.stream.ImageOutputStream;
import javax.imageio.stream.MemoryCacheImageInputStream;
import javax.imageio.stream.MemoryCacheImageOutputStream;
+/**
+ * An uninstantiable class that provides static methods for locating
+ * and using image readers and writers.
+ */
public final class ImageIO
{
/**
- * This class isn't intended to be instantiated.
+ * Construct an ImageIO. Private since ImageIO is not instantiable.
*/
- private ImageIO() {}
+ private ImageIO()
+ {
+ }
private static final class ReaderFormatFilter implements ServiceRegistry.Filter
{
@@ -117,6 +126,35 @@ public final class ImageIO
}
}
+ private static final class ReaderObjectFilter implements ServiceRegistry.Filter
+ {
+ private Object object;
+
+ public ReaderObjectFilter(Object object)
+ {
+ this.object = object;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageReaderSpi)
+ {
+ ImageReaderSpi spi = (ImageReaderSpi) provider;
+
+ try
+ {
+ if (spi.canDecodeInput(object))
+ return true;
+ }
+ catch (IOException e)
+ {
+ // Return false in this case
+ }
+ }
+ return false;
+ }
+ }
+
private static final class ReaderSuffixFilter implements ServiceRegistry.Filter
{
private String fileSuffix;
@@ -217,6 +255,66 @@ public final class ImageIO
}
}
+ private static final class WriterObjectFilter implements ServiceRegistry.Filter
+ {
+ private ImageTypeSpecifier type;
+ private String formatName;
+
+ public WriterObjectFilter(ImageTypeSpecifier type,
+ String formatName)
+ {
+ this.type = type;
+ this.formatName = formatName;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageWriterSpi)
+ {
+ ImageWriterSpi spi = (ImageWriterSpi) provider;
+
+ if (spi.canEncodeImage(type))
+ {
+ String[] formatNames = spi.getFormatNames();
+ for (int i = formatNames.length - 1; i >= 0; --i)
+ if (formatName.equals(formatNames[i]))
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ private static final class TranscoderFilter implements ServiceRegistry.Filter
+ {
+ private ImageReader reader;
+ private ImageWriter writer;
+
+ public TranscoderFilter(ImageReader reader,
+ ImageWriter writer)
+ {
+ this.reader = reader;
+ this.writer = writer;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageTranscoderSpi)
+ {
+ ImageTranscoderSpi spi = (ImageTranscoderSpi) provider;
+
+ if (spi.getReaderServiceProviderName().equals
+ (reader.getOriginatingProvider().getClass().getName())
+ && spi.getWriterServiceProviderName().equals
+ (writer.getOriginatingProvider().getClass().getName()))
+ return true;
+ }
+
+ return false;
+ }
+ }
+
private static final class ImageReaderIterator implements Iterator
{
Iterator it;
@@ -318,11 +416,26 @@ public final class ImageIO
}
}
+ /**
+ * Retrieve the current cache directory.
+ *
+ * @return the current cache directory or null if none is set.
+ */
public static File getCacheDirectory()
{
return cacheDirectory;
}
+ /**
+ * Retrieve an iterator over all registered readers for the given
+ * format.
+ *
+ * @param formatName an infomal format name (e.g. "jpeg" or "bmp")
+ *
+ * @return an iterator over a collection of image readers
+ *
+ * @exception IllegalArgumentException if formatName is null
+ */
public static Iterator getImageReadersByFormatName(String formatName)
{
if (formatName == null)
@@ -333,6 +446,17 @@ public final class ImageIO
formatName);
}
+ /**
+ * Retrieve an iterator over all registered readers for the given
+ * MIME type.
+ *
+ * @param MIMEType a MIME specification for an image type
+ * (e.g. "image/jpeg" or "image/x-bmp")
+ *
+ * @return an iterator over a collection of image readers
+ *
+ * @exception IllegalArgumentException if MIMEType is null
+ */
public static Iterator getImageReadersByMIMEType(String MIMEType)
{
if (MIMEType == null)
@@ -343,6 +467,16 @@ public final class ImageIO
MIMEType);
}
+ /**
+ * Retrieve an iterator over all registered readers for the given
+ * file suffix.
+ *
+ * @param fileSuffix an image file suffix (e.g. "jpg" or "bmp")
+ *
+ * @return an iterator over a collection of image readers
+ *
+ * @exception IllegalArgumentException if fileSuffix is null
+ */
public static Iterator getImageReadersBySuffix(String fileSuffix)
{
if (fileSuffix == null)
@@ -353,6 +487,16 @@ public final class ImageIO
fileSuffix);
}
+ /**
+ * Retrieve an iterator over all registered writers for the given
+ * format.
+ *
+ * @param formatName an infomal format name (e.g. "jpeg" or "bmp")
+ *
+ * @return an iterator over a collection of image writers
+ *
+ * @exception IllegalArgumentException if formatName is null
+ */
public static Iterator getImageWritersByFormatName(String formatName)
{
if (formatName == null)
@@ -363,6 +507,17 @@ public final class ImageIO
formatName);
}
+ /**
+ * Retrieve an iterator over all registered writers for the given
+ * MIME type.
+ *
+ * @param MIMEType a MIME specification for an image type
+ * (e.g. "image/jpeg" or "image/x-bmp")
+ *
+ * @return an iterator over a collection of image writers
+ *
+ * @exception IllegalArgumentException if MIMEType is null
+ */
public static Iterator getImageWritersByMIMEType(String MIMEType)
{
if (MIMEType == null)
@@ -373,6 +528,16 @@ public final class ImageIO
MIMEType);
}
+ /**
+ * Retrieve an iterator over all registered writers for the given
+ * file suffix.
+ *
+ * @param fileSuffix an image file suffix (e.g. "jpg" or "bmp")
+ *
+ * @return an iterator over a collection of image writers
+ *
+ * @exception IllegalArgumentException if fileSuffix is null
+ */
public static Iterator getImageWritersBySuffix(String fileSuffix)
{
if (fileSuffix == null)
@@ -383,6 +548,12 @@ public final class ImageIO
fileSuffix);
}
+ /**
+ * Retrieve all the informal format names supported by the
+ * collection of registered image readers.
+ *
+ * @return an array of format names
+ */
public static String[] getReaderFormatNames()
{
try
@@ -408,6 +579,12 @@ public final class ImageIO
}
}
+ /**
+ * Retrieve all the MIME types supported by the collection of
+ * registered image readers.
+ *
+ * @return an array of MIME types
+ */
public static String[] getReaderMIMETypes()
{
try
@@ -438,11 +615,23 @@ public final class ImageIO
return IIORegistry.getDefaultInstance();
}
+ /**
+ * Check whether or not an on-disk cache is used for image input and
+ * output streams.
+ *
+ * @return true if an on-disk cache is available, false otherwise
+ */
public static boolean getUseCache()
{
return useCache;
}
+ /**
+ * Retrieve all the informal format names supported by the
+ * collection of registered image writers.
+ *
+ * @return an array of format names
+ */
public static String[] getWriterFormatNames()
{
try
@@ -468,6 +657,12 @@ public final class ImageIO
}
}
+ /**
+ * Retrieve all the MIME types supported by the collection of
+ * registered image writers.
+ *
+ * @return an array of MIME types
+ */
public static String[] getWriterMIMETypes()
{
try
@@ -502,8 +697,20 @@ public final class ImageIO
IIORegistry.getDefaultInstance().registerApplicationClasspathSpis();
}
+ /**
+ * Set the directory to be used for caching image data. A null
+ * argument means to use the default system temporary directory.
+ * This cache directory is only used if getUseCache returns true.
+ *
+ * @param cacheDirectory the directory where image data should be
+ * cached
+ *
+ * @exception IllegalArgumentException if cacheDirectory is not a
+ * directory
+ */
public static void setCacheDirectory(File cacheDirectory)
{
+ // FIXME: add SecurityManager call
if (cacheDirectory != null)
{
if (!cacheDirectory.isDirectory())
@@ -515,37 +722,98 @@ public final class ImageIO
ImageIO.cacheDirectory = cacheDirectory;
}
+ /**
+ * Control whether or not an on-disk cache is used. This cache is
+ * used to store input or output data from an image data stream when
+ * data in the stream needs to be re-processed.
+ *
+ * If useCache is false the cache will be stored in memory. Doing
+ * so eliminates file creation and deletion overhead. The default
+ * is to use an on-disk cache.
+ *
+ * @param useCache true to use an on-disk cache, false otherwise
+ */
public static void setUseCache(boolean useCache)
{
ImageIO.useCache = useCache;
}
- /*
- * "Standard" simplified entry points.
+ /**
+ * Write an image to a file using a registered writer that supports
+ * the given format, overwriting the file if it already exists.
+ *
+ * @param im the image data to write
+ * @param formatName an informal description of the output format
+ * @param output the file to which the image will be written
+ *
+ * @return false if no registered writer supports the given format,
+ * true otherwise
+ *
+ * @exception IllegalArgumentException if any argument is null
+ * @exception IOException if a writing error occurs
*/
-
public static boolean write(RenderedImage im,
String formatName,
File output)
throws IOException
{
+ if (im == null || formatName == null || output == null)
+ throw new IllegalArgumentException ("null argument");
+
return write(im, formatName, new FileOutputStream(output));
}
+ /**
+ * Write an image to an output stream using a registered writer that
+ * supports the given format.
+ *
+ * @param im the image data to write
+ * @param formatName an informal description of the output format
+ * @param output the output stream to which the image will be
+ * written
+ *
+ * @return false if no registered writer supports the given format,
+ * true otherwise
+ *
+ * @exception IllegalArgumentException if any argument is null
+ * @exception IOException if a writing error occurs
+ */
public static boolean write(RenderedImage im,
String formatName,
OutputStream output)
throws IOException
{
+ if (im == null || formatName == null || output == null)
+ throw new IllegalArgumentException ("null argument");
+
return write(im, formatName, new MemoryCacheImageOutputStream(output));
}
-
-
+
+ /**
+ * Write an image to an ImageOutputStream using a registered writer
+ * that supports the given format. Image data is written starting
+ * at the ImageOutputStream's current stream pointer, overwriting
+ * any existing data.
+ *
+ * @param im the image data to write
+ * @param formatName an informal description of the output format
+ * @param output the image output stream to which the image will be
+ * written
+ *
+ * @return false if no registered writer supports the given format,
+ * true otherwise
+ *
+ * @exception IllegalArgumentException if any argument is null
+ * @exception IOException if a writing error occurs
+ */
public static boolean write(RenderedImage im,
String formatName,
ImageOutputStream output)
throws IOException
{
+ if (im == null || formatName == null || output == null)
+ throw new IllegalArgumentException ("null argument");
+
Iterator writers = getImageWritersByFormatName(formatName);
IIOImage img = new IIOImage(im, null, null);
while (writers.hasNext())
@@ -567,9 +835,27 @@ public final class ImageIO
return false;
}
+ /**
+ * Create a buffered image from an image input stream. An image
+ * reader that supports the given image data is automatically
+ * selected from the collection of registered readers. If no
+ * registered reader can handle the input format, null is returned.
+ *
+ * @param stream the image input stream from which to read image
+ * data
+ *
+ * @return a new buffered image created from the given image data,
+ * or null
+ *
+ * @exception IllegalArgumentException if stream is null
+ * @exception IOException if a reading error occurs
+ */
public static BufferedImage read(ImageInputStream stream)
throws IOException
{
+ if (stream == null)
+ throw new IllegalArgumentException("null argument");
+
Iterator providers = getRegistry().getServiceProviders(ImageReaderSpi.class, true);
while (providers.hasNext())
{
@@ -583,23 +869,330 @@ public final class ImageIO
}
return null;
}
-
+
+ /**
+ * Create a buffered image from a URL. An image reader that
+ * supports the given image data is automatically selected from the
+ * collection of registered readers. If no registered reader can
+ * handle the input format, null is returned.
+ *
+ * The image data will be cached in the current cache directory if
+ * caching is enabled.
+ *
+ * This method does not locate readers that read data directly from
+ * a URL. To locate such readers manually, use IIORegistry and
+ * ImageReaderSpi.
+ *
+ * @param input the URL from which to retrieve the image file
+ *
+ * @return a new buffered image created from the given image URL, or
+ * null
+ *
+ * @exception IllegalArgumentException if input is null
+ * @exception IOException if a reading error occurs
+ */
public static BufferedImage read(URL input)
throws IOException
{
+ if (input == null)
+ throw new IllegalArgumentException("null argument");
+
return read(input.openStream());
}
+ /**
+ * Create a buffered image from an input stream. An image reader
+ * that supports the given image data is automatically selected from
+ * the collection of registered readers. If no registered reader
+ * can handle the input format, null is returned.
+ *
+ * The image data will be cached in the current cache directory if
+ * caching is enabled.
+ *
+ * This method does not locate readers that read data directly from
+ * an input stream. To locate such readers manually, use
+ * IIORegistry and ImageReaderSpi.
+ *
+ * @param input the input stream from which to read the image data
+ *
+ * @return a new buffered image created from the given input stream,
+ * or null
+ *
+ * @exception IllegalArgumentException if input is null
+ * @exception IOException if a reading error occurs
+ */
public static BufferedImage read(InputStream input)
throws IOException
{
+ if (input == null)
+ throw new IllegalArgumentException("null argument");
+
return read(new MemoryCacheImageInputStream(input));
}
+ /**
+ * Create a buffered image from a file. An image reader that
+ * supports the given image data is automatically selected from the
+ * collection of registered readers. If no registered reader can
+ * handle the input format, null is returned.
+ *
+ * The image data will be cached in the current cache directory if
+ * caching is enabled.
+ *
+ * This method does not locate readers that read data directly from
+ * a file. To locate such readers manually, use IIORegistry and
+ * ImageReaderSpi.
+ *
+ * @param input the file from which to read image data
+ *
+ * @return a new buffered image created from the given image file,
+ * or null
+ *
+ * @exception IllegalArgumentException if input is null
+ * @exception IOException if a reading error occurs
+ */
public static BufferedImage read(File input)
throws IOException
{
+ if (input == null)
+ throw new IllegalArgumentException("null argument");
+
return read(new FileInputStream(input));
}
+ /**
+ * Create an image input stream from the given object. The
+ * collection of ImageInputStreamSpis registered with the
+ * IIORegistry is searched for an image input stream that can take
+ * input from the given object. null is returned if no such SPI is
+ * registered.
+ *
+ * The image data will be cached in the current cache directory if
+ * caching is enabled.
+ *
+ * @param input an object from which to read image data
+ *
+ * @return an ImageInputStream that can read data from input, or
+ * null
+ *
+ * @exception IllegalArgumentException if input is null
+ * @exception IOException if caching is required but not enabled
+ */
+ public static ImageInputStream createImageInputStream (Object input)
+ throws IOException
+ {
+ if (input == null)
+ throw new IllegalArgumentException ("null argument");
+
+ Iterator spis = getRegistry().getServiceProviders
+ (ImageInputStreamSpi.class, true);
+
+ ImageInputStreamSpi foundSpi = null;
+
+ while(spis.hasNext())
+ {
+ ImageInputStreamSpi spi = (ImageInputStreamSpi) spis.next();
+
+ if (input.getClass().equals(spi.getInputClass()))
+ {
+ foundSpi = spi;
+ break;
+ }
+ }
+
+ return foundSpi == null ? null :
+ foundSpi.createInputStreamInstance (input,
+ getUseCache(),
+ getCacheDirectory());
+ }
+
+ /**
+ * Create an image output stream from the given object. The
+ * collection of ImageOutputStreamSpis registered with the
+ * IIORegistry is searched for an image output stream that can send
+ * output to the given object. null is returned if no such SPI is
+ * registered.
+ *
+ * The image data will be cached in the current cache directory if
+ * caching is enabled.
+ *
+ * @param input an object to which to write image data
+ *
+ * @return an ImageOutputStream that can send data to output, or
+ * null
+ *
+ * @exception IllegalArgumentException if output is null
+ * @exception IOException if caching is required but not enabled
+ */
+ public static ImageOutputStream createImageOutputStream (Object output)
+ throws IOException
+ {
+ if (output == null)
+ throw new IllegalArgumentException ("null argument");
+
+ Iterator spis = getRegistry().getServiceProviders
+ (ImageOutputStreamSpi.class, true);
+
+ ImageOutputStreamSpi foundSpi = null;
+
+ while(spis.hasNext())
+ {
+ ImageOutputStreamSpi spi = (ImageOutputStreamSpi) spis.next();
+
+ if (output.getClass().equals(spi.getOutputClass()))
+ {
+ foundSpi = spi;
+ break;
+ }
+ }
+
+ return foundSpi == null ? null :
+ foundSpi.createOutputStreamInstance (output,
+ getUseCache(),
+ getCacheDirectory());
+ }
+
+ /**
+ * Retrieve an image reader corresponding to an image writer, or
+ * null if writer is not registered or if no corresponding reader is
+ * registered.
+ *
+ * @param writer a registered image writer
+ *
+ * @return an image reader corresponding to writer, or null
+ *
+ * @exception IllegalArgumentException if writer is null
+ */
+ public static ImageReader getImageReader (ImageWriter writer)
+ {
+ if (writer == null)
+ throw new IllegalArgumentException ("null argument");
+
+ ImageWriterSpi spi = (ImageWriterSpi) getRegistry()
+ .getServiceProviderByClass(writer.getClass());
+
+ String[] readerSpiNames = spi.getImageReaderSpiNames();
+
+ ImageReader r = null;
+
+ if (readerSpiNames != null)
+ {
+ try
+ {
+ Class readerClass = Class.forName (readerSpiNames[0]);
+ r = (ImageReader) readerClass.newInstance ();
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Retrieve an iterator over the collection of registered image
+ * readers that support reading data from the given object.
+ *
+ * @param input the object for which to retrieve image readers
+ *
+ * @return an iterator over a collection of image readers
+ */
+ public static Iterator getImageReaders (Object input)
+ {
+ if (input == null)
+ throw new IllegalArgumentException ("null argument");
+
+ return getRegistry().getServiceProviders (ImageReaderSpi.class,
+ new ReaderObjectFilter(input),
+ true);
+ }
+
+ /**
+ * Retrieve an iterator over the collection of registered image
+ * writers that support writing images of the given type and in the
+ * given format.
+ *
+ * @param type the output image's colour and sample models
+ * @param formatName the output image format
+ *
+ * @return an iterator over a collection of image writers
+ */
+ public static Iterator getImageWriters (ImageTypeSpecifier type,
+ String formatName)
+ {
+ if (type == null || formatName == null)
+ throw new IllegalArgumentException ("null argument");
+
+ return getRegistry().getServiceProviders (ImageWriterSpi.class,
+ new WriterObjectFilter(type,
+ formatName),
+ true);
+ }
+
+ /**
+ * Retrieve an image writer corresponding to an image reader, or
+ * null if reader is not registered or if no corresponding writer is
+ * registered. This method is useful for preserving metadata
+ * without needing to understand its format, since the returned
+ * writer will be able to write, unchanged, the metadata passed to
+ * it by the reader.
+ *
+ * @param reader a registered image reader
+ *
+ * @return an image writer corresponding to reader, or null
+ *
+ * @exception IllegalArgumentException if reader is null
+ */
+ public static ImageWriter getImageWriter (ImageReader reader)
+ {
+ if (reader == null)
+ throw new IllegalArgumentException ("null argument");
+
+ ImageReaderSpi spi = (ImageReaderSpi) getRegistry()
+ .getServiceProviderByClass(reader.getClass());
+
+ String[] writerSpiNames = spi.getImageWriterSpiNames();
+
+ ImageWriter w = null;
+
+ if (writerSpiNames != null)
+ {
+ try
+ {
+ Class writerClass = Class.forName (writerSpiNames[0]);
+ w = (ImageWriter) writerClass.newInstance ();
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ }
+ return w;
+ }
+
+ /**
+ * Retrieve an iterator over a collection of image transcoders that
+ * support transcoding from the given image reader's metadata format
+ * to the given writer's metadata format.
+ *
+ * @param reader an image reader
+ * @param writer an image writer
+ *
+ * @return an iterator over a collection of image transcoders
+ *
+ * @exception IllegalArgumentException if either reader or writer is
+ * null
+ */
+ public static Iterator getImageTranscoders (ImageReader reader,
+ ImageWriter writer)
+ {
+ if (reader == null || writer == null)
+ throw new IllegalArgumentException ("null argument");
+
+ return getRegistry().getServiceProviders (ImageTranscoderSpi.class,
+ new TranscoderFilter (reader,
+ writer),
+ true);
+ }
}
diff --git a/javax/imageio/ImageReadParam.java b/javax/imageio/ImageReadParam.java
index 889fe6cc9..b2680f6b1 100644
--- a/javax/imageio/ImageReadParam.java
+++ b/javax/imageio/ImageReadParam.java
@@ -42,6 +42,8 @@ import java.awt.Dimension;
import java.awt.image.BufferedImage;
/**
+ * DOCUMENT ME
+ *
* @author Michel Koch (konqueror@gmx.de)
*/
public class ImageReadParam extends IIOParam
diff --git a/javax/imageio/ImageReader.java b/javax/imageio/ImageReader.java
index fdf692bd2..cdd77d52b 100644
--- a/javax/imageio/ImageReader.java
+++ b/javax/imageio/ImageReader.java
@@ -1,5 +1,5 @@
/* ImageReader.java -- Decodes raster images.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,13 +38,19 @@ exception statement from your version. */
package javax.imageio;
+import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import java.util.Set;
import javax.imageio.event.IIOReadProgressListener;
import javax.imageio.event.IIOReadUpdateListener;
@@ -53,82 +59,233 @@ import javax.imageio.metadata.IIOMetadata;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
+/**
+ * A class for decoding images within the ImageIO framework.
+ *
+ * An ImageReader for a given format is instantiated by an
+ * ImageReaderSpi for that format. ImageReaderSpis are registered
+ * with the IIORegistry.
+ *
+ * The ImageReader API supports reading animated images that may have
+ * multiple frames; to support such images many methods take an index
+ * parameter.
+ *
+ * Images may also be read in multiple passes, where each successive
+ * pass increases the level of detail in the destination image.
+ */
public abstract class ImageReader
{
private boolean aborted;
-
- protected Locale[] availableLocales;
- protected boolean ignoreMetadata;
- protected Object input;
- protected Locale locale;
- protected int minIndex;
- protected ImageReaderSpi originatingProvider;
- protected List progressListeners = new ArrayList();
- protected boolean seekForwardOnly;
- protected List updateListeners = new ArrayList();
- protected List warningListeners = new ArrayList();
- protected List warningLocales = new ArrayList();
+ /**
+ * All locales available for localization of warning messages, or
+ * null if localization is not supported.
+ */
+ protected Locale[] availableLocales = null;
+
+ /**
+ * true if the input source does not require metadata to be read,
+ * false otherwise.
+ */
+ protected boolean ignoreMetadata = false;
+
+ /**
+ * An ImageInputStream from which image data is read.
+ */
+ protected Object input = null;
+
+ /**
+ * The current locale used to localize warning messages, or null if
+ * no locale has been set.
+ */
+ protected Locale locale = null;
+
+ /**
+ * The minimum index at which data can be read. Constantly 0 if
+ * seekForwardOnly is false, always increasing if seekForwardOnly is
+ * true.
+ */
+ protected int minIndex = 0;
+
+ /**
+ * The image reader SPI that instantiated this reader.
+ */
+ protected ImageReaderSpi originatingProvider = null;
+
+ /**
+ * A list of installed progress listeners. Initially null, meaning
+ * no installed listeners.
+ */
+ protected List progressListeners = null;
+
+ /**
+ * true if this reader should only read data further ahead in the
+ * stream than its current location. false if it can read backwards
+ * in the stream. If this is true then caching can be avoided.
+ */
+ protected boolean seekForwardOnly = false;
+
+ /**
+ * A list of installed update listeners. Initially null, meaning no
+ * installed listeners.
+ */
+ protected List updateListeners = null;
+
+ /**
+ * A list of installed warning listeners. Initially null, meaning
+ * no installed listeners.
+ */
+ protected List warningListeners = null;
+
+ /**
+ * A list of warning locales corresponding with the list of
+ * installed warning listeners. Initially null, meaning no locales.
+ */
+ protected List warningLocales = null;
+
+ /**
+ * Construct an image reader.
+ *
+ * @param originatingProvider the provider that is constructing this
+ * image reader, or null
+ */
protected ImageReader(ImageReaderSpi originatingProvider)
{
this.originatingProvider = originatingProvider;
}
+ /**
+ * Request that reading be aborted. The unread contents of the
+ * image will be undefined.
+ *
+ * Readers should clear the abort flag before starting a read
+ * operation, then poll it periodically during the read operation.
+ */
public void abort()
{
aborted = true;
}
+ /**
+ * Check if the abort flag is set.
+ *
+ * @return true if the current read operation should be aborted,
+ * false otherwise
+ */
protected boolean abortRequested()
{
return aborted;
}
+ /**
+ * Install a read progress listener. This method will return
+ * immediately if listener is null.
+ *
+ * @param listener a read progress listener or null
+ */
public void addIIOReadProgressListener(IIOReadProgressListener listener)
{
if (listener == null)
return;
-
- progressListeners.add(listener);
+ if (progressListeners == null)
+ progressListeners = new ArrayList ();
+ progressListeners.add(listener);
}
+ /**
+ * Install a read update listener. This method will return
+ * immediately if listener is null.
+ *
+ * @param listener a read update listener
+ */
public void addIIOReadUpdateListener(IIOReadUpdateListener listener)
{
if (listener == null)
return;
-
- updateListeners.add(listener);
+ if (updateListeners == null)
+ updateListeners = new ArrayList ();
+ updateListeners.add(listener);
}
-
+
+ /**
+ * Install a read warning listener. This method will return
+ * immediately if listener is null. Warning messages sent to this
+ * listener will be localized using the current locale. If the
+ * current locale is null then this reader will select a sensible
+ * default.
+ *
+ * @param listener a read warning listener
+ */
public void addIIOReadWarningListener(IIOReadWarningListener listener)
{
if (listener == null)
return;
-
- warningListeners.add(listener);
+ if (warningListeners == null)
+ warningListeners = new ArrayList ();
+ warningListeners.add(listener);
}
+ /**
+ * Check if this reader can handle raster data. Determines whether
+ * or not readRaster and readTileRaster throw
+ * UnsupportedOperationException.
+ *
+ * @return true if this reader supports raster data, false if not
+ */
public boolean canReadRaster()
{
return false;
}
+ /**
+ * Clear the abort flag.
+ */
protected void clearAbortRequest()
{
aborted = false;
}
-
+
+ /**
+ * Releases any resources allocated to this object. Subsequent
+ * calls to methods on this object will produce undefined results.
+ *
+ * The default implementation does nothing; subclasses should use
+ * this method ensure that native resources are released.
+ */
public void dispose()
{
// The default implementation does nothing.
}
-
+
+ /**
+ * Returns the aspect ratio of this image, the ration of its width
+ * to its height. The aspect ratio is useful when resizing an image
+ * while keeping its proportions constant.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return the image's aspect ratio
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public float getAspectRatio(int imageIndex)
throws IOException
{
+ if (input == null)
+ throw new IllegalStateException("input is null");
+
return (float) (getWidth(imageIndex) / getHeight(imageIndex));
}
+ /**
+ * Retrieve the available locales. Return null if no locales are
+ * available or a clone of availableLocales.
+ *
+ * @return an array of locales or null
+ */
public Locale[] getAvailableLocales()
{
if (availableLocales == null)
@@ -137,26 +294,107 @@ public abstract class ImageReader
return (Locale[]) availableLocales.clone();
}
+ /**
+ * Retrieve the default read parameters for this reader's image
+ * format.
+ *
+ * The default implementation returns new ImageReadParam().
+ *
+ * @return image reading parameters
+ */
public ImageReadParam getDefaultReadParam()
{
return new ImageReadParam();
}
+ /**
+ * Retrieve the format of the input source.
+ *
+ * @return the input source format name
+ *
+ * @exception IOException if a read error occurs
+ */
public String getFormatName()
throws IOException
{
return originatingProvider.getFormatNames()[0];
}
+ /**
+ * Get the height of the input image in pixels. If the input image
+ * is resizable then a default height is returned.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return the height of the input image
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public abstract int getHeight(int imageIndex)
throws IOException;
+ /**
+ * Get the metadata associated with this image. If the reader is
+ * set to ignore metadata or does not support reading metadata, or
+ * if no metadata is available then null is returned.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return a metadata object, or null
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public abstract IIOMetadata getImageMetadata(int imageIndex)
throws IOException;
+ /**
+ * Get an iterator over the collection of image types into which
+ * this reader can decode image data. This method is guaranteed to
+ * return at least one valid image type specifier.
+ *
+ * The elements of the iterator should be ordered; the first element
+ * should be the most appropriate image type for this decoder,
+ * followed by the second-most appropriate, and so on.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return an iterator over a collection of image type specifiers
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public abstract Iterator getImageTypes(int imageIndex)
throws IOException;
+ /**
+ * Set the input source to the given object, specify whether this
+ * reader should be allowed to read input from the data stream more
+ * than once, and specify whether this reader should ignore metadata
+ * in the input stream. The input source must be set before many
+ * methods can be called on this reader. (see all ImageReader
+ * methods that throw IllegalStateException). If input is null then
+ * the current input source will be removed.
+ *
+ * Unless this reader has direct access with imaging hardware, input
+ * should be an ImageInputStream.
+ *
+ * @param input the input source object
+ * @param seekForwardOnly true if this reader should be allowed to
+ * read input from the data stream more than once, false otherwise
+ * @param ignoreMetadata true if this reader should ignore metadata
+ * associated with the input source, false otherwise
+ *
+ * @exception IllegalArgumentException if input is not a valid input
+ * source for this reader and is not an ImageInputStream
+ */
public void setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
@@ -183,358 +421,960 @@ public abstract class ImageReader
this.minIndex = 0;
}
+ /**
+ * Set the input source to the given object and specify whether this
+ * reader should be allowed to read input from the data stream more
+ * than once. The input source must be set before many methods can
+ * be called on this reader. (see all ImageReader methods that throw
+ * IllegalStateException). If input is null then the current input
+ * source will be removed.
+ *
+ * @param input the input source object
+ * @param seekForwardOnly true if this reader should be allowed to
+ * read input from the data stream more than once, false otherwise
+ *
+ * @exception IllegalArgumentException if input is not a valid input
+ * source for this reader and is not an ImageInputStream
+ */
public void setInput(Object in, boolean seekForwardOnly)
{
setInput(in, seekForwardOnly, false);
}
- public void setInput(Object in)
+ /**
+ * Set the input source to the given object. The input source must
+ * be set before many methods can be called on this reader. (see all
+ * ImageReader methods that throw IllegalStateException). If input
+ * is null then the current input source will be removed.
+ *
+ * @param input the input source object
+ *
+ * @exception IllegalArgumentException if input is not a valid input
+ * source for this reader and is not an ImageInputStream
+ */
+ public void setInput(Object input)
{
- setInput(in, false, false);
+ setInput(input, false, false);
}
+ /**
+ * Get this reader's image input source. null is returned if the
+ * image source has not been set.
+ *
+ * @return an image input source object, or null
+ */
public Object getInput()
{
return input;
}
+ /**
+ * Get this reader's locale. null is returned if the locale has not
+ * been set.
+ *
+ * @return this reader's locale, or null
+ */
public Locale getLocale()
{
return locale;
}
+ /**
+ * Return the number of images available from the image input
+ * source, not including thumbnails. This method will return 1
+ * unless this reader is reading an animated image.
+ *
+ * Certain multi-image formats do not encode the total number of
+ * images. When reading images in those formats it may be necessary
+ * to repeatedly call read, incrementing the image index at each
+ * call, until an IndexOutOfBoundsException is thrown.
+ *
+ * The allowSearch parameter determines whether all images must be
+ * available at all times. When allowSearch is false, getNumImages
+ * will return -1 if the total number of images is unknown.
+ * Otherwise this method returns the number of images.
+ *
+ * @param allowSearch true if all images should be available at
+ * once, false otherwise
+ *
+ * @return -1 if allowSearch is false and the total number of images
+ * is currently unknown, or the number of images
+ *
+ * @exception IllegalStateException if input has not been set, or if
+ * seekForwardOnly is true
+ * @exception IOException if a read error occurs
+ */
public abstract int getNumImages(boolean allowSearch)
throws IOException;
+ /**
+ * Get the number of thumbnails associated with an image.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return the number of thumbnails associated with this image
+ */
public int getNumThumbnails(int imageIndex)
throws IOException
{
return 0;
}
+ /**
+ * Get the ImageReaderSpi that created this reader or null.
+ *
+ * @return an ImageReaderSpi, or null
+ */
public ImageReaderSpi getOriginatingProvider()
{
return originatingProvider;
}
+ /**
+ * Get the metadata associated with the image being read. If the
+ * reader is set to ignore metadata or does not support reading
+ * metadata, or if no metadata is available then null is returned.
+ * This method returns metadata associated with the entirety of the
+ * image data, whereas getImageMetadata(int) returns metadata
+ * associated with a frame within a multi-image data stream.
+ *
+ * @return metadata associated with the image being read, or null
+ *
+ * @exception IOException if a read error occurs
+ */
public abstract IIOMetadata getStreamMetadata()
throws IOException;
+ /**
+ * Get the height of a thumbnail image.
+ *
+ * @param imageIndex the frame index
+ * @param thumbnailIndex the thumbnail index
+ *
+ * @return the height of the thumbnail image
+ *
+ * @exception UnsupportedOperationException if this reader does not
+ * support thumbnails
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if either index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public int getThumbnailHeight(int imageIndex, int thumbnailIndex)
throws IOException
{
return readThumbnail(imageIndex, thumbnailIndex).getHeight();
}
+ /**
+ * Get the width of a thumbnail image.
+ *
+ * @param imageIndex the frame index
+ * @param thumbnailIndex the thumbnail index
+ *
+ * @return the width of the thumbnail image
+ *
+ * @exception UnsupportedOperationException if this reader does not
+ * support thumbnails
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if either index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public int getThumbnailWidth(int imageIndex, int thumbnailIndex)
throws IOException
{
return readThumbnail(imageIndex, thumbnailIndex).getWidth();
}
+ /**
+ * Get the X coordinate in pixels of the top-left corner of the
+ * first tile in this image.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return the X coordinate of this image's first tile
+ *
+ * @exception IllegalStateException if input is needed but the input
+ * source is not set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public int getTileGridXOffset(int imageIndex)
throws IOException
{
return 0;
}
+ /**
+ * Get the Y coordinate in pixels of the top-left corner of the
+ * first tile in this image.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return the Y coordinate of this image's first tile
+ *
+ * @exception IllegalStateException if input is needed but the input
+ * source is not set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public int getTileGridYOffset(int imageIndex)
throws IOException
{
return 0;
}
+ /**
+ * Get the height of an image tile.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return the tile height for the given image
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public int getTileHeight(int imageIndex)
throws IOException
{
return getHeight(imageIndex);
}
+ /**
+ * Get the width of an image tile.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return the tile width for the given image
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public int getTileWidth(int imageIndex)
throws IOException
{
return getWidth(imageIndex);
}
+ /**
+ * Get the width of the input image in pixels. If the input image
+ * is resizable then a default width is returned.
+ *
+ * @param imageIndex the image's index
+ *
+ * @return the width of the input image
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public abstract int getWidth(int imageIndex)
throws IOException;
+ /**
+ * Check whether or not the given image has thumbnails associated
+ * with it.
+ *
+ * @return true if the given image has thumbnails, false otherwise
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public boolean hasThumbnails(int imageIndex)
throws IOException
{
return getNumThumbnails(imageIndex) > 0;
}
+ /**
+ * Check if this image reader ignores metadata. This method simply
+ * returns the value of ignoreMetadata.
+ *
+ * @return true if metadata is being ignored, false otherwise
+ */
public boolean isIgnoringMetadata()
{
return ignoreMetadata;
}
+ /**
+ * Check if the given image is sub-divided into equal-sized
+ * non-overlapping pixel rectangles.
+ *
+ * A reader may expose tiling in the underlying format, hide it, or
+ * simulate tiling even if the underlying format is not tiled.
+ *
+ * @return true if the given image is tiled, false otherwise
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public boolean isImageTiled(int imageIndex)
throws IOException
{
return false;
}
+ /**
+ * Check if all pixels in this image are readily accessible. This
+ * method should return false for compressed formats. The return
+ * value is a hint as to the efficiency of certain image reader
+ * operations.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return true if random pixel access is fast, false otherwise
+ *
+ * @exception IllegalStateException if input is null and it is
+ * needed to determine the return value
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds but the frame data must be accessed to determine
+ * the return value
+ * @exception IOException if a read error occurs
+ */
public boolean isRandomAccessEasy(int imageIndex)
throws IOException
{
return false;
}
+ /**
+ * Check if this image reader may only seek forward within the input
+ * stream.
+ *
+ * @return true if this reader may only seek forward, false
+ * otherwise
+ */
public boolean isSeekForwardOnly()
{
return seekForwardOnly;
}
+ /**
+ * Notifies all installed read progress listeners that image loading
+ * has completed by calling their imageComplete methods.
+ */
protected void processImageComplete()
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.imageComplete (this);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.imageComplete (this);
+ }
}
}
+ /**
+ * Notifies all installed read progress listeners that a certain
+ * percentage of the image has been loaded, by calling their
+ * imageProgress methods.
+ *
+ * @param percentageDone the percentage of image data that has been
+ * loaded
+ */
protected void processImageProgress(float percentageDone)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.imageProgress(this, percentageDone);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.imageProgress(this, percentageDone);
+ }
}
}
-
+ /**
+ * Notifies all installed read progress listeners, by calling their
+ * imageStarted methods, that image loading has started on the given
+ * image.
+ *
+ * @param imageIndex the frame index of the image that has started
+ * loading
+ */
protected void processImageStarted(int imageIndex)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.imageStarted(this, imageIndex);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.imageStarted(this, imageIndex);
+ }
}
}
+ /**
+ * Notifies all installed read update listeners, by calling their
+ * imageUpdate methods, that the set of samples has changed.
+ *
+ * @param image the buffered image that is being updated
+ * @param minX the X coordinate of the top-left pixel in this pass
+ * @param minY the Y coordinate of the top-left pixel in this pass
+ * @param width the total width of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param height the total height of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param periodX the horizontal sample interval
+ * @param periodY the vertical sample interval
+ * @param bands the affected bands in the destination
+ */
protected void processImageUpdate(BufferedImage image, int minX, int minY,
int width, int height, int periodX,
int periodY, int[] bands)
{
- Iterator it = updateListeners.iterator();
-
- while (it.hasNext())
+ if (updateListeners != null)
{
- IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
- listener.imageUpdate(this, image, minX, minY, width, height, periodX,
- periodY, bands);
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.imageUpdate(this, image, minX, minY, width, height,
+ periodX, periodY, bands);
+ }
}
}
+ /**
+ * Notifies all installed update progress listeners, by calling
+ * their passComplete methods, that a progressive pass has
+ * completed.
+ *
+ * @param image the image that has being updated
+ */
protected void processPassComplete(BufferedImage image)
{
- Iterator it = updateListeners.iterator();
-
- while (it.hasNext())
+ if (updateListeners != null)
{
- IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
- listener.passComplete(this, image);
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.passComplete(this, image);
+ }
}
}
+ /**
+ * Notifies all installed read update listeners, by calling their
+ * passStarted methods, that a new pass has begun.
+ *
+ * @param image the buffered image that is being updated
+ * @param pass the current pass number
+ * @param minPass the pass at which decoding will begin
+ * @param maxPass the pass at which decoding will end
+ * @param minX the X coordinate of the top-left pixel in this pass
+ * @param minY the Y coordinate of the top-left pixel in this pass
+ * @param width the total width of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param height the total height of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param periodX the horizontal sample interval
+ * @param periodY the vertical sample interval
+ * @param bands the affected bands in the destination
+ */
protected void processPassStarted(BufferedImage image, int pass, int minPass,
int maxPass, int minX, int minY,
int periodX, int periodY, int[] bands)
{
- Iterator it = updateListeners.iterator();
-
- while (it.hasNext())
+ if (updateListeners != null)
{
- IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
- listener.passStarted(this, image, pass, minPass, maxPass, minX, minY,
- periodX, periodY, bands);
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.passStarted(this, image, pass, minPass, maxPass, minX,
+ minY, periodX, periodY, bands);
+ }
}
}
+ /**
+ * Notifies all installed read progress listeners that image loading
+ * has been aborted by calling their readAborted methods.
+ */
protected void processReadAborted()
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.readAborted(this);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.readAborted(this);
+ }
}
}
-
+ /**
+ * Notifies all installed read progress listeners, by calling their
+ * sequenceComplete methods, that a sequence of images has completed
+ * loading.
+ */
protected void processSequenceComplete()
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.sequenceComplete(this);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.sequenceComplete(this);
+ }
}
}
+ /**
+ * Notifies all installed read progress listeners, by calling their
+ * sequenceStarted methods, a sequence of images has started
+ * loading.
+ *
+ * @param minIndex the index of the first image in the sequence
+ */
protected void processSequenceStarted(int minIndex)
{
- Iterator it = progressListeners.iterator();
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.sequenceStarted(this, minIndex);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.sequenceStarted(this, minIndex);
+ }
}
}
+ /**
+ * Notifies all installed read progress listeners, by calling their
+ * thumbnailComplete methods, that a thumbnail has completed
+ * loading.
+ */
protected void processThumbnailComplete()
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.thumbnailComplete(this);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.thumbnailComplete(this);
+ }
}
}
+ /**
+ * Notifies all installed update progress listeners, by calling
+ * their thumbnailPassComplete methods, that a progressive pass has
+ * completed on a thumbnail.
+ *
+ * @param thumbnail the thumbnail that has being updated
+ */
protected void processThumbnailPassComplete(BufferedImage thumbnail)
{
- Iterator it = updateListeners.iterator();
-
- while (it.hasNext())
+ if (updateListeners != null)
{
- IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
- listener.thumbnailPassComplete(this, thumbnail);
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.thumbnailPassComplete(this, thumbnail);
+ }
}
}
+ /**
+ * Notifies all installed read update listeners, by calling their
+ * thumbnailPassStarted methods, that a new pass has begun.
+ *
+ * @param thumbnail the thumbnail that is being updated
+ * @param pass the current pass number
+ * @param minPass the pass at which decoding will begin
+ * @param maxPass the pass at which decoding will end
+ * @param minX the X coordinate of the top-left pixel in this pass
+ * @param minY the Y coordinate of the top-left pixel in this pass
+ * @param width the total width of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param height the total height of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param periodX the horizontal sample interval
+ * @param periodY the vertical sample interval
+ * @param bands the affected bands in the destination
+ */
protected void processThumbnailPassStarted(BufferedImage thumbnail, int pass,
int minPass, int maxPass, int minX,
int minY, int periodX, int periodY,
int[] bands)
{
- Iterator it = updateListeners.iterator();
-
- while (it.hasNext())
+ if (updateListeners != null)
{
- IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
- listener.thumbnailPassStarted(this, thumbnail, pass, minPass, maxPass,
- minX, minY, periodX, periodY, bands);
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.thumbnailPassStarted(this, thumbnail, pass, minPass,
+ maxPass, minX, minY, periodX,
+ periodY, bands);
+ }
}
}
-
+
+ /**
+ * Notifies all installed read progress listeners that a certain
+ * percentage of a thumbnail has been loaded, by calling their
+ * thumbnailProgress methods.
+ *
+ * @param percentageDone the percentage of thumbnail data that has
+ * been loaded
+ */
protected void processThumbnailProgress(float percentageDone)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.thumbnailProgress(this, percentageDone);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.thumbnailProgress(this, percentageDone);
+ }
}
}
+ /**
+ * Notifies all installed read progress listeners, by calling their
+ * imageStarted methods, that thumbnail loading has started on the
+ * given thumbnail of the given image.
+ *
+ * @param imageIndex the frame index of the image one of who's
+ * thumbnails has started loading
+ * @param thumbnailIndex the index of the thumbnail that has started
+ * loading
+ */
protected void processThumbnailStarted(int imageIndex, int thumbnailIndex)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
- listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener =
+ (IIOReadProgressListener) it.next();
+ listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+ }
}
}
+ /**
+ * Notifies all installed read update listeners, by calling their
+ * thumbnailUpdate methods, that the set of samples has changed.
+ *
+ * @param image the buffered image that is being updated
+ * @param minX the X coordinate of the top-left pixel in this pass
+ * @param minY the Y coordinate of the top-left pixel in this pass
+ * @param width the total width of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param height the total height of the rectangle covered by this
+ * pass, including skipped pixels
+ * @param periodX the horizontal sample interval
+ * @param periodY the vertical sample interval
+ * @param bands the affected bands in the destination
+ */
protected void processThumbnailUpdate(BufferedImage image, int minX, int minY,
int width, int height, int periodX,
int periodY, int[] bands)
{
- Iterator it = updateListeners.iterator();
-
- while (it.hasNext())
+ if (updateListeners != null)
{
- IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
- listener.thumbnailUpdate(this, image, minX, minY, width, height,
- periodX, periodY, bands);
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.thumbnailUpdate(this, image, minX, minY, width, height,
+ periodX, periodY, bands);
+ }
}
}
+ /**
+ * Notifies all installed warning listeners, by calling their
+ * warningOccurred methods, that a warning message has been raised.
+ *
+ * @param warning the warning message
+ *
+ * @exception IllegalArgumentException if warning is null
+ */
protected void processWarningOccurred(String warning)
{
- Iterator it = warningListeners.iterator();
+ if (warning == null)
+ throw new IllegalArgumentException ("null argument");
+ if (warningListeners != null)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadWarningListener listener =
+ (IIOReadWarningListener) it.next();
+ listener.warningOccurred(this, warning);
+ }
+ }
+ }
+
+ /**
+ * Notify all installed warning listeners, by calling their
+ * warningOccurred methods, that a warning message has been raised.
+ * The warning message is retrieved from a resource bundle, using
+ * the given basename and keyword.
+ *
+ * @param baseName the basename of the resource from which to
+ * retrieve the warning message
+ * @param keyword the keyword used to retrieve the warning from the
+ * resource bundle
+ *
+ * @exception IllegalArgumentException if either baseName or keyword
+ * is null
+ * @exception IllegalArgumentException if no resource bundle is
+ * found using baseName
+ * @exception IllegalArgumentException if the given keyword produces
+ * no results from the resource bundle
+ * @exception IllegalArgumentException if the retrieved object is
+ * not a String
+ */
+ protected void processWarningOccurred(String baseName,
+ String keyword)
+ {
+ if (baseName == null || keyword == null)
+ throw new IllegalArgumentException ("null argument");
+
+ ResourceBundle b = null;
+
+ try
+ {
+ b = ResourceBundle.getBundle(baseName, getLocale());
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no resource bundle found");
+ }
+
+ Object str = null;
- while (it.hasNext())
+ try
{
- IIOReadWarningListener listener = (IIOReadWarningListener) it.next();
- listener.warningOccurred(this, warning);
+ str = b.getObject(keyword);
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no results found for keyword");
+ }
+
+ if (! (str instanceof String))
+ throw new IllegalArgumentException ("retrieved object not a String");
+
+ String warning = (String) str;
+
+ if (warningListeners != null)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadWarningListener listener =
+ (IIOReadWarningListener) it.next();
+ listener.warningOccurred(this, warning);
+ }
}
}
+ /**
+ * Read the given frame into a buffered image using the given read
+ * parameters. Listeners will be notified of image loading progress
+ * and warnings.
+ *
+ * @param imageIndex the index of the frame to read
+ * @param param the image read parameters to use when reading
+ *
+ * @return a buffered image
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public abstract BufferedImage read(int imageIndex, ImageReadParam param)
throws IOException;
+ /**
+ * Check if this reader supports reading thumbnails.
+ *
+ * @return true if this reader supports reading thumbnails, false
+ * otherwise
+ */
public boolean readerSupportsThumbnails()
{
return false;
}
+ /**
+ * Read raw raster data. The image type specifier in param is
+ * ignored but all other parameters are used. Offset parameters are
+ * translated into the raster's coordinate space. This method may
+ * be implemented by image readers that want to provide direct
+ * access to raw image data.
+ *
+ * @param imageIndex the frame index
+ * @param param the image read parameters
+ *
+ * @return a raster containing the read image data
+ *
+ * @exception UnsupportedOperationException if this reader doesn't
+ * support rasters
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
public Raster readRaster(int imageIndex, ImageReadParam param)
throws IOException
{
throw new UnsupportedOperationException();
}
+ /**
+ * Read a thumbnail.
+ *
+ * @param imageIndex the frame index
+ * @param thumbnailIndex the thumbnail index
+ *
+ * @return a buffered image of the thumbnail
+ *
+ * @exception UnsupportedOperationException if this reader doesn't
+ * support thumbnails
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if either the frame index or
+ * the thumbnail index is out-of-bounds
+ * @exception IOException if a read error occurs
+ *
+ */
public BufferedImage readThumbnail(int imageIndex, int thumbnailIndex)
throws IOException
{
throw new UnsupportedOperationException();
}
+ /**
+ * Uninstall all read progress listeners.
+ */
public void removeAllIIOReadProgressListeners()
{
- progressListeners.clear();
+ progressListeners = null;
}
+ /**
+ * Uninstall all read update listeners.
+ */
public void removeAllIIOReadUpdateListeners()
{
- updateListeners.clear();
+ updateListeners = null;
}
+ /**
+ * Uninstall all read warning listeners.
+ */
public void removeAllIIOReadWarningListeners()
{
- warningListeners.clear();
+ warningListeners = null;
}
-
+
+ /**
+ * Uninstall the given read progress listener.
+ *
+ * @param listener the listener to remove
+ */
public void removeIIOReadProgressListener(IIOReadProgressListener listener)
{
if (listener == null)
return;
-
- progressListeners.remove(listener);
+ if (progressListeners != null)
+ {
+ progressListeners.remove(listener);
+ }
}
-
+
+ /**
+ * Uninstall the given read update listener.
+ *
+ * @param listener the listener to remove
+ */
public void removeIIOReadUpdateListener(IIOReadUpdateListener listener)
{
if (listener == null)
return;
-
- updateListeners.remove(listener);
+
+ if (updateListeners != null)
+ {
+ updateListeners.remove(listener);
+ }
}
-
+
+ /**
+ * Uninstall the given read warning listener.
+ *
+ * @param listener the listener to remove
+ */
public void removeIIOReadWarningListener(IIOReadWarningListener listener)
{
if (listener == null)
return;
-
- warningListeners.remove(listener);
+ if (warningListeners != null)
+ {
+ warningListeners.remove(listener);
+ }
}
-
+
+ /**
+ * Set the current locale or use the default locale.
+ *
+ * @param locale the locale to set, or null
+ */
public void setLocale(Locale locale)
{
if (locale != null)
@@ -553,4 +1393,644 @@ public abstract class ImageReader
this.locale = locale;
}
+
+ /**
+ * Check that the given read parameters have valid source and
+ * destination band settings. If the param.getSourceBands() returns
+ * null, the array is assumed to include all band indices, 0 to
+ * numSrcBands - 1; likewise if param.getDestinationBands() returns
+ * null, it is assumed to be an array containing indices 0 to
+ * numDstBands - 1. A failure will cause this method to throw
+ * IllegalArgumentException.
+ *
+ * @param param the image parameters to check
+ * @param numSrcBands the number of input source bands
+ * @param numDstBands the number of ouput destination bands
+ *
+ * @exception IllegalArgumentException if either the given source or
+ * destination band indices are invalid
+ */
+ protected static void checkReadParamBandSettings(ImageReadParam param,
+ int numSrcBands,
+ int numDstBands)
+ {
+ int[] srcBands = param.getSourceBands();
+ int[] dstBands = param.getDestinationBands();
+ boolean lengthsDiffer = false;
+ boolean srcOOB = false;
+ boolean dstOOB = false;
+
+ if (srcBands == null)
+ {
+ if (dstBands == null)
+ {
+ if (numSrcBands != numDstBands)
+ lengthsDiffer = true;
+ }
+ else
+ {
+ if (numSrcBands != dstBands.length)
+ lengthsDiffer = true;
+
+ for (int i = 0; i < dstBands.length; i++)
+ if (dstBands[i] > numSrcBands - 1)
+ {
+ dstOOB = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (dstBands == null)
+ {
+ if (srcBands.length != numDstBands)
+ lengthsDiffer = true;
+
+ for (int i = 0; i < srcBands.length; i++)
+ if (srcBands[i] > numDstBands - 1)
+ {
+ srcOOB = true;
+ break;
+ }
+ }
+ else
+ {
+ if (srcBands.length != dstBands.length)
+ lengthsDiffer = true;
+
+ for (int i = 0; i < srcBands.length; i++)
+ if (srcBands[i] > numDstBands - 1)
+ {
+ srcOOB = true;
+ break;
+ }
+
+ for (int i = 0; i < dstBands.length; i++)
+ if (dstBands[i] > numSrcBands - 1)
+ {
+ dstOOB = true;
+ break;
+ }
+ }
+ }
+
+ if (lengthsDiffer)
+ throw new IllegalArgumentException ("array lengths differ");
+
+ if (srcOOB)
+ throw new IllegalArgumentException ("source band index"
+ + " out-of-bounds");
+
+ if (dstOOB)
+ throw new IllegalArgumentException ("destination band index"
+ + " out-of-bounds");
+ }
+
+ /**
+ * Calcluate the source and destination regions that will be read
+ * from and written to, given image parameters and/or a destination
+ * buffered image. The source region will be clipped if any of its
+ * bounds are outside the destination region. Clipping will account
+ * for subsampling and destination offsets. Likewise, the
+ * destination region is clipped to the given destination image, if
+ * it is not null, using the given image parameters, if they are not
+ * null. IllegalArgumentException is thrown if either region will
+ * contain 0 pixels after clipping.
+ *
+ * @param image read parameters, or null
+ * @param srcWidth the width of the source image
+ * @param srcHeight the height of the source image
+ * @param image the destination image, or null
+ * @param srcRegion a rectangle whose values will be set to the
+ * clipped source region
+ * @param destRegion a rectangle whose values will be set to the
+ * clipped destination region
+ *
+ * @exception IllegalArgumentException if either srcRegion or
+ * destRegion is null
+ * @exception IllegalArgumentException if either of the calculated
+ * regions is empty
+ */
+ protected static void computeRegions (ImageReadParam param,
+ int srcWidth,
+ int srcHeight,
+ BufferedImage image,
+ Rectangle srcRegion,
+ Rectangle destRegion)
+ {
+ if (srcRegion == null || destRegion == null)
+ throw new IllegalArgumentException ("null region");
+
+ if (srcWidth == 0 || srcHeight == 0)
+ throw new IllegalArgumentException ("zero-sized region");
+
+ srcRegion = getSourceRegion(param, srcWidth, srcHeight);
+ if (image != null)
+ destRegion = new Rectangle (0, 0, image.getWidth(), image.getHeight());
+ else
+ destRegion = new Rectangle (0, 0, srcWidth, srcHeight);
+
+ if (param != null)
+ {
+ Point offset = param.getDestinationOffset();
+
+ if (offset.x < 0)
+ {
+ srcRegion.x -= offset.x;
+ srcRegion.width += offset.x;
+ }
+ if (offset.y < 0)
+ {
+ srcRegion.y -= offset.y;
+ srcRegion.height += offset.y;
+ }
+
+ srcRegion.width = srcRegion.width > destRegion.width
+ ? destRegion.width : srcRegion.width;
+ srcRegion.height = srcRegion.height > destRegion.height
+ ? destRegion.height : srcRegion.height;
+
+ if (offset.x >= 0)
+ {
+ destRegion.x += offset.x;
+ destRegion.width -= offset.x;
+ }
+ if (offset.y >= 0)
+ {
+ destRegion.y += offset.y;
+ destRegion.height -= offset.y;
+ }
+ }
+
+ if (srcRegion.isEmpty() || destRegion.isEmpty())
+ throw new IllegalArgumentException ("zero-sized region");
+ }
+
+ /**
+ * Return a suitable destination buffered image. If
+ * param.getDestination() is non-null, then it is returned,
+ * otherwise a buffered image is created using
+ * param.getDestinationType() if it is non-null and also in the
+ * given imageTypes collection, or the first element of imageTypes
+ * otherwise.
+ *
+ * @param param image read parameters from which a destination image
+ * or image type is retrieved, or null
+ * @param imageTypes a collection of legal image types
+ * @param width the width of the source image
+ * @param height the height of the source image
+ *
+ * @return a suitable destination buffered image
+ *
+ * @exception IIOException if param.getDestinationType() does not
+ * return an image type in imageTypes
+ * @exception IllegalArgumentException if imageTypes is null or
+ * empty, or if a non-ImageTypeSpecifier object is retrieved from
+ * imageTypes
+ * @exception IllegalArgumentException if the resulting destination
+ * region is empty
+ * @exception IllegalArgumentException if the product of width and
+ * height is greater than Integer.MAX_VALUE
+ */
+ protected static BufferedImage getDestination (ImageReadParam param,
+ Iterator imageTypes,
+ int width,
+ int height)
+ throws IIOException
+ {
+ if (imageTypes == null || !imageTypes.hasNext())
+ throw new IllegalArgumentException ("imageTypes null or empty");
+
+ if (width < 0 || height < 0)
+ throw new IllegalArgumentException ("negative dimension");
+
+ // test for overflow
+ if (width * height < Math.min (width, height))
+ throw new IllegalArgumentException ("width * height > Integer.MAX_VALUE");
+
+ BufferedImage dest = null;
+ ImageTypeSpecifier destType = null;
+
+ if (param != null)
+ {
+ dest = param.getDestination ();
+ if (dest == null)
+ {
+ ImageTypeSpecifier type = param.getDestinationType();
+ if (type != null)
+ {
+ Iterator it = imageTypes;
+
+ while (it.hasNext())
+ {
+ Object o = it.next ();
+ if (! (o instanceof ImageTypeSpecifier))
+ throw new IllegalArgumentException ("non-ImageTypeSpecifier object");
+
+ ImageTypeSpecifier t = (ImageTypeSpecifier) o;
+ if (t.equals (type))
+ {
+ dest = t.createBufferedImage (width, height);
+ break;
+ }
+ if (destType == null)
+ throw new IIOException ("invalid destination type");
+
+ }
+ }
+ }
+ }
+ if (dest == null)
+ {
+ Rectangle srcRegion = new Rectangle ();
+ Rectangle destRegion = new Rectangle ();
+
+ computeRegions (param, width, height, null, srcRegion, destRegion);
+
+ if (destRegion.isEmpty())
+ throw new IllegalArgumentException ("destination region empty");
+
+ if (destType == null)
+ {
+ Object o = imageTypes.next();
+ if (! (o instanceof ImageTypeSpecifier))
+ throw new IllegalArgumentException ("non-ImageTypeSpecifier"
+ + " object");
+
+ dest = ((ImageTypeSpecifier) o).createBufferedImage
+ (destRegion.width, destRegion.height);
+ }
+ else
+ dest = destType.createBufferedImage
+ (destRegion.width, destRegion.height);
+ }
+ return dest;
+ }
+
+ /**
+ * Get the metadata associated with this image. If the reader is
+ * set to ignore metadata or does not support reading metadata, or
+ * if no metadata is available then null is returned.
+ *
+ * This more specific version of getImageMetadata(int) can be used
+ * to restrict metadata retrieval to specific formats and node
+ * names, which can limit the amount of data that needs to be
+ * processed.
+ *
+ * @param imageIndex the frame index
+ * @param formatName the format of metadata requested
+ * @param nodeNames a set of Strings specifiying node names to be
+ * retrieved
+ *
+ * @return a metadata object, or null
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IllegalArgumentException if formatName is null
+ * @exception IllegalArgumentException if nodeNames is null
+ * @exception IOException if a read error occurs
+ */
+ public IIOMetadata getImageMetadata (int imageIndex,
+ String formatName,
+ Set nodeNames)
+ throws IOException
+ {
+ if (formatName == null || nodeNames == null)
+ throw new IllegalArgumentException ("null argument");
+
+ return getImageMetadata (imageIndex);
+ }
+
+ /**
+ * Get the index at which the next image will be read. If
+ * seekForwardOnly is true then the returned value will increase
+ * monotonically each time an image frame is read. If
+ * seekForwardOnly is false then the returned value will always be
+ * 0.
+ *
+ * @return the current frame index
+ */
+ public int getMinIndex()
+ {
+ return minIndex;
+ }
+
+ /**
+ * Get the image type specifier that most closely represents the
+ * internal data representation used by this reader. This value
+ * should be included in the return value of getImageTypes.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return an image type specifier
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
+ public ImageTypeSpecifier getRawImageType (int imageIndex)
+ throws IOException
+ {
+ return (ImageTypeSpecifier) getImageTypes(imageIndex).next();
+ }
+
+ /**
+ * Calculate a source region based on the given source image
+ * dimensions and parameters. Subsampling offsets and a source
+ * region are taken from the given image read parameters and used to
+ * clip the given image dimensions, returning a new rectangular
+ * region as a result.
+ *
+ * @param param image parameters, or null
+ * @param srcWidth the width of the source image
+ * @param srcHeight the height of the source image
+ *
+ * @return a clipped rectangle
+ */
+ protected static Rectangle getSourceRegion (ImageReadParam param,
+ int srcWidth,
+ int srcHeight)
+ {
+ Rectangle clippedRegion = new Rectangle (0, 0, srcWidth, srcHeight);
+
+ if (param != null)
+ {
+ Rectangle srcRegion = param.getSourceRegion();
+
+ if (srcRegion != null)
+ {
+ clippedRegion.x = srcRegion.x > clippedRegion.x
+ ? srcRegion.x : clippedRegion.x;
+ clippedRegion.y = srcRegion.y > clippedRegion.y
+ ? srcRegion.y : clippedRegion.y;
+ clippedRegion.width = srcRegion.width > clippedRegion.width
+ ? srcRegion.width : clippedRegion.width;
+ clippedRegion.height = srcRegion.height > clippedRegion.height
+ ? srcRegion.height : clippedRegion.height;
+ }
+
+ int xOffset = param.getSubsamplingXOffset();
+
+ clippedRegion.x += xOffset;
+ clippedRegion.width -= xOffset;
+
+ int yOffset = param.getSubsamplingYOffset();
+
+ clippedRegion.y += yOffset;
+ clippedRegion.height -= yOffset;
+ }
+ return clippedRegion;
+ }
+
+ /**
+ * Get the metadata associated with the image being read. If the
+ * reader is set to ignore metadata or does not support reading
+ * metadata, or if no metadata is available then null is returned.
+ * This method returns metadata associated with the entirety of the
+ * image data, whereas getStreamMetadata() returns metadata
+ * associated with a frame within a multi-image data stream.
+ *
+ * This more specific version of getStreamMetadata() can be used to
+ * restrict metadata retrieval to specific formats and node names,
+ * which can limit the amount of data that needs to be processed.
+ *
+ * @param formatName the format of metadata requested
+ * @param nodeNames a set of Strings specifiying node names to be
+ * retrieved
+ *
+ * @return metadata associated with the image being read, or null
+ *
+ * @exception IllegalArgumentException if formatName is null
+ * @exception IllegalArgumentException if nodeNames is null
+ * @exception IOException if a read error occurs
+ */
+ public IIOMetadata getStreamMetadata (String formatName,
+ Set nodeNames)
+ throws IOException
+ {
+ if (formatName == null || nodeNames == null)
+ throw new IllegalArgumentException ("null argument");
+
+ return getStreamMetadata();
+ }
+
+ /**
+ * Read the given frame all at once, using default image read
+ * parameters, and return a buffered image.
+ *
+ * The returned image will be formatted according to the
+ * currently-preferred image type specifier.
+ *
+ * Installed read progress listeners, update progress listeners and
+ * warning listeners will be notified of read progress, changes in
+ * sample sets and warnings respectively.
+ *
+ * @param the index of the image frame to read
+ *
+ * @return a buffered image
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
+ public BufferedImage read (int imageIndex)
+ throws IOException
+ {
+ return read (imageIndex, null);
+ }
+
+ /**
+ * Read the given frame all at once, using the given image read
+ * parameters, and return an IIOImage. The IIOImage will contain a
+ * buffered image as returned by getDestination.
+ *
+ * Installed read progress listeners, update progress listeners and
+ * warning listeners will be notified of read progress, changes in
+ * sample sets and warnings respectively.
+ *
+ * The source and destination band settings are checked with a call
+ * to checkReadParamBandSettings.
+ *
+ * @param the index of the image frame to read
+ * @param the image read parameters
+ *
+ * @return an IIOImage
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IllegalArgumentException if param.getSourceBands() and
+ * param.getDestinationBands() are incompatible
+ * @exception IllegalArgumentException if either the source or
+ * destination image regions are empty
+ * @exception IOException if a read error occurs
+ */
+ public IIOImage readAll (int imageIndex,
+ ImageReadParam param)
+ throws IOException
+ {
+ checkReadParamBandSettings (param,
+ param.getSourceBands().length,
+ param.getDestinationBands().length);
+
+ List l = new ArrayList ();
+
+ for (int i = 0; i < getNumThumbnails (imageIndex); i++)
+ l.add (readThumbnail(imageIndex, i));
+
+ return new IIOImage (getDestination(param, getImageTypes(imageIndex),
+ getWidth(imageIndex),
+ getHeight(imageIndex)),
+ l,
+ getImageMetadata (imageIndex));
+ }
+
+ /**
+ * Read all image frames all at once, using the given image read
+ * parameters iterator, and return an iterator over a collection of
+ * IIOImages. Each IIOImage in the collection will contain a
+ * buffered image as returned by getDestination.
+ *
+ * Installed read progress listeners, update progress listeners and
+ * warning listeners will be notified of read progress, changes in
+ * sample sets and warnings respectively.
+ *
+ * Each set of source and destination band settings are checked with
+ * a call to checkReadParamBandSettings.
+ *
+ * @param an iterator over the image read parameters
+ *
+ * @return an IIOImage
+ *
+ * @exception IllegalStateException if input has not been set
+ * @exception IllegalArgumentException if a non-ImageReadParam is
+ * found in params
+ * @exception IllegalArgumentException if param.getSourceBands() and
+ * param.getDestinationBands() are incompatible
+ * @exception IllegalArgumentException if either the source or
+ * destination image regions are empty
+ * @exception IOException if a read error occurs
+ */
+ public Iterator readAll (Iterator params)
+ throws IOException
+ {
+ List l = new ArrayList ();
+ int index = 0;
+
+ while (params.hasNext())
+ {
+ if (params != null && ! (params instanceof ImageReadParam))
+ throw new IllegalArgumentException ("non-ImageReadParam found");
+
+ l.add (readAll(index++, (ImageReadParam) params.next ()));
+ }
+
+ return l.iterator();
+ }
+
+ /**
+ * Read a rendered image. This is a more general counterpart to
+ * read (int, ImageReadParam). All image data may not be read
+ * before this method returns and so listeners will not necessarily
+ * be notified.
+ *
+ * @param the index of the image frame to read
+ * @param the image read parameters
+ *
+ * @return a rendered image
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IllegalArgumentException if param.getSourceBands() and
+ * param.getDestinationBands() are incompatible
+ * @exception IllegalArgumentException if either the source or
+ * destination image regions are empty
+ * @exception IOException if a read error occurs
+ */
+ public RenderedImage readAsRenderedImage (int imageIndex,
+ ImageReadParam param)
+ throws IOException
+ {
+ return read (imageIndex, param);
+ }
+
+ /**
+ * Read the given tile into a buffered image. If the tile
+ * coordinates are out-of-bounds an exception is thrown. If the
+ * image is not tiled then the coordinates 0, 0 are expected and the
+ * entire image will be read.
+ *
+ * @param imageIndex the frame index
+ * @param tileX the horizontal tile coordinate
+ * @param tileY the vertical tile coordinate
+ *
+ * @return the contents of the tile as a buffered image
+ *
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IllegalArgumentException if the tile coordinates are
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
+ public BufferedImage readTile (int imageIndex, int tileX, int tileY)
+ throws IOException
+ {
+ if (tileX != 0 || tileY != 0)
+ throw new IllegalArgumentException ("tileX not 0 or tileY not 0");
+
+ return read (imageIndex);
+ }
+
+ /**
+ * Read the given tile into a raster containing the raw image data.
+ * If the tile coordinates are out-of-bounds an exception is thrown.
+ * If the image is not tiled then the coordinates 0, 0 are expected
+ * and the entire image will be read.
+ *
+ * @param imageIndex the frame index
+ * @param tileX the horizontal tile coordinate
+ * @param tileY the vertical tile coordinate
+ *
+ * @return the contents of the tile as a raster
+ *
+ * @exception UnsupportedOperationException if rasters are not
+ * supported
+ * @exception IllegalStateException if input is null
+ * @exception IndexOutOfBoundsException if the frame index is
+ * out-of-bounds
+ * @exception IllegalArgumentException if the tile coordinates are
+ * out-of-bounds
+ * @exception IOException if a read error occurs
+ */
+ public Raster readTileRaster (int imageIndex, int tileX, int tileY)
+ throws IOException
+ {
+ if (!canReadRaster())
+ throw new UnsupportedOperationException ("cannot read rasters");
+
+ if (tileX != 0 || tileY != 0)
+ throw new IllegalArgumentException ("tileX not 0 or tileY not 0");
+
+ return readRaster (imageIndex, null);
+ }
+
+ /**
+ * Reset this reader's internal state.
+ */
+ public void reset ()
+ {
+ setInput (null, false);
+ setLocale (null);
+ removeAllIIOReadUpdateListeners ();
+ removeAllIIOReadWarningListeners ();
+ removeAllIIOReadProgressListeners ();
+ clearAbortRequest ();
+ }
}
+
diff --git a/javax/imageio/ImageTranscoder.java b/javax/imageio/ImageTranscoder.java
index ccc993162..1f9195f58 100644
--- a/javax/imageio/ImageTranscoder.java
+++ b/javax/imageio/ImageTranscoder.java
@@ -41,14 +41,62 @@ package javax.imageio;
import javax.imageio.metadata.IIOMetadata;
/**
+ * An ImageTranscoder translates IIOMetadata objects provided by an
+ * ImageReader into corresponding IIOMetadata objects that can be
+ * understood by a given ImageWriter.
+ *
+ * Usually an ImageWriter will implement ImageTranscoder directly in
+ * which case the conversion methods will return IIOMetadata objects
+ * appropriate for this ImageWriter.
+ *
+ * Independent transcoders are also allowed; they must have knowledge
+ * of both the source IIOMetadata provided by the reader and the
+ * returned IIOMetadata expected by the writer.
+ *
* @author Michael Koch (konqueror@gmx.de)
*/
public interface ImageTranscoder
{
+ /**
+ * Converts IIOMetadata from an input reader format, returning an
+ * IIOMetadata suitable for use by an image writer.
+ *
+ * The ImageTypeSpecifier specifies the destination image type.
+ *
+ * An optional ImageWriteParam argument is available in case the
+ * image writing parameters affect the metadata conversion.
+ *
+ * @param inData the metadata coming from an image reader
+ * @param imageType the output image type of the writer
+ * @param param the image writing parameters or null
+ *
+ * @return the converted metadata that should be used by the image
+ * writer, or null if this ImageTranscoder has no knowledge of the
+ * input metadata
+ *
+ * @exception IllegalArgumentException if either inData or imageType
+ * is null
+ */
IIOMetadata convertImageMetadata(IIOMetadata inData,
ImageTypeSpecifier imageType,
ImageWriteParam param);
+ /**
+ * Converts IIOMetadata from an input stream format, returning an
+ * IIOMetadata suitable for use by an image writer.
+ *
+ * An optional ImageWriteParam argument is available in case the
+ * image writing parameters affect the metadata conversion.
+ *
+ * @param inData the metadata coming from an input image stream
+ * @param param the image writing parameters or null
+ *
+ * @return the converted metadata that should be used by the image
+ * writer, or null if this ImageTranscoder has no knowledge of the
+ * input metadata
+ *
+ * @exception IllegalArgumentException if inData is null
+ */
IIOMetadata convertStreamMetadata(IIOMetadata inData,
ImageWriteParam param);
}
diff --git a/javax/imageio/ImageTypeSpecifier.java b/javax/imageio/ImageTypeSpecifier.java
index 0751e3767..05b3a26d4 100644
--- a/javax/imageio/ImageTypeSpecifier.java
+++ b/javax/imageio/ImageTypeSpecifier.java
@@ -38,15 +38,47 @@ exception statement from your version. */
package javax.imageio;
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.awt.image.DataBuffer;
+import java.awt.image.BandedSampleModel;
+import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.PixelInterleavedSampleModel;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
+/**
+ * ImageTypeSpecifier store the color and sample models associated
+ * with an IIOImage.
+ */
public class ImageTypeSpecifier
{
+ /**
+ * The image's color model.
+ */
protected ColorModel colorModel;
+
+ /**
+ * The image's sample model.
+ */
protected SampleModel sampleModel;
+ /**
+ * Construct an image type specifier with the given models.
+ *
+ * @param colorModel the color model
+ * @param sampleModel the sample model
+ *
+ * @exception IllegalArgumentException if either model argument is
+ * null
+ * @exception IllegalArgumentException if the models are
+ * incompatible with one another
+ */
public ImageTypeSpecifier(ColorModel colorModel, SampleModel sampleModel)
{
if (colorModel == null)
@@ -63,6 +95,14 @@ public class ImageTypeSpecifier
this.sampleModel = sampleModel;
}
+ /**
+ * Construct an image type specifier that describes the given
+ * rendered image.
+ *
+ * @param image a rendered image
+ *
+ * @exception IllegalArgumentException if image is null
+ */
public ImageTypeSpecifier(RenderedImage image)
{
if (image == null)
@@ -72,21 +112,448 @@ public class ImageTypeSpecifier
this.sampleModel = image.getSampleModel();
}
+ /**
+ * Create an image type specifier for a banded image using a
+ * component color model and a banded sample model.
+ *
+ * @param colorSpace the color space
+ * @param bankIndices the bank indices at which each band will be
+ * stored
+ * @param bandOffsets the starting band offset for each band within
+ * its bank
+ * @param dataType the data type, a DataBuffer constant
+ * @param hasAlpha true if this image type specifier should have an
+ * alpha component, false otherwise
+ * @param isAlphaPremultiplied true if other color components should
+ * be premultiplied by the alpha component, false otherwise
+ *
+ * @return a banded image type specifier
+ *
+ * @exception IllegalArgumentException if any of colorSpace,
+ * bankIndices or bankOffsets is null
+ * @exception IllegalArgumentException if bankIndices and
+ * bankOffsets differ in length
+ * @excpetion IllegalArgumentException if the number of color space
+ * components, including the alpha component if requested, is
+ * different from bandOffsets.length
+ * @exception if dataType is not a valid DataBuffer constant
+ */
+ public static ImageTypeSpecifier createBanded (ColorSpace colorSpace,
+ int[] bankIndices,
+ int[] bankOffsets,
+ int dataType,
+ boolean hasAlpha,
+ boolean isAlphaPremultiplied)
+ {
+ if (colorSpace == null || bankIndices == null || bankOffsets == null)
+ throw new IllegalArgumentException ("null argument");
+
+ if (bankIndices.length != bankOffsets.length)
+ throw new IllegalArgumentException ("array lengths differ");
+
+ if (bankOffsets.length != (colorSpace.getNumComponents() + (hasAlpha ? 1 : 0)))
+ throw new IllegalArgumentException ("invalid bankOffsets length");
+
+ return new ImageTypeSpecifier (new ComponentColorModel (colorSpace,
+ hasAlpha,
+ isAlphaPremultiplied,
+ hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE,
+ dataType),
+ new BandedSampleModel (dataType, 1, 1, 1,
+ bankIndices,
+ bankOffsets));
+ }
+
+ /**
+ * Create a buffered image with the given dimensions using that has
+ * the characteristics specified by this image type specifier.
+ *
+ * @param the width of the buffered image, in pixels
+ * @param the height of the buffered image, in pixels
+ *
+ * @return a buffered image
+ *
+ * @exception IllegalArgumentException if either width or height is
+ * less than or equal to zero
+ * @exception IllegalArgumentException if width * height is greater
+ * than Integer.MAX_VALUE or if the storage required is greater than
+ * Integer.MAX_VALUE
+ */
+ public BufferedImage createBufferedImage (int width, int height)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException ("dimension <= 0");
+
+ // test for overflow
+ if (width * height < Math.min (width, height))
+ throw new IllegalArgumentException ("width * height > Integer.MAX_VALUE");
+
+ if (width * height * sampleModel.getNumBands() < Math.min (width, height))
+ throw new IllegalArgumentException ("storage required >"
+ + " Integer.MAX_VALUE");
+
+ // FIXME: this is probably wrong:
+ return new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
+ }
+
+ /**
+ * Create an image type specifier that describes the given buffered
+ * image type.
+ *
+ * @param bufferedImageType the buffered image type to represent
+ * with the returned image type specifier
+ *
+ * @return a new image type specifier
+ *
+ * @exception IllegalArgumentException if bufferedImageType is not a
+ * BufferedImage constant or is BufferedImage.TYPE_CUSTOM
+ */
+ public static ImageTypeSpecifier createFromBufferedImageType (int bufferedImageType)
+ {
+ if (bufferedImageType <= BufferedImage.TYPE_CUSTOM
+ || bufferedImageType > BufferedImage.TYPE_BYTE_INDEXED)
+ throw new IllegalArgumentException ("invalid buffered image type");
+
+ return new ImageTypeSpecifier (new BufferedImage (1, 1, bufferedImageType));
+ }
+
+ /**
+ * Create an image type specifier that describes the given rendered
+ * image's type.
+ *
+ * @param image the rendered image
+ *
+ * @return a new image type specifier
+ *
+ * @exception IllegalArgumentException if image is null
+ */
+ public static ImageTypeSpecifier createFromRenderedImage (RenderedImage image)
+ {
+ if (image == null)
+ throw new IllegalArgumentException ("image null");
+
+ return new ImageTypeSpecifier (image);
+ }
+
+ /**
+ * Create a grayscale image type specifier, given the number of
+ * bits, data type and whether or not the data is signed.
+ *
+ * @param bits the number of bits used to specify a greyscale value
+ * @param dataType a DataBuffer type constant
+ * @param isSigned true if this type specifier should support
+ * negative values, false otherwise
+ *
+ * @return a greyscal image type specifier
+ *
+ * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or 16
+ * @exception IllegalArgumentException if dataType is not
+ * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+ * DataBuffer.TYPE_USHORT
+ * @exception if bits is larger than the number of bits in the given
+ * data type
+ */
+ public static ImageTypeSpecifier createGrayscale (int bits, int dataType, boolean isSigned)
+ {
+ return createGrayscale (bits, dataType, isSigned, false);
+ }
+
+ /**
+ * Create a grayscale image type specifier, given the number of
+ * bits, data type and whether or not the data is signed.
+ *
+ * @param bits the number of bits used to specify a greyscale value
+ * @param dataType a DataBuffer type constant
+ * @param isSigned true if this type specifier should support
+ * negative values, false otherwise
+ *
+ * @return a greyscal image type specifier
+ *
+ * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
+ * 16
+ * @exception IllegalArgumentException if dataType is not
+ * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+ * DataBuffer.TYPE_USHORT
+ * @exception if bits is larger than the number of bits in the given
+ * data type
+ */
+ public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
+ boolean isSigned,
+ boolean isAlphaPremultiplied)
+ {
+ if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
+ throw new IllegalArgumentException ("invalid bit size");
+
+ if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
+ && dataType != DataBuffer.TYPE_USHORT)
+ throw new IllegalArgumentException ("invalid data type");
+
+ if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
+ throw new IllegalArgumentException ("number of bits too large for data type");
+
+ // FIXME: this is probably wrong:
+ return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
+ 0x0, 0xff),
+ new MultiPixelPackedSampleModel (dataType,
+ 1, 1,
+ bits));
+ }
+
+ /**
+ * Return an image type specifier for an image that uses an indexed
+ * colour model where each colour value has the specified number of
+ * bits and type and where the colour tables are those given.
+ *
+ * @param redLUT the red index values
+ * @param greenLUT the green index values
+ * @param blueLUT the blue index values
+ * @param alphaLUT the alpha index values
+ * @param bits the number of bits per index value
+ * @param dataType the type of each index value
+ *
+ * @return an indexed image type specifier
+ *
+ * @exception IllegalArgumentException if any of the colour arrays,
+ * not including alphaLUT, is null
+ * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
+ * 16
+ * @exception IllegalArgumentException if dataType is not
+ * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+ * DataBuffer.TYPE_USHORT
+ * @exception if bits is larger than the number of bits in the given
+ * data type
+ */
+ public static ImageTypeSpecifier createIndexed (byte[] redLUT,
+ byte[] greenLUT,
+ byte[] blueLUT,
+ byte[] alphaLUT,
+ int bits,
+ int dataType)
+ {
+ if (redLUT == null || greenLUT == null || blueLUT == null)
+ throw new IllegalArgumentException ("null colour table");
+
+ if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
+ throw new IllegalArgumentException ("invalid bit size");
+
+ if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
+ && dataType != DataBuffer.TYPE_USHORT)
+ throw new IllegalArgumentException ("invalid data type");
+
+ if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
+ throw new IllegalArgumentException ("number of bits too large for data type");
+
+ // FIXME: this is probably wrong:
+ return new ImageTypeSpecifier (new IndexColorModel (bits, redLUT.length,
+ redLUT, greenLUT, blueLUT,
+ alphaLUT),
+ new MultiPixelPackedSampleModel (dataType,
+ 1, 1,
+ bits));
+ }
+
+ /**
+ * Create an image type specifier that uses a component colour model
+ * and a pixel interleaved sample model. Each pixel component will
+ * be stored in a separate value of the given data type.
+ *
+ * @param colorSpace the colour space used by the colour model
+ * @param bandOffsets the starting band offset for each band within
+ * its bank
+ * @param dataType the type of each pixel value
+ * @param hasAlpha true if an alpha channel should be specified,
+ * false otherwise
+ * @param isAlphaPremultiplied true if other colour channels should
+ * be premultiplied by the alpha value, false otherwise
+ *
+ * @return an interleaved image type specifier
+ *
+ * @exception IllegalArgumentException if either colorSpace or
+ * bandOffsets is null
+ * @excpetion IllegalArgumentException if the number of color space
+ * components, including the alpha component if requested, is
+ * different from bandOffsets.length
+ * @exception if dataType is not a valid DataBuffer constant
+ */
+ public static ImageTypeSpecifier createInterleaved (ColorSpace colorSpace,
+ int[] bandOffsets,
+ int dataType,
+ boolean hasAlpha,
+ boolean isAlphaPremultiplied)
+ {
+ if (colorSpace == null || bandOffsets == null)
+ throw new IllegalArgumentException ("null argument");
+
+ if (bandOffsets.length != (colorSpace.getNumComponents() + (hasAlpha ? 1 : 0)))
+ throw new IllegalArgumentException ("invalid bankOffsets length");
+
+ return new ImageTypeSpecifier (new ComponentColorModel (colorSpace,
+ hasAlpha,
+ isAlphaPremultiplied,
+ hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE,
+ dataType),
+ new PixelInterleavedSampleModel (dataType, 1, 1, 1, 1,
+ bandOffsets));
+ }
+
+ /**
+ * Create an image type specifier using a direct color model and a
+ * packed sample model. All pixel components will be packed into
+ * one value of the given data type.
+ *
+ * @param colorSpace the color space to use in the color model
+ * @param redMask the bitmask for the red bits
+ * @param greenMask the bitmask for the green bits
+ * @param blueMask the bitmask for the blue bits
+ * @param alphaMask the bitmask for the alpha bits
+ * @param transferType the data type used to store pixel values
+ * @param isAlphaPremultiplied true if other colour channels should
+ * be premultiplied by the alpha value, false otherwise
+ *
+ * @return a packed image type specifier
+ *
+ * @exception IllegalArgumentException if colorSpace is null
+ * @exception IllegalArgumentException if colorSpace does not have
+ * type ColorSpace.TYPE_RGB
+ * @exception IllegalArgumentException if all masks are 0
+ * @exception IllegalArgumentException if dataType is not
+ * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
+ * DataBuffer.TYPE_INT
+ */
+ public static ImageTypeSpecifier createPacked (ColorSpace colorSpace,
+ int redMask,
+ int greenMask,
+ int blueMask,
+ int alphaMask,
+ int transferType,
+ boolean isAlphaPremultiplied)
+ {
+ if (colorSpace == null)
+ throw new IllegalArgumentException ("null color space");
+
+ if (colorSpace.getType() != ColorSpace.TYPE_RGB)
+ throw new IllegalArgumentException ("invalid color space type");
+
+ if (redMask == 0 && greenMask == 0 && blueMask == 0 && alphaMask == 0)
+ throw new IllegalArgumentException ("no non-zero mask");
+
+ if (transferType != DataBuffer.TYPE_BYTE && transferType != DataBuffer.TYPE_USHORT
+ && transferType != DataBuffer.TYPE_INT)
+ throw new IllegalArgumentException ("invalid data type");
+
+ // Assume DataBuffer.TYPE_BYTE.
+ int numBits = 8;
+
+ if (transferType == DataBuffer.TYPE_SHORT)
+ numBits = 16;
+ else if (transferType == DataBuffer.TYPE_INT)
+ numBits = 32;
+
+ return new ImageTypeSpecifier (new DirectColorModel (colorSpace,
+ numBits,
+ redMask,
+ greenMask,
+ blueMask,
+ alphaMask,
+ isAlphaPremultiplied,
+ transferType),
+ new MultiPixelPackedSampleModel (transferType,
+ 1, 1, numBits));
+ }
+
+ /**
+ * Get the number of bits per sample in the given band.
+ *
+ * @param band the band from which to get the number of bits
+ *
+ * @return the number of bits in the given band
+ *
+ * @exception IllegalArgumentException if band is out-of-bounds
+ */
+ public int getBitsPerBand (int band)
+ {
+ if (band < 0 || band > sampleModel.getNumBands())
+ throw new IllegalArgumentException ("band out-of-bounds");
+
+ return sampleModel.getSampleSize (band);
+ }
+
+ /**
+ * Get the buffered image constant specified by this image type
+ * specifier.
+ *
+ * @return a buffered image constant
+ */
+ public int getBufferedImageType ()
+ {
+ // FIXME:
+ return BufferedImage.TYPE_INT_RGB;
+ }
+
+ /**
+ * Create a sample model that is compatible with the one specified
+ * by this image type specifier, with the given dimensions.
+ *
+ * @param width the width of the returned sample model
+ * @param height the height of the returned sample model
+ *
+ * @return a sample model compatible with the one in this image type
+ * specifier, with the given dimensions
+ *
+ * @exception IllegalArgumentException if either width or height is
+ * less than or equal to 0
+ * @exception IllegalArgumentException if width * height is greater
+ * than Intere.MAX_VALUE
+ */
+ public SampleModel getSampleModel (int width, int height)
+ {
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException ("invalid dimension");
+
+ // test for overflow
+ if (width * height < Math.min (width, height))
+ throw new IllegalArgumentException ("width * height > Integer.MAX_VALUE");
+
+ return sampleModel.createCompatibleSampleModel (width, height);
+ }
+
+ /**
+ * Get the color model specified by this image type specifier.
+ *
+ * @return the color model
+ */
public ColorModel getColorModel()
{
return colorModel;
}
+ /**
+ * Get the number of bands specified by this image type specifier's
+ * sample model.
+ *
+ * @return the number of bands in the sample model
+ */
public int getNumBands()
{
return sampleModel.getNumBands();
}
+ /**
+ * Get the number of components specified by this image type
+ * specifier's color model.
+ *
+ * @return the number of color components per pixel
+ */
public int getNumComponents()
{
return colorModel.getNumComponents();
}
+ /**
+ * Get the sample model specified by this image type specifier.
+ *
+ * @return the sample model
+ */
public SampleModel getSampleModel()
{
return sampleModel;
diff --git a/javax/imageio/ImageWriteParam.java b/javax/imageio/ImageWriteParam.java
index 08f4885a8..84b257e04 100644
--- a/javax/imageio/ImageWriteParam.java
+++ b/javax/imageio/ImageWriteParam.java
@@ -41,6 +41,9 @@ package javax.imageio;
import java.awt.Dimension;
import java.util.Locale;
+/**
+ * DOCUMENT ME
+ */
public class ImageWriteParam extends IIOParam
{
public static final int MODE_DISABLED = 0;
diff --git a/javax/imageio/ImageWriter.java b/javax/imageio/ImageWriter.java
index 7479c3074..ef3521541 100644
--- a/javax/imageio/ImageWriter.java
+++ b/javax/imageio/ImageWriter.java
@@ -1,5 +1,5 @@
/* ImageWriter.java -- Encodes raster images.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,11 +39,16 @@ exception statement from your version. */
package javax.imageio;
import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
import javax.imageio.event.IIOWriteProgressListener;
import javax.imageio.event.IIOWriteWarningListener;
@@ -51,56 +56,161 @@ import javax.imageio.metadata.IIOMetadata;
import javax.imageio.spi.ImageWriterSpi;
+/**
+ * A class for encoding images within the ImageIO framework.
+ *
+ * An ImageWriter for a given format is instantiated by an
+ * ImageWriterSpi for that format. ImageWriterSpis are registered
+ * with the IIORegistry.
+ *
+ * The ImageWriter API supports writing animated images that may have
+ * multiple frames; to support such images many methods take an index
+ * parameter.
+ *
+ * Images may also be written in multiple passes, where each
+ * successive pass increases the level of detail in the destination
+ * image.
+ */
public abstract class ImageWriter
implements ImageTranscoder
{
private boolean aborted;
- protected Locale[] availableLocales;
- protected Locale locale;
- protected ImageWriterSpi originatingProvider;
- protected Object output;
- protected List progressListeners = new ArrayList();
- protected List warningListeners = new ArrayList();
- protected List warningLocales = new ArrayList();
+ /**
+ * All locales available for localization of warning messages, or
+ * null if localization is not supported.
+ */
+ protected Locale[] availableLocales = null;
+ /**
+ * The current locale used to localize warning messages, or null if
+ * no locale has been set.
+ */
+ protected Locale locale = null;
+
+ /**
+ * The image writer SPI that instantiated this writer.
+ */
+ protected ImageWriterSpi originatingProvider = null;
+
+ /**
+ * An ImageInputStream to which image data is written.
+ */
+ protected Object output = null;
+
+ /**
+ * A list of installed progress listeners. Initially null, meaning
+ * no installed listeners.
+ */
+ protected List progressListeners = null;
+
+ /**
+ * A list of installed warning listeners. Initially null, meaning
+ * no installed listeners.
+ */
+ protected List warningListeners = null;
+
+ /**
+ * A list of warning locales corresponding with the list of
+ * installed warning listeners. Initially null, meaning no locales.
+ */
+ protected List warningLocales = null;
+
+ /**
+ * Construct an image writer.
+ *
+ * @param originatingProvider the provider that is constructing this
+ * image writer, or null
+ */
protected ImageWriter(ImageWriterSpi originatingProvider)
{
this.originatingProvider = originatingProvider;
}
+ /**
+ * Throw an IllegalStateException if output is null.
+ *
+ * @exception IllegalStateException if output is null
+ */
private void checkOutputSet()
{
if (output == null)
throw new IllegalStateException("no output set");
}
+ /**
+ * Request that writing be aborted. The unwritten portions of the
+ * destination image will be undefined.
+ *
+ * Writers should clear the abort flag before starting a write
+ * operation, then poll it periodically during the write operation.
+ */
public void abort()
{
aborted = true;
}
+ /**
+ * Check if the abort flag is set.
+ *
+ * @return true if the current write operation should be aborted,
+ * false otherwise
+ */
protected boolean abortRequested()
{
return aborted;
}
+ /**
+ * Install a write progress listener. This method will return
+ * immediately if listener is null.
+ *
+ * @param listener a write progress listener or null
+ */
public void addIIOWriteProgressListener(IIOWriteProgressListener listener)
{
if (listener == null)
return;
-
+ if (progressListeners == null)
+ progressListeners = new ArrayList ();
progressListeners.add(listener);
}
-
+
+ /**
+ * Install a write warning listener. This method will return
+ * immediately if listener is null. Warning messages sent to this
+ * listener will be localized using the current locale. If the
+ * current locale is null then this writer will select a sensible
+ * default.
+ *
+ * @param listener a write warning listener
+ */
public void addIIOWriteWarningListener (IIOWriteWarningListener listener)
{
if (listener == null)
return;
-
+ if (warningListeners == null)
+ warningListeners = new ArrayList ();
warningListeners.add(listener);
}
+ /**
+ * Check whether a new empty image can be inserted at the given
+ * frame index. Pixel values may be filled in later using the
+ * replacePixels methods. Indices greater than the insertion index
+ * will be incremented. If imageIndex is -1, the image will be
+ * appended at the end of the current image list.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return true if an empty image can be inserted at imageIndex,
+ * false otherwise
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IndexOutOfBoundsException if imageIndex is less than
+ * -1 or greater than the last index in the current image list
+ * @exception IOException if a write error occurs
+ */
public boolean canInsertEmpty(int imageIndex)
throws IOException
{
@@ -108,6 +218,22 @@ public abstract class ImageWriter
return false;
}
+ /**
+ * Check whether an image can be inserted at the given frame index.
+ * Indices greater than the insertion index will be incremented. If
+ * imageIndex is -1, the image will be appended at the end of the
+ * current image list.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return true if an image can be inserted at imageIndex, false
+ * otherwise
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IndexOutOfBoundsException if imageIndex is less than
+ * -1 or greater than the last index in the current image list
+ * @exception IOException if a write error occurs
+ */
public boolean canInsertImage(int imageIndex)
throws IOException
{
@@ -115,6 +241,20 @@ public abstract class ImageWriter
return false;
}
+ /**
+ * Check whether an image can be removed from the given frame index.
+ * Indices greater than the removal index will be decremented.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return true if an image can be removed from imageIndex, false
+ * otherwise
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IndexOutOfBoundsException if imageIndex is less than 0
+ * or greater than the last index in the current image list
+ * @exception IOException if a write error occurs
+ */
public boolean canRemoveImage(int imageIndex)
throws IOException
{
@@ -122,6 +262,20 @@ public abstract class ImageWriter
return false;
}
+ /**
+ * Check whether the metadata associated the image at the given
+ * frame index can be replaced.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return true if the metadata associated with the image at
+ * imageIndex can be replaced, false otherwise
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IndexOutOfBoundsException if imageIndex is less than 0
+ * or greater than the last index in the current image list
+ * @exception IOException if a write error occurs
+ */
public boolean canReplaceImageMetadata(int imageIndex)
throws IOException
{
@@ -129,6 +283,20 @@ public abstract class ImageWriter
return false;
}
+ /**
+ * Check whether the pixels within the image at the given index can
+ * be replaced.
+ *
+ * @param imageIndex the frame index
+ *
+ * @return true if the pixels in the image at imageIndex can be
+ * replaced, false otherwise
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IndexOutOfBoundsException if imageIndex is less than 0
+ * or greater than the last index in the current image list
+ * @exception IOException if a write error occurs
+ */
public boolean canReplacePixels(int imageIndex)
throws IOException
{
@@ -136,6 +304,16 @@ public abstract class ImageWriter
return false;
}
+ /**
+ * Check whether the metadata associated the entire image stream can
+ * be replaced.
+ *
+ * @return true if the stream metadata can be replaced, false
+ * otherwise
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IOException if a write error occurs
+ */
public boolean canReplaceStreamMetadata()
throws IOException
{
@@ -143,6 +321,18 @@ public abstract class ImageWriter
return false;
}
+ /**
+ * Check whether an entire empty image, including empty metadata and
+ * empty thumbnails, can be written to the output stream, leaving
+ * pixel values to be filled in later using the replacePixels
+ * methods.
+ *
+ * @return true if an entire empty image can be written before its
+ * contents are filled in, false otherwise
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IOException if a write error occurs
+ */
public boolean canWriteEmpty()
throws IOException
{
@@ -150,68 +340,217 @@ public abstract class ImageWriter
return false;
}
+ /**
+ * Check if IIOImages containing raster data are supported.
+ *
+ * @return true if raster IIOImages are supported, false otherwise
+ */
public boolean canWriteRasters()
{
return false;
}
+ /**
+ * Check if an image can be appended at the end of the current list
+ * of images even if prior images have already been written.
+ *
+ * @return true if sequences of images can be written, false
+ * otherwise
+ */
public boolean canWriteSequence()
{
return false;
}
+ /**
+ * Clear the abort flag.
+ */
protected void clearAbortRequest()
{
aborted = false;
}
-
+
+ /**
+ * Convert IIOMetadata from an input reader format, returning an
+ * IIOMetadata suitable for use by an image writer.
+ *
+ * The ImageTypeSpecifier specifies the destination image type.
+ *
+ * An optional ImageWriteParam argument is available in case the
+ * image writing parameters affect the metadata conversion.
+ *
+ * @param inData the metadata coming from an image reader
+ * @param imageType the output image type of the writer
+ * @param param the image writing parameters or null
+ *
+ * @return the converted metadata that should be used by the image
+ * writer, or null if this ImageTranscoder has no knowledge of the
+ * input metadata
+ *
+ * @exception IllegalArgumentException if either inData or imageType
+ * is null
+ */
public abstract IIOMetadata convertImageMetadata (IIOMetadata inData,
ImageTypeSpecifier imageType,
ImageWriteParam param);
+ /**
+ * Convert IIOMetadata from an input stream format, returning an
+ * IIOMetadata suitable for use by an image writer.
+ *
+ * An optional ImageWriteParam argument is available in case the
+ * image writing parameters affect the metadata conversion.
+ *
+ * @param inData the metadata coming from an input image stream
+ * @param param the image writing parameters or null
+ *
+ * @return the converted metadata that should be used by the image
+ * writer, or null if this ImageTranscoder has no knowledge of the
+ * input metadata
+ *
+ * @exception IllegalArgumentException if inData is null
+ */
public abstract IIOMetadata convertStreamMetadata (IIOMetadata inData,
ImageWriteParam param);
+ /**
+ * Releases any resources allocated to this object. Subsequent
+ * calls to methods on this object will produce undefined results.
+ *
+ * The default implementation does nothing; subclasses should use
+ * this method ensure that native resources are released.
+ */
public void dispose()
{
// The default implementation is empty. Subclasses have to overwrite it.
}
+ /**
+ * Retrieve the available locales. Return null if no locales are
+ * available or a clone of availableLocales.
+ *
+ * @return an array of locales or null
+ */
public Locale[] getAvailableLocales()
{
return availableLocales;
}
+ /**
+ * Get a metadata object appropriate for encoding an image specified
+ * by the given image type specifier and optional image write
+ * parameters.
+ *
+ * @param imageType an image type specifier
+ * @param param image writing parameters, or null
+ *
+ * @return a metadata object appropriate for encoding an image of
+ * the given type with the given parameters
+ */
public abstract IIOMetadata getDefaultImageMetadata (ImageTypeSpecifier imageType, ImageWriteParam param);
+ /**
+ * Get a metadata object appropriate for encoding the default image
+ * type handled by this writer, optionally considering image write
+ * parameters.
+ *
+ * @param param image writing parameters, or null
+ *
+ * @return a metadata object appropriate for encoding an image of
+ * the default type with the given parameters
+ */
public abstract IIOMetadata getDefaultStreamMetadata (ImageWriteParam param);
+ /**
+ * Retrieve the default write parameters for this writer's image
+ * format.
+ *
+ * The default implementation returns new ImageWriteParam().
+ *
+ * @return image writing parameters
+ */
public ImageWriteParam getDefaultWriteParam()
{
return new ImageWriteParam(getLocale());
}
+ /**
+ * Get this writer's locale. null is returned if the locale has not
+ * been set.
+ *
+ * @return this writer's locale, or null
+ */
public Locale getLocale()
{
return locale;
}
- public int getNumThumbnailsSupported (ImageTypeSpecifier imageType, ImageWriteParam param,
- IIOMetadata streamMetadata, IIOMetadata imageMetadata)
+ /**
+ * Get the number of thumbnails supported by this image writer,
+ * based on the given image type, image writing parameters, and
+ * stream and image metadata. The image writing parameters are
+ * optional, in case they affect the number of thumbnails supported.
+ *
+ * @param imageType an image type specifier, or null
+ * @param param image writing parameters, or null
+ * @param streamMetadata the metadata associated with this stream,
+ * or null
+ * @param imageMetadata the metadata associated with this image, or
+ * null
+ *
+ * @return the number of thumbnails that this writer supports
+ * writing or -1 if the given information is insufficient
+ */
+ public int getNumThumbnailsSupported (ImageTypeSpecifier imageType,
+ ImageWriteParam param,
+ IIOMetadata streamMetadata,
+ IIOMetadata imageMetadata)
{
return 0;
}
+ /**
+ * Get the ImageWriterSpi that created this writer or null.
+ *
+ * @return an ImageWriterSpi, or null
+ */
public ImageWriterSpi getOriginatingProvider()
{
return originatingProvider;
}
+ /**
+ * Get this reader's image output destination. null is returned if
+ * the image destination has not been set.
+ *
+ * @return an image output destination object, or null
+ */
public Object getOutput()
{
return output;
}
+ /**
+ * Get the preferred sizes for thumbnails based on the given image
+ * type, image writing parameters, and stream and image metadata.
+ * The preferred sizes are returned in pairs of dimension values;
+ * the first value in the array is a dimension object representing
+ * the minimum thumbnail size, the second value is a dimension
+ * object representing a maximum thumbnail size. The writer can
+ * select a size within the range given by each pair, or it can
+ * ignore these size hints.
+ *
+ * @param imageType an image type specifier, or null
+ * @param param image writing parameters, or null
+ * @param streamMetadata the metadata associated with this stream,
+ * or null
+ * @param imageMetadata the metadata associated with this image, or
+ * null
+ *
+ * @return an array of dimension pairs whose length is a multiple of
+ * 2, or null if there is no preferred size (any size is allowed) or
+ * if the size is unknown (insufficient information was provided)
+ */
public Dimension[] getPreferredThumbnailSizes (ImageTypeSpecifier imageType,
ImageWriteParam param,
IIOMetadata streamMetadata,
@@ -220,120 +559,305 @@ public abstract class ImageWriter
return null;
}
+ /**
+ * Notifies all installed write progress listeners that image
+ * loading has completed by calling their imageComplete methods.
+ */
protected void processImageComplete()
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
- listener.imageComplete(this);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener =
+ (IIOWriteProgressListener) it.next();
+ listener.imageComplete(this);
+ }
}
}
+ /**
+ * Notifies all installed write progress listeners that a certain
+ * percentage of the image has been loaded, by calling their
+ * imageProgress methods.
+ *
+ * @param percentageDone the percentage of image data that has been
+ * loaded
+ */
protected void processImageProgress(float percentageDone)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
- listener.imageProgress(this, percentageDone);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener =
+ (IIOWriteProgressListener) it.next();
+ listener.imageProgress(this, percentageDone);
+ }
}
}
+ /**
+ * Notifies all installed write progress listeners, by calling their
+ * imageStarted methods, that image loading has started on the given
+ * image.
+ *
+ * @param imageIndex the frame index of the image that has started
+ * loading
+ */
protected void processImageStarted(int imageIndex)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
- listener.imageStarted(this, imageIndex);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener =
+ (IIOWriteProgressListener) it.next();
+ listener.imageStarted(this, imageIndex);
+ }
}
}
+ /**
+ * Notifies all installed write progress listeners, by calling their
+ * thumbnailComplete methods, that a thumbnail has completed
+ * loading.
+ */
protected void processThumbnailComplete()
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
- listener.thumbnailComplete(this);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener =
+ (IIOWriteProgressListener) it.next();
+ listener.thumbnailComplete(this);
+ }
}
}
+ /**
+ * Notifies all installed write progress listeners that a certain
+ * percentage of a thumbnail has been loaded, by calling their
+ * thumbnailProgress methods.
+ *
+ * @param percentageDone the percentage of thumbnail data that has
+ * been loaded
+ */
protected void processThumbnailProgress(float percentageDone)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
- listener.thumbnailProgress(this, percentageDone);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener =
+ (IIOWriteProgressListener) it.next();
+ listener.thumbnailProgress(this, percentageDone);
+ }
}
}
+ /**
+ * Notifies all installed write progress listeners, by calling their
+ * imageStarted methods, that thumbnail loading has started on the
+ * given thumbnail of the given image.
+ *
+ * @param imageIndex the frame index of the image one of who's
+ * thumbnails has started loading
+ * @param thumbnailIndex the index of the thumbnail that has started
+ * loading
+ */
protected void processThumbnailStarted(int imageIndex, int thumbnailIndex)
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
- listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener =
+ (IIOWriteProgressListener) it.next();
+ listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+ }
}
}
+ /**
+ * Notifies all installed warning listeners, by calling their
+ * warningOccurred methods, that a warning message has been raised.
+ *
+ * @param imageIndex the index of the image that was being written
+ * when the warning was raised
+ * @param warning the warning message
+ *
+ * @exception IllegalArgumentException if warning is null
+ */
protected void processWarningOccurred(int imageIndex, String warning)
{
- Iterator it = warningListeners.iterator();
+ if (warningListeners != null)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteWarningListener listener =
+ (IIOWriteWarningListener) it.next();
+ listener.warningOccurred(this, imageIndex, warning);
+ }
+ }
+ }
+
+ /**
+ * Notify all installed warning listeners, by calling their
+ * warningOccurred methods, that a warning message has been raised.
+ * The warning message is retrieved from a resource bundle, using
+ * the given basename and keyword.
+ *
+ * @param imageIndex the index of the image that was being written
+ * when the warning was raised
+ * @param baseName the basename of the resource from which to
+ * retrieve the warning message
+ * @param keyword the keyword used to retrieve the warning from the
+ * resource bundle
+ *
+ * @exception IllegalArgumentException if either baseName or keyword
+ * is null
+ * @exception IllegalArgumentException if no resource bundle is
+ * found using baseName
+ * @exception IllegalArgumentException if the given keyword produces
+ * no results from the resource bundle
+ * @exception IllegalArgumentException if the retrieved object is
+ * not a String
+ */
+ protected void processWarningOccurred(int imageIndex,
+ String baseName,
+ String keyword)
+ {
+ if (baseName == null || keyword == null)
+ throw new IllegalArgumentException ("null argument");
+
+ ResourceBundle b = null;
- while (it.hasNext())
+ try
{
- IIOWriteWarningListener listener = (IIOWriteWarningListener) it.next();
- listener.warningOccurred(this, imageIndex, warning);
+ b = ResourceBundle.getBundle(baseName, getLocale());
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no resource bundle found");
+ }
+
+ Object str = null;
+
+ try
+ {
+ str = b.getObject(keyword);
+ }
+ catch (MissingResourceException e)
+ {
+ throw new IllegalArgumentException ("no results found for keyword");
+ }
+
+ if (! (str instanceof String))
+ throw new IllegalArgumentException ("retrieved object not a String");
+
+ String warning = (String) str;
+
+ if (warningListeners != null)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteWarningListener listener =
+ (IIOWriteWarningListener) it.next();
+ listener.warningOccurred(this, imageIndex, warning);
+ }
}
}
+ /**
+ * Notifies all installed write progress listeners that image
+ * loading has been aborted by calling their writeAborted methods.
+ */
protected void processWriteAborted()
{
- Iterator it = progressListeners.iterator();
-
- while (it.hasNext())
+ if (progressListeners != null)
{
- IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
- listener.writeAborted(this);
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener =
+ (IIOWriteProgressListener) it.next();
+ listener.writeAborted(this);
+ }
}
}
+ /**
+ * Uninstall all write progress listeners.
+ */
public void removeAllIIOWriteProgressListeners()
{
- progressListeners.clear();
+ if (progressListeners != null)
+ {
+ progressListeners.clear();
+ }
}
+ /**
+ * Uninstall all write warning listeners.
+ */
public void removeAllIIOWriteWarningListeners()
{
- progressListeners.clear();
+ if (progressListeners != null)
+ {
+ progressListeners.clear();
+ }
}
-
- public void removeIIOWriteProgressListener (IIOWriteProgressListener listener)
+
+ /**
+ * Uninstall the given write progress listener.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeIIOWriteProgressListener (IIOWriteProgressListener listener)
{
if (listener == null)
return;
-
- progressListeners.remove(listener);
+ if (progressListeners != null)
+ {
+ progressListeners.remove(listener);
+ }
}
-
+ /**
+ * Uninstall the given write warning listener.
+ *
+ * @param listener the listener to remove
+ */
public void removeIIOWriteWarningListener (IIOWriteWarningListener listener)
{
if (listener == null)
return;
-
- warningListeners.remove(listener);
+ if (warningListeners != null)
+ {
+ warningListeners.remove(listener);
+ }
}
-
+ /**
+ * Reset this writer's internal state.
+ */
public void reset()
{
setOutput(null);
@@ -343,6 +867,11 @@ public abstract class ImageWriter
clearAbortRequest();
}
+ /**
+ * Set the current locale or use the default locale.
+ *
+ * @param locale the locale to set, or null
+ */
public void setLocale(Locale locale)
{
if (locale != null)
@@ -362,6 +891,18 @@ public abstract class ImageWriter
this.locale = locale;
}
+ /**
+ * Set the output destination of the given object. The output
+ * destination must be set before many methods can be called on this
+ * writer. (see all ImageWriter methods that throw
+ * IllegalStateException). If input is null then the current input
+ * source will be removed.
+ *
+ * @param input the output destination object
+ *
+ * @exception IllegalArgumentException if input is not a valid input
+ * source for this writer and is not an ImageInputStream
+ */
public void setOutput(Object output)
{
if (output != null)
@@ -385,6 +926,464 @@ public abstract class ImageWriter
this.output = output;
}
+ /**
+ * Write an image stream, including thumbnails and metadata to the
+ * output stream. The output must have been set prior to this
+ * method being called. Metadata associated with the stream may be
+ * supplied, or it can be left null. IIOImage may contain raster
+ * data if this writer supports rasters, or it will contain a
+ * rendered image. Thumbnails are resized if need be. Image
+ * writing parameters may be specified to affect writing, or may be
+ * left null.
+ *
+ * @param streamMetadata metadata associated with this stream, or
+ * null
+ * @param image an IIOImage containing image data, metadata and
+ * thumbnails to be written
+ * @param param image writing parameters, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if image contains raster
+ * data but this writer does not support rasters
+ * @exception IllegalArgumentException if image is null
+ * @exception IOException if a write error occurs
+ */
public abstract void write (IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param)
throws IOException;
+
+ /**
+ * Complete inserting an empty image in the output stream.
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if inserting empty
+ * images is not supported
+ * @exception IllegalArgumentException if a call to
+ * prepareInsertEmpty was not called previous to this method being
+ * called (a sequence of prepareInsertEmpty calls must be terminated
+ * by a call to endInsertEmpty)
+ * @exception IllegalArgumentException if prepareWriteEmpty was
+ * called before this method being called (without a terminating
+ * call to endWriteEmpty)
+ * @exception IllegalArgumentException if prepareReplacePixels was
+ * called before this method being called (without a terminating
+ * call to endReplacePixels)
+ * @exception IOException if a write error occurs
+ */
+ public void endInsertEmpty ()
+ throws IOException
+ {
+ if (!canInsertEmpty(0))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Complete replacing pixels in an image in the output stream.
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if replacing pixels is
+ * not supported by this writer
+ * @exception IllegalArgumentException if prepareReplacePixels was
+ * not called before this method being called
+ * @exception IOException if a write error occurs
+ */
+ public void endReplacePixels ()
+ throws IOException
+ {
+ if (!canReplacePixels(0))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Complete writing an empty image to the image output stream.
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if writing empty images
+ * is not supported
+ * @exception IllegalArgumentException if a call to
+ * prepareWriteEmpty was not called previous to this method being
+ * called (a sequence of prepareWriteEmpty calls must be terminated
+ * by a call to endWriteEmpty)
+ * @exception IllegalArgumentException if prepareInsertEmpty was
+ * called before this method being called (without a terminating
+ * call to endInsertEmpty)
+ * @exception IllegalArgumentException if prepareReplacePixels was
+ * called before this method being called (without a terminating
+ * call to endReplacePixels)
+ * @exception IOException if a write error occurs
+ */
+ public void endWriteEmpty ()
+ throws IOException
+ {
+ if (!canWriteEmpty())
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Complete writing a sequence of images to the output stream. This
+ * method may patch header data and write out footer data.
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IllegalStateException if prepareWriteSequence has not
+ * been called
+ * @exception UnsupportedOperationException if writing a sequence of
+ * images is not supported
+ * @exception IOException if a write error occurs
+ */
+ public void endWriteSequence ()
+ throws IOException
+ {
+ checkOutputSet();
+ if (!canWriteSequence())
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Start inserting an empty image in the image output stream. All
+ * indices after the specified index are incremented. An index of
+ * -1 implies that the empty image should be appended to the end of
+ * the current image list.
+ *
+ * The insertion that this method call starts is not complete until
+ * endInsertEmpty is called. prepareInsertEmpty cannot be called
+ * again until endInsertEmpty is called and calls to
+ * prepareWriteEmpty and prepareInsertEmpty may not be intersperced.
+ *
+ * @param imageIndex the image index
+ * @param imageType the image type specifier
+ * @param width the image width
+ * @param height the image height
+ * @param imageMetadata the image metadata, or null
+ * @param thumbnails a list of thumbnails, or null
+ * @param param image write parameters, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if inserting empty
+ * images is not supported
+ * @exception IndexOutOfBoundsException if imageIndex is less than
+ * -1 or greater than the last index in the current image list
+ * @exception IllegalStateException if a previous call to
+ * prepareInsertEmpty was made (without a terminating call to
+ * endInsertEmpty)
+ * @exception IllegalStateException if a previous call to
+ * prepareWriteEmpty was made (without a terminating call to
+ * endWriteEmpty)
+ * @exception IllegalArgumentException if imageType is null or
+ * thumbnails contain non-BufferedImage objects
+ * @exception IllegalArgumentException if either width or height is
+ * less than 1
+ * @exception IOException if a write error occurs
+ */
+ public void prepareInsertEmpty (int imageIndex, ImageTypeSpecifier imageType,
+ int width, int height,
+ IIOMetadata imageMetadata,
+ List thumbnails,
+ ImageWriteParam param)
+ throws IOException
+ {
+ if (!canInsertEmpty(imageIndex))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Start the replacement of pixels within an image in the output
+ * stream. Output pixels will be clipped to lie within region.
+ *
+ * @param imageIndex the index of the image in which pixels are
+ * being replaced
+ * @param region the rectangle to which to limit pixel replacement
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if replacing pixels is
+ * not supported
+ * @exception IndexOutOfBoundsException if imageIndex is less than 0
+ * or greater than the last index in the current image list
+ * @exception IllegalStateException if a previous call to
+ * prepareReplacePixels was made (without a terminating call to
+ * endReplacePixels)
+ * @exception IllegalArgumentException if either region.width or
+ * region.height is less than 1, or if region is null
+ * @exception IOException if a write error occurs
+ */
+ public void prepareReplacePixels (int imageIndex, Rectangle region)
+ throws IOException
+ {
+ if (canReplacePixels(imageIndex))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Start writing an empty image to the end of the image output
+ * stream.
+ *
+ * The writing that this method call starts is not complete until
+ * endWriteEmpty is called. prepareWritetEmpty cannot be called
+ * again until endWriteEmpty is called and calls to
+ * prepareWriteEmpty and prepareInsertEmpty may not be intersperced.
+ *
+ * @param streamMetadata metadata associated with the stream, or null
+ * @param imageType the image type specifier
+ * @param width the image width
+ * @param height the image height
+ * @param imageMetadata the image metadata, or null
+ * @param thumbnails a list of thumbnails, or null
+ * @param param image write parameters, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if writing empty images
+ * is not supported
+ * @exception IndexOutOfBoundsException if imageIndex is less than
+ * -1 or greater than the last index in the current image list
+ * @exception IllegalStateException if a previous call to
+ * prepareInsertEmpty was made (without a terminating call to
+ * endInsertEmpty)
+ * @exception IllegalStateException if a previous call to
+ * prepareWriteEmpty was made (without a terminating call to
+ * endWriteEmpty)
+ * @exception IllegalArgumentException if imageType is null or
+ * thumbnails contain non-BufferedImage objects
+ * @exception IllegalArgumentException if either width or height is
+ * less than 1
+ * @exception IOException if a write error occurs
+ */
+ public void prepareWriteEmpty (IIOMetadata streamMetadata,
+ ImageTypeSpecifier imageType,
+ int width, int height,
+ IIOMetadata imageMetadata,
+ List thumbnails,
+ ImageWriteParam param)
+ throws IOException
+ {
+ if (!canWriteEmpty())
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Start the writing of a sequence of images.
+ *
+ * @param streamMetadata the stream metadata, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if writing sequences of
+ * images is not supported
+ * @exception IOException if a write error occurs
+ */
+ public void prepareWriteSequence (IIOMetadata streamMetadata)
+ throws IOException
+ {
+ checkOutputSet();
+ if (!canWriteSequence())
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Remove the image at the specified index from the output stream.
+ *
+ * @param imageIndex the frame index from which to remove the image
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if removing this image
+ * is not supported
+ * @exception IndexOutOfBoundsException if imageIndex is less than 0
+ * or greater than the last index in the current image list
+ * @exception IOException if a write error occurs
+ */
+ public void removeImage (int imageIndex)
+ throws IOException
+ {
+ if (!canRemoveImage(imageIndex))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Replace the metadata associated with the image at the given
+ * index.
+ *
+ * @param imageIndex the index of the image whose metadata should be
+ * replaced
+ * @param imageMetadata the metadata, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if replacing this
+ * image's metadata is not supported
+ * @exception IndexOutOfBoundsException if imageIndex is less than 0
+ * or greater than the last index in the current image list
+ * @exception IOException if a write error occurs
+ */
+ public void replaceImageMetadata (int imageIndex, IIOMetadata imageMetadata)
+ throws IOException
+ {
+ if (!canReplaceImageMetadata(imageIndex))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Replace a region of an image in the output stream with a portion
+ * of the given rendered image. The image data must be of the same
+ * type as that in the output stream. The destination region is
+ * given by the image writing parameters and the source region is
+ * the one given to prepareReplacePixels.
+ *
+ * @param image the rendered image with which to overwrite the image
+ * region in the stream
+ * @param param the image writing parameters
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if replacing pixels is
+ * not supported
+ * @exception IllegalStateException if prepareReplacePixels was not
+ * called before this method was called
+ * @exception IllegalArgumentException if image is null or if param
+ * is null or if the overlap of the source and destination regions
+ * contains no pixels or if the image types differ and no conversion
+ * is possible
+ * @exception IOException if a write error occurs
+ */
+ public void replacePixels (RenderedImage image,
+ ImageWriteParam param)
+ throws IOException
+ {
+ if (!canReplacePixels(0))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Replace a region of an image in the output stream with a portion
+ * of the given raster data. The image data must be of the same
+ * type as that in the output stream. The destination region is
+ * given by the image writing parameters and the source region is
+ * the one given to prepareReplacePixels.
+ *
+ * @param raster the raster data with which to overwrite the image
+ * region in the stream
+ * @param param the image writing parameters
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if replacing pixels is
+ * not supported
+ * @exception IllegalStateException if prepareReplacePixels was not
+ * called before this method was called
+ * @exception UnsupportedOperationException if raster data is not
+ * supported
+ * @exception IllegalArgumentException if raster is null or if param
+ * is null or if the overlap of the source and destination regions
+ * contains no pixels or if the image types differ and no conversion
+ * is possible
+ * @exception IOException if a write error occurs
+ */
+ public void replacePixels (Raster raster, ImageWriteParam param)
+ throws IOException
+ {
+ if (!canReplacePixels(0))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Replace the metadata associated with this image stream.
+ *
+ * @param streamMetadata the stream metadata, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if replacing the stream
+ * metadata is not supported
+ * @exception IOException if a write error occurs
+ */
+ public void replaceStreamMetadata (IIOMetadata streamMetadata)
+ throws IOException
+ {
+ if (!canReplaceStreamMetadata())
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Write a rendered image to the output stream.
+ *
+ * @param image a rendered image containing image data to be written
+ *
+ * @exception IllegalStateException if output is null
+ * @exception IllegalArgumentException if image is null
+ * @exception IOException if a write error occurs
+ */
+ public void write (RenderedImage image)
+ throws IOException
+ {
+ checkOutputSet();
+ write (null, new IIOImage(image, null, null), null);
+ }
+
+ /**
+ * Write a image data, metadata and thumbnails to the output stream.
+ *
+ * @param image image data, metadata and thumbnails to be written
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if image contains raster
+ * data but this writer does not support rasters
+ * @exception IllegalArgumentException if image is null
+ * @exception IOException if a write error occurs
+ */
+ public void write (IIOImage image)
+ throws IOException
+ {
+ checkOutputSet();
+ write (null, image, null);
+ }
+
+ /**
+ * Insert an image into the output stream. Indices greater than the
+ * specified index are incremented accordingly. Specifying an index
+ * of -1 causes the image to be appended at the end of the current
+ * image list.
+ *
+ * @param imageIndex the frame index at which to insert the image
+ * @param image the image data, metadata and thumbnails to be
+ * inserted
+ * @param the image write parameters, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if image insertion is
+ * not supported
+ * @exception IllegalArgumentException if image is null
+ * @exception IndexOutOfBoundsException if imageIndex is less than
+ * -1 or greater than the last index in the current image list
+ * @exception UnsupportedOperationException if image contains raster
+ * data but this writer does not support rasters
+ * @exception IOException if a write error occurs
+ */
+ public void writeInsert (int imageIndex, IIOImage image, ImageWriteParam param)
+ throws IOException
+ {
+ if (!canInsertImage(imageIndex))
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Write a sequence of images, including thumbnails and metadata, to
+ * the output stream. The output must have been set prior to this
+ * method being called. Metadata associated with the stream may be
+ * supplied, or it can be left null. IIOImage may contain raster
+ * data if this writer supports rasters, or it will contain a
+ * rendered image. Thumbnails are resized if need be. Image
+ * writing parameters may be specified to affect writing, or may be
+ * left null.
+ *
+ * @param streamMetadata metadata associated with this stream, or
+ * null
+ * @param image an IIOImage containing image data, metadata and
+ * thumbnails to be written
+ * @param param image writing parameters, or null
+ *
+ * @exception IllegalStateException if output is null
+ * @exception UnsupportedOperationException if writing sequences of
+ * images is not supported
+ * @exception IllegalArgumentException if image is null
+ * @exception UnsupportedOperationException if image contains raster
+ * data but this writer does not support rasters
+ * @exception IOException if a write error occurs
+ */
+ public void writeToSequence (IIOImage image, ImageWriteParam param)
+ throws IOException
+ {
+ if (!canWriteSequence())
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/javax/imageio/metadata/IIOAttr.java b/javax/imageio/metadata/IIOAttr.java
deleted file mode 100644
index 0c1d3d2ef..000000000
--- a/javax/imageio/metadata/IIOAttr.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/* IIOAttr.java --
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package javax.imageio.metadata;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.TypeInfo;
-import org.w3c.dom.UserDataHandler;
-
-/**
- * Simple Attr node for metadata trees
- *
- * @author jlquinn
- */
-class IIOAttr implements Attr
-{
- String name;
- String value;
- IIOMetadataNode owner;
-
- public IIOAttr(String name, String value, IIOMetadataNode owner)
- {
- this.name = name;
- this.value = value;
- this.owner = owner;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Attr#getName()
- */
- public String getName()
- {
- return name;
- }
-
- public TypeInfo getSchemaTypeInfo()
- {
- throw new Error("not implemented");
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Attr#getSpecified()
- */
- public boolean getSpecified()
- {
- // I don't think there can be default attrs in metadata
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Attr#getValue()
- */
- public String getValue()
- {
- return value;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Attr#setValue(java.lang.String)
- */
- public void setValue(String value) throws DOMException
- {
- this.value = value;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Attr#getOwnerElement()
- */
- public Element getOwnerElement()
- {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getNodeName()
- */
- public String getNodeName()
- {
- return name;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getNodeValue()
- */
- public String getNodeValue() throws DOMException
- {
- return value;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#setNodeValue(java.lang.String)
- */
- public void setNodeValue(String nodeValue) throws DOMException
- {
- this.value = nodeValue;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getNodeType()
- */
- public short getNodeType()
- {
- return ATTRIBUTE_NODE;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getParentNode()
- */
- public Node getParentNode()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getChildNodes()
- */
- public NodeList getChildNodes()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getFirstChild()
- */
- public Node getFirstChild()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getLastChild()
- */
- public Node getLastChild()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getPreviousSibling()
- */
- public Node getPreviousSibling()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getNextSibling()
- */
- public Node getNextSibling()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getAttributes()
- */
- public NamedNodeMap getAttributes()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getOwnerDocument()
- */
- public Document getOwnerDocument()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
- */
- public Node replaceChild(Node newChild, Node oldChild) throws DOMException
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
- */
- public Node removeChild(Node oldChild) throws DOMException
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
- */
- public Node appendChild(Node newChild) throws DOMException
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#hasChildNodes()
- */
- public boolean hasChildNodes()
- {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#cloneNode(boolean)
- */
- public Node cloneNode(boolean deep)
- {
- return new IIOAttr(name, value, owner);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#normalize()
- */
- public void normalize()
- {
- }
-
- public boolean isDefaultNamespace(String namespaceURI)
- {
- throw new Error("not implemented");
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#isSupported(java.lang.String, java.lang.String)
- */
- public boolean isSupported(String feature, String version)
- {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getNamespaceURI()
- */
- public String getNamespaceURI()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getPrefix()
- */
- public String getPrefix()
- {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#setPrefix(java.lang.String)
- */
- public void setPrefix(String prefix) throws DOMException
- {
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#getLocalName()
- */
- public String getLocalName()
- {
- return name;
- }
-
- public Object getUserData(String key)
- {
- throw new Error("not implemented");
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.Node#hasAttributes()
- */
- public boolean hasAttributes()
- {
- return false;
- }
-
- public boolean isId()
- {
- throw new Error("not implemented");
- }
-
- public String lookupNamespaceURI(String prefix)
- {
- throw new Error("not implemented");
- }
-
- public String lookupPrefix(String namespaceURI)
- {
- throw new Error("not implemented");
- }
-
- public Object setUserData(String key, Object data, UserDataHandler handler)
- {
- throw new Error("not implemented");
- }
-
- public String getBaseURI()
- {
- throw new Error("not implemented");
- }
-
- public String getTextContent()
- {
- throw new Error("not implemented");
- }
-
- public void setTextContent(String textContent)
- {
- throw new Error("not implemented");
- }
-
- public short compareDocumentPosition(Node other)
- throws DOMException
- {
- throw new Error("not implemented");
- }
-
- public Object getFeature(String feature, String version)
- {
- throw new Error("not implemented");
- }
-
- public boolean isEqualNode(Node other)
- {
- throw new Error("not implemented");
- }
-
- public boolean isSameNode(Node other)
- {
- throw new Error("not implemented");
- }
-}
diff --git a/javax/imageio/metadata/IIOMetadata.java b/javax/imageio/metadata/IIOMetadata.java
index d727e1d1e..e5105de2c 100644
--- a/javax/imageio/metadata/IIOMetadata.java
+++ b/javax/imageio/metadata/IIOMetadata.java
@@ -38,8 +38,41 @@ exception statement from your version. */
package javax.imageio.metadata;
+import org.w3c.dom.Node;
+
/**
+ * Represents metadata that describe an image or an image stream.
+ * Each ImageIO plugin will represent image data using an opaque
+ * object but all such objects should expose their internal
+ * information as a tree of IIOMetadataNodes.
+ *
+ * There are three formats of metadata that a plugin can support:
+ *
+ * <ul>
+ * <li>a "native" format</li>
+ * <li>a custom format</li>
+ * <li>a standard plugin-neutral format</li>
+ * </ul>
+ *
+ * If a plugin supports more than one format of metadata, the other
+ * formats can be retrieved by calling getMetadataFormatNames.
+ *
+ * The native format is used to transfer metadata from one image to
+ * another image of the same type, losslessly.
+ *
+ * The custom format describes the image metadata and exposes a tree
+ * of IIOMetadataNodes but its internal representation is specific to
+ * this plugin.
+ *
+ * The plugin-neutral format uses a generic tree structure as its
+ * internal representation.
+ *
+ * ImageTranscoders may be used to convert metadata understood by one
+ * plugin to metadata understood by another, however the conversion
+ * may be lossy.
+ *
* @author Michael Koch (konqueror@gmx.de)
+ * @author Thomas Fitzsimmons (fitzsim@redhat.com)
*/
public abstract class IIOMetadata
{
@@ -52,7 +85,7 @@ public abstract class IIOMetadata
protected boolean standardFormatSupported;
/**
- * Creates a <code>IIOMetaData</code> object.
+ * Construct an IIOMetadata object.
*/
protected IIOMetadata()
{
@@ -60,7 +93,7 @@ public abstract class IIOMetadata
}
/**
- * Creates a <code>IIOMetaData</code> object with the given arguments.
+ * Construct an IIOMetadata object.
*
* @param standardMetadataFormatSupported
* @param nativeMetadataFormatName
@@ -210,4 +243,81 @@ public abstract class IIOMetadata
{
this.controller = controller;
}
+
+ public abstract Node getAsTree (String formatName);
+
+ protected IIOMetadataNode getStandardChromaNode ()
+ {
+ return null;
+ }
+
+ protected IIOMetadataNode getStandardCompressionNode ()
+ {
+ return null;
+ }
+
+ protected IIOMetadataNode getStandardDataNode ()
+ {
+ return null;
+ }
+
+ protected IIOMetadataNode getStandardDimensionNode ()
+ {
+ return null;
+ }
+
+ protected IIOMetadataNode getStandardDocumentNode ()
+ {
+ return null;
+ }
+
+ protected IIOMetadataNode getStandardTextNode ()
+ {
+ return null;
+ }
+
+ protected IIOMetadataNode getStandardTileNode ()
+ {
+ return null;
+ }
+
+ protected IIOMetadataNode getStandardTransparencyNode ()
+ {
+ return null;
+ }
+
+ private void appendChild (IIOMetadataNode node,
+ IIOMetadataNode child)
+ {
+ if (child != null)
+ node.appendChild(child);
+ }
+
+ protected final IIOMetadataNode getStandardTree ()
+ {
+ IIOMetadataNode node = new IIOMetadataNode();
+
+ appendChild (node, getStandardChromaNode());
+ appendChild (node, getStandardCompressionNode());
+ appendChild (node, getStandardDataNode());
+ appendChild (node, getStandardDimensionNode());
+ appendChild (node, getStandardDocumentNode());
+ appendChild (node, getStandardTextNode());
+ appendChild (node, getStandardTileNode());
+ appendChild (node, getStandardTransparencyNode());
+
+ return node;
+ }
+
+ public abstract void mergeTree (String formatName,
+ Node root)
+ throws IIOInvalidTreeException;
+
+ public void setFromTree (String formatName, Node root)
+ throws IIOInvalidTreeException
+ {
+ reset();
+
+ mergeTree (formatName, root);
+ }
}
diff --git a/javax/imageio/metadata/IIOMetadataFormatImpl.java b/javax/imageio/metadata/IIOMetadataFormatImpl.java
index 2ce8f9c3d..aad30447c 100644
--- a/javax/imageio/metadata/IIOMetadataFormatImpl.java
+++ b/javax/imageio/metadata/IIOMetadataFormatImpl.java
@@ -38,6 +38,848 @@ exception statement from your version. */
package javax.imageio.metadata;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.UserDataHandler;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import javax.imageio.ImageTypeSpecifier;
+
public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat
{
+ /**
+ * The standard metadata format name constant set to
+ * "javax_imageio_1.0".
+ */
+ public static final String standardMetadataFormatName = "javax_imageio_1.0";
+
+ private String rootName;
+
+ // These maps assume that each element name is unique.
+
+ private Map nodes = new HashMap();
+
+ // A mapping from element name to child policy.
+ private Map childPolicies = new HashMap();
+
+ // A mapping from element name to the permissible number of
+ // children. Values in this map are length-two integer arrays; the
+ // first index is the minimum bound, the second index is the maximum
+ // bound.
+ private Map childRanges = new HashMap();
+
+ private String resourceBaseName;
+
+ // Package-private so that it may be used in IIOMetadataNode.
+ static class IIOMetadataNodeAttr extends IIOMetadataNode
+ implements Attr
+ {
+ protected Element owner;
+ protected String name;
+ protected int dataType;
+ protected boolean required;
+ protected String defaultValue;
+
+ public IIOMetadataNodeAttr (Element owner,
+ String name,
+ String defaultValue)
+ {
+ this (owner, name, IIOMetadataFormat.DATATYPE_STRING,
+ true, defaultValue);
+ }
+
+ public IIOMetadataNodeAttr (Element owner,
+ String name,
+ int dataType,
+ boolean required,
+ String defaultValue)
+ {
+ this.owner = owner;
+ this.name = name;
+ this.dataType = dataType;
+ this.required = required;
+ this.defaultValue = defaultValue;
+ }
+
+ public String getName ()
+ {
+ return name;
+ }
+
+ public Element getOwnerElement ()
+ {
+ return owner;
+ }
+
+ public int getDataType ()
+ {
+ return dataType;
+ }
+
+ public TypeInfo getSchemaTypeInfo ()
+ {
+ return null;
+ }
+
+ public boolean getSpecified ()
+ {
+ return false;
+ }
+
+ public String getValue ()
+ {
+ return defaultValue;
+ }
+
+ public boolean isId()
+ {
+ return false;
+ }
+
+ public void setValue (String value)
+ {
+ }
+
+ // new methods
+
+ public boolean isRequired ()
+ {
+ return required;
+ }
+ }
+
+ private class IIOMetadataNodeAttrEnumerated extends IIOMetadataNodeAttr
+ {
+ protected List enumeratedValues;
+
+ public IIOMetadataNodeAttrEnumerated (Element owner,
+ String name,
+ int dataType,
+ boolean required,
+ String defaultValue,
+ List enumeratedValues)
+ {
+ super (owner, name, dataType, required, defaultValue);
+ this.enumeratedValues = new ArrayList (enumeratedValues);
+ }
+
+ public Object[] getEnumerations ()
+ {
+ return enumeratedValues.toArray ();
+ }
+ }
+
+ private class IIOMetadataNodeAttrBounded extends IIOMetadataNodeAttr
+ {
+ protected String minValue;
+ protected String maxValue;
+ protected boolean minInclusive;
+ protected boolean maxInclusive;
+
+ public IIOMetadataNodeAttrBounded (Element owner,
+ String name,
+ int dataType,
+ boolean required,
+ String defaultValue,
+ String minValue,
+ String maxValue,
+ boolean minInclusive,
+ boolean maxInclusive)
+ {
+ super (owner, name, dataType, required, defaultValue);
+ this.minValue = minValue;
+ this.maxValue = maxValue;
+ this.minInclusive = minInclusive;
+ this.maxInclusive = maxInclusive;
+ }
+
+ public String getMinValue ()
+ {
+ return minValue;
+ }
+
+ public String getMaxValue ()
+ {
+ return maxValue;
+ }
+ }
+
+ private class IIOMetadataNodeAttrList extends IIOMetadataNodeAttr
+ {
+ protected int listMinLength;
+ protected int listMaxLength;
+
+ public IIOMetadataNodeAttrList (Element owner,
+ String name,
+ int dataType,
+ boolean required,
+ int listMinLength,
+ int listMaxLength)
+ {
+ super (owner, name, dataType, required, null);
+ this.listMinLength = listMinLength;
+ this.listMaxLength = listMaxLength;
+ }
+
+ public int getListMinLength ()
+ {
+ return listMinLength;
+ }
+
+ public int getListMaxLength ()
+ {
+ return listMaxLength;
+ }
+ }
+
+ private class NodeObject
+ {
+ protected Element owner;
+ protected Class classType;
+ protected boolean required;
+ protected Object defaultValue;
+ protected int valueType;
+
+ public NodeObject (Element owner,
+ Class classType,
+ boolean required,
+ Object defaultValue)
+ {
+ this.owner = owner;
+ this.classType = classType;
+ this.required = required;
+ this.defaultValue = defaultValue;
+ valueType = IIOMetadataFormat.VALUE_ARBITRARY;
+ }
+
+ public int getValueType ()
+ {
+ return valueType;
+ }
+
+ public Class getClassType ()
+ {
+ return classType;
+ }
+
+ public Element getOwnerElement ()
+ {
+ return owner;
+ }
+
+ public Object getDefaultValue ()
+ {
+ return defaultValue;
+ }
+
+ public boolean isRequired ()
+ {
+ return required;
+ }
+ }
+
+ private class NodeObjectEnumerated extends NodeObject
+ {
+ protected List enumeratedValues;
+
+ public NodeObjectEnumerated (Element owner,
+ Class classType,
+ boolean required,
+ Object defaultValue,
+ List enumeratedValues)
+ {
+ super (owner, classType, false, defaultValue);
+ this.enumeratedValues = enumeratedValues;
+ valueType = IIOMetadataFormat.VALUE_ENUMERATION;
+ }
+
+ public Object[] getEnumerations ()
+ {
+ return enumeratedValues.toArray();
+ }
+ }
+
+ private class NodeObjectBounded extends NodeObject
+ {
+ protected Comparable minValue;
+ protected Comparable maxValue;
+ protected boolean minInclusive;
+ protected boolean maxInclusive;
+
+ public NodeObjectBounded (Element owner,
+ Class classType,
+ Object defaultValue,
+ Comparable minValue,
+ Comparable maxValue,
+ boolean minInclusive,
+ boolean maxInclusive)
+ {
+ super (owner, classType, false, defaultValue);
+ this.minValue = minValue;
+ this.maxValue = maxValue;
+ this.minInclusive = minInclusive;
+ this.maxInclusive = maxInclusive;
+ if (minInclusive)
+ {
+ if (maxInclusive)
+ valueType = IIOMetadataFormat.VALUE_RANGE_MIN_MAX_INCLUSIVE;
+ else
+ valueType = IIOMetadataFormat.VALUE_RANGE_MIN_INCLUSIVE;
+ }
+ else
+ {
+ if (maxInclusive)
+ valueType = IIOMetadataFormat.VALUE_RANGE_MAX_INCLUSIVE;
+ else
+ valueType = IIOMetadataFormat.VALUE_RANGE;
+ }
+ }
+
+ public Comparable getMinValue ()
+ {
+ return minValue;
+ }
+
+ public Comparable getMaxValue ()
+ {
+ return maxValue;
+ }
+ }
+
+ private class NodeObjectArray extends NodeObject
+ {
+ protected Integer arrayMinLength;
+ protected Integer arrayMaxLength;
+
+ public NodeObjectArray (Element owner,
+ Class classType,
+ int arrayMinLength,
+ int arrayMaxLength)
+ {
+ super (owner, classType, false, null);
+ this.arrayMinLength = new Integer (arrayMinLength);
+ this.arrayMaxLength = new Integer (arrayMaxLength);
+ valueType = IIOMetadataFormat.VALUE_LIST;
+ }
+
+ public Comparable getArrayMinLength ()
+ {
+ return arrayMinLength;
+ }
+
+ public Comparable getArrayMaxLength ()
+ {
+ return arrayMaxLength;
+ }
+ }
+
+ /**
+ * Construct a blank IIOMetadataFormatImpl with the given root name
+ * and child policy.
+ *
+ * @param rootName the root element name
+ * @param childPolicy the child policy of the root element
+ *
+ * @exception IllegalArgumentException if rootName is null
+ * @exception IllegalArgumentException if childPolicy is
+ * CHILD_POLICY_REPEAT or if childPolicy is not a CHILD_POLICY
+ * constant
+ */
+ public IIOMetadataFormatImpl (String rootName, int childPolicy)
+ {
+ if (rootName == null)
+ throw new IllegalArgumentException ("null argument");
+
+ if (childPolicy < IIOMetadataFormat.CHILD_POLICY_ALL
+ || childPolicy > IIOMetadataFormat.CHILD_POLICY_SOME
+ || childPolicy == IIOMetadataFormat.CHILD_POLICY_REPEAT)
+ throw new IllegalArgumentException ("wrong child policy");
+
+ nodes.put (rootName, new IIOMetadataNode (rootName));
+ childPolicies.put (rootName, new Integer (childPolicy));
+ this.rootName = rootName;
+ }
+
+ /**
+ * Construct a blank IIOMetadataFormatImpl with the given root name,
+ * a child policy of CHILD_POLICY_REPEAT and the given minimum and
+ * maximum limits on the number of root element children.
+ *
+ * @param rootName the root element name
+ * @param minChildren the minimum number of children that this node
+ * can have
+ * @param maxChildren the maximum number of children that this node
+ * can have
+ *
+ * @exception IllegalArgumentException if rootName is null
+ * @exception IllegalArgumentException if minChildren is less than
+ * zero or greater than maxChildren
+ */
+ public IIOMetadataFormatImpl (String rootName,
+ int minChildren,
+ int maxChildren)
+ {
+ if (rootName == null)
+ throw new IllegalArgumentException ("null argument");
+
+ if (minChildren < 0 || maxChildren < minChildren)
+ throw new IllegalArgumentException ("invalid min or max children argument");
+
+ nodes.put (rootName, new IIOMetadataNode (rootName));
+ childPolicies.put (rootName, new Integer (IIOMetadataFormat.CHILD_POLICY_REPEAT));
+ childRanges.put (rootName, new int [] { minChildren, maxChildren });
+ this.rootName = rootName;
+ }
+
+ protected void addAttribute (String elementName,
+ String attrName,
+ int dataType,
+ boolean required,
+ String defaultValue)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ node.setAttributeNode (new IIOMetadataNodeAttr (node,
+ attrName,
+ dataType,
+ required,
+ defaultValue));
+ }
+
+ protected void addAttribute (String elementName,
+ String attrName,
+ int dataType,
+ boolean required,
+ String defaultValue,
+ List enumeratedValues)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ node.setAttributeNode (new IIOMetadataNodeAttrEnumerated (node,
+ attrName,
+ dataType,
+ required,
+ defaultValue,
+ enumeratedValues));
+ }
+
+ protected void addAttribute (String elementName,
+ String attrName,
+ int dataType,
+ boolean required,
+ String defaultValue,
+ String minValue,
+ String maxValue,
+ boolean minInclusive,
+ boolean maxInclusive)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ node.setAttributeNode (new IIOMetadataNodeAttrBounded (node,
+ attrName,
+ dataType,
+ required,
+ defaultValue,
+ minValue,
+ maxValue,
+ minInclusive,
+ maxInclusive));
+ }
+
+ protected void addAttribute (String elementName,
+ String attrName,
+ int dataType,
+ boolean required,
+ int listMinLength,
+ int listMaxLength)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ node.setAttributeNode (new IIOMetadataNodeAttrList (node,
+ attrName,
+ dataType,
+ required,
+ listMinLength,
+ listMaxLength));
+ }
+
+ protected void addBooleanAttribute (String elementName,
+ String attrName,
+ boolean hasDefaultValue,
+ boolean defaultValue)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+
+ List enumeratedValues = new ArrayList();
+ enumeratedValues.add ("TRUE");
+ enumeratedValues.add ("FALSE");
+
+ node.setAttributeNode (new IIOMetadataNodeAttrEnumerated (node,
+ attrName,
+ IIOMetadataFormat.DATATYPE_BOOLEAN,
+ hasDefaultValue,
+ defaultValue ? "TRUE" : "FALSE",
+ enumeratedValues));
+ }
+
+ protected void addChildElement (String elementName, String parentName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (parentName);
+
+ node.appendChild (new IIOMetadataNode (elementName));
+ childPolicies.put (elementName, new Integer (IIOMetadataFormat.CHILD_POLICY_REPEAT));
+ }
+
+ protected void addElement (String elementName, String parentName, int childPolicy)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (parentName);
+
+ node.appendChild (new IIOMetadataNode (elementName));
+ childPolicies.put (elementName, new Integer (childPolicy));
+ }
+
+ protected void addElement (String elementName, String parentName,
+ int minChildren, int maxChildren)
+ {
+ addChildElement (elementName, parentName);
+ childRanges.put (elementName, new int [] { minChildren, maxChildren });
+ }
+
+ private void addNodeObject (IIOMetadataNode node, NodeObject o)
+ {
+ node.setUserObject (o);
+ }
+
+ private NodeObject getNodeObject (IIOMetadataNode node)
+ {
+ return (NodeObject) node.getUserObject ();
+ }
+
+ private void removeNodeObject (IIOMetadataNode node)
+ {
+ node.setUserObject (null);
+ }
+
+ protected void addObjectValue (String elementName, Class classType,
+ boolean required, Object defaultValue)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ addNodeObject (node, new NodeObject (node,
+ classType,
+ required,
+ defaultValue));
+ }
+
+ protected void addObjectValue (String elementName, Class classType,
+ boolean required, Object defaultValue,
+ List enumeratedValues)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ addNodeObject (node, new NodeObjectEnumerated (node,
+ classType,
+ required,
+ defaultValue,
+ enumeratedValues));
+ }
+
+ protected void addObjectValue (String elementName, Class classType,
+ Object defaultValue,
+ Comparable minValue,
+ Comparable maxValue,
+ boolean minInclusive,
+ boolean maxInclusive)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ addNodeObject (node, new NodeObjectBounded (node,
+ classType,
+ defaultValue,
+ minValue,
+ maxValue,
+ minInclusive,
+ maxInclusive));
+ }
+
+ protected void addObjectValue (String elementName, Class classType,
+ int arrayMinLength, int arrayMaxLength)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ addNodeObject (node, new NodeObjectArray (node,
+ classType,
+ arrayMinLength,
+ arrayMaxLength));
+ }
+
+ public String getRootName ()
+ {
+ return rootName;
+ }
+
+ protected String getResourceBaseName ()
+ {
+ return resourceBaseName;
+ }
+
+ public static IIOMetadataFormat getStandardFormatInstance ()
+ {
+ // FIXME: populate this with the standard metadata format
+ return new IIOMetadataFormatImpl (standardMetadataFormatName,
+ IIOMetadataFormat.CHILD_POLICY_ALL)
+ {
+ public boolean canNodeAppear (String elementName,
+ ImageTypeSpecifier specifier)
+ {
+ return true;
+ }
+ };
+ }
+
+ public abstract boolean canNodeAppear (String elementName,
+ ImageTypeSpecifier specifier);
+
+ protected void removeAttribute (String elementName,
+ String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ node.removeAttribute (attrName);
+ }
+
+ protected void removeElement (String elementName)
+ {
+ nodes.remove (elementName);
+ }
+
+ protected void removeObjectValue (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ removeNodeObject (node);
+ }
+
+ protected void setResourceBaseName (String resourceBaseName)
+ {
+ this.resourceBaseName = resourceBaseName;
+ }
+
+ public int getAttributeDataType (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) node.getAttributeNode (attrName);
+ return attr.getDataType ();
+ }
+
+ public String getAttributeDefaultValue (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) node.getAttributeNode (attrName);
+ return attr.getValue();
+ }
+
+ public String getAttributeDescription (String elementName, String attrName, Locale locale)
+ {
+ return getDescription (elementName + "/" + attrName, locale);
+ }
+
+ public String[] getAttributeEnumerations (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttrEnumerated attr =
+ (IIOMetadataNodeAttrEnumerated) node.getAttributeNode (attrName);
+
+ Object[] attrEnums = attr.getEnumerations();
+
+ String[] attrNames = new String[attrEnums.length];
+
+ for (int i = 0; i < attrEnums.length; i++)
+ {
+ attrNames[i] = (String) attrEnums[i];
+ }
+
+ return attrNames;
+ }
+
+ public int getAttributeListMaxLength (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttrList attr =
+ (IIOMetadataNodeAttrList) node.getAttributeNode (attrName);
+ return attr.getListMaxLength();
+ }
+
+ public int getAttributeListMinLength (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttrList attr =
+ (IIOMetadataNodeAttrList) node.getAttributeNode (attrName);
+ return attr.getListMinLength();
+ }
+
+ public String getAttributeMaxValue (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttrBounded attr =
+ (IIOMetadataNodeAttrBounded) node.getAttributeNode (attrName);
+ return attr.getMaxValue();
+ }
+
+ public String getAttributeMinValue (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttrBounded attr =
+ (IIOMetadataNodeAttrBounded) node.getAttributeNode (attrName);
+ return attr.getMinValue();
+ }
+
+ public String[] getAttributeNames (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+
+ NamedNodeMap attrNodes = node.getAttributes();
+
+ String[] attrNames = new String[attrNodes.getLength()];
+
+ for (int i = 0; i < attrNodes.getLength(); i++)
+ {
+ attrNames[i] = attrNodes.item (i).getLocalName();
+ }
+
+ return attrNames;
+ }
+
+ public int getAttributeValueType (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) node.getAttributeNode (attrName);
+ return attr.getDataType();
+ }
+
+ public String[] getChildNames (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+
+ NodeList childNodes = node.getChildNodes();
+
+ String[] childNames = new String[childNodes.getLength()];
+
+ for (int i = 0; i < childNodes.getLength(); i++)
+ {
+ childNames[i] = childNodes.item (i).getLocalName();
+ }
+
+ return childNames;
+ }
+
+ public int getChildPolicy (String elementName)
+ {
+ return ((Integer) childPolicies.get (elementName)).intValue();
+ }
+
+ private String getDescription (String resourceName, Locale locale)
+ {
+ if (resourceBaseName == null)
+ return null;
+
+ Locale l = locale;
+
+ if (l == null)
+ l = Locale.getDefault();
+
+ ResourceBundle bundle = ResourceBundle.getBundle (resourceBaseName, locale);
+
+ String desc = null;
+
+ if (bundle == null)
+ {
+ try
+ {
+ desc = bundle.getString (resourceName);
+ }
+ catch (MissingResourceException e)
+ {
+ desc = null;
+ }
+ }
+
+ return desc;
+ }
+
+ public String getElementDescription (String elementName, Locale locale)
+ {
+ return getDescription (elementName, locale);
+ }
+
+ public int getElementMaxChildren (String elementName)
+ {
+ return ((int[]) childRanges.get (elementName))[1];
+ }
+
+ public int getElementMinChildren (String elementName)
+ {
+ return ((int[]) childRanges.get (elementName))[0];
+ }
+
+ public int getObjectArrayMaxLength (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return ((Integer) ((NodeObjectArray) getNodeObject (node)).getArrayMaxLength ()).intValue();
+ }
+
+ public int getObjectArrayMinLength (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return ((Integer) ((NodeObjectArray) getNodeObject (node)).getArrayMinLength ()).intValue();
+ }
+
+ public Class getObjectClass (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return getNodeObject (node).getClassType ();
+ }
+
+ public Object getObjectDefaultValue (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return getNodeObject (node).getDefaultValue ();
+ }
+
+ public Object[] getObjectEnumerations (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return ((NodeObjectEnumerated) getNodeObject (node)).getEnumerations ();
+ }
+
+ public Comparable getObjectMaxValue (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return ((NodeObjectBounded) getNodeObject (node)).getMaxValue ();
+ }
+
+ public Comparable getObjectMinValue (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return ((NodeObjectBounded) getNodeObject (node)).getMinValue ();
+ }
+
+ public int getObjectValueType (String elementName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ NodeObject n = getNodeObject (node);
+
+ if (n == null)
+ return IIOMetadataFormat.VALUE_NONE;
+ else
+ return n.getValueType ();
+ }
+
+ public boolean isAttributeRequired (String elementName, String attrName)
+ {
+ IIOMetadataNode node = (IIOMetadataNode) nodes.get (elementName);
+ return ((IIOMetadataNodeAttr) node.getAttributeNode (attrName)).isRequired();
+ }
}
diff --git a/javax/imageio/metadata/IIOMetadataNode.java b/javax/imageio/metadata/IIOMetadataNode.java
index d9e0983e9..2d52e4670 100644
--- a/javax/imageio/metadata/IIOMetadataNode.java
+++ b/javax/imageio/metadata/IIOMetadataNode.java
@@ -52,6 +52,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.TypeInfo;
import org.w3c.dom.UserDataHandler;
+import javax.imageio.metadata.IIOMetadataFormatImpl.IIOMetadataNodeAttr;
public class IIOMetadataNode
implements Element, NodeList
@@ -61,7 +62,127 @@ public class IIOMetadataNode
private List children = new ArrayList();
private IIOMetadataNode parent;
private Object obj;
+
+ /**
+ * Simple NamedNodeMap class for IIOMetadataNode.
+ *
+ * @author jlquinn
+ */
+ private class IIONamedNodeMap implements NamedNodeMap
+ {
+ HashMap attrs;
+
+ /**
+ * @param attrs
+ * @param node
+ */
+ public IIONamedNodeMap(HashMap attrs)
+ {
+ this.attrs = attrs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#getNamedItem(java.lang.String)
+ */
+ public Node getNamedItem(String name)
+ {
+ return (Node)attrs.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#setNamedItem(org.w3c.dom.Node)
+ */
+ public Node setNamedItem(Node arg) throws DOMException
+ {
+ if (arg instanceof IIOMetadataNodeAttr)
+ {
+ IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr) arg;
+ // The only code that can successfully do this is in this package.
+ if (attr.owner != null)
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, "");
+ return (Node)attrs.put(attr.name, attr);
+ }
+ // Anything else gets treated as an invalid op.
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#removeNamedItem(java.lang.String)
+ */
+ public Node removeNamedItem(String name) throws DOMException
+ {
+ return (Node)attrs.remove(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#item(int)
+ */
+ public Node item(int index)
+ {
+ return (Node)attrs.values().toArray()[index];
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#getLength()
+ */
+ public int getLength()
+ {
+ return attrs.size();
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#getNamedItemNS(java.lang.String, java.lang.String)
+ */
+ public Node getNamedItemNS(String namespaceURI, String localName)
+ {
+ return getNamedItem(localName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#setNamedItemNS(org.w3c.dom.Node)
+ */
+ public Node setNamedItemNS(Node arg) throws DOMException
+ {
+ return setNamedItem(arg);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NamedNodeMap#removeNamedItemNS(java.lang.String, java.lang.String)
+ */
+ public Node removeNamedItemNS(String namespaceURI, String localName)
+ throws DOMException
+ {
+ return removeNamedItem(localName);
+ }
+ }
+
+ /**
+ * Simple NodeList implementation for IIOMetadataNode.
+ *
+ * @author jlquinn
+ *
+ */
+ private class IIONodeList implements NodeList
+ {
+ List children = new ArrayList();
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NodeList#item(int)
+ */
+ public Node item(int index)
+ {
+ return (index < children.size()) ? (Node)children.get(index) : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.NodeList#getLength()
+ */
+ public int getLength()
+ {
+ return children.size();
+ }
+ }
+
public IIOMetadataNode()
{
// Do nothing here.
@@ -71,12 +192,12 @@ public class IIOMetadataNode
{
name = nodename;
}
-
+
public Object getUserObject()
{
return obj;
}
-
+
public void setUserObject(Object o)
{
obj = o;
@@ -85,7 +206,7 @@ public class IIOMetadataNode
public short compareDocumentPosition(Node other)
throws DOMException
{
- throw new Error("not implemented");
+ return Element.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
}
/* (non-Javadoc)
@@ -104,7 +225,7 @@ public class IIOMetadataNode
{
String val = getAttribute(name);
if (val != null)
- return new IIOAttr(name, val, this);
+ return new IIOMetadataNodeAttr(this, name, val);
return null;
}
@@ -126,7 +247,7 @@ public class IIOMetadataNode
public String getBaseURI()
{
- throw new Error("not implemented");
+ return null;
}
// Recursive function for assembling a node list.
@@ -217,7 +338,7 @@ public class IIOMetadataNode
if (attr != null)
attr.setValue(value);
else
- attrs.put(name, new IIOAttr(name, value, this));
+ attrs.put(name, new IIOMetadataNodeAttr(this, name, value));
}
/* (non-Javadoc)
@@ -295,7 +416,7 @@ public class IIOMetadataNode
// clone attrs
for (Iterator it = attrs.values().iterator(); it.hasNext();)
{
- IIOAttr attr = (IIOAttr)it.next();
+ IIOMetadataNodeAttr attr = (IIOMetadataNodeAttr)it.next();
newnode.attrs.put(attr.name, attr.cloneNode(deep));
attr.owner = newnode;
}
@@ -321,7 +442,7 @@ public class IIOMetadataNode
public Object getFeature(String feature, String version)
{
- throw new Error("not implemented");
+ return null;
}
/* (non-Javadoc)
@@ -432,18 +553,18 @@ public class IIOMetadataNode
public TypeInfo getSchemaTypeInfo()
{
- throw new Error("not implemented");
+ return null;
}
public String getTextContent()
throws DOMException
{
- throw new Error("not implemented");
+ return null;
}
public Object getUserData(String key)
{
- throw new Error("not implemented");
+ return null;
}
/* (non-Javadoc)
@@ -482,12 +603,12 @@ public class IIOMetadataNode
public boolean isDefaultNamespace(String namespaceURI)
{
- throw new Error("not implemented");
+ return true;
}
public boolean isEqualNode(Node arg)
{
- throw new Error("not implemented");
+ return true;
}
public boolean isSameNode(Node other)
@@ -506,12 +627,12 @@ public class IIOMetadataNode
public String lookupNamespaceURI(String prefix)
{
- throw new Error("not implemented");
+ return null;
}
public String lookupPrefix(String namespaceURI)
{
- throw new Error("not implemented");
+ return null;
}
/* (non-Javadoc)
@@ -550,19 +671,16 @@ public class IIOMetadataNode
public void setIdAttribute(String name, boolean isId)
throws DOMException
{
- throw new Error("not implemented");
}
public void setIdAttributeNode(Attr idAttr, boolean isId)
throws DOMException
{
- throw new Error("not implemented");
}
public void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
throws DOMException
{
- throw new Error("not implemented");
}
/* (non-Javadoc)
@@ -582,11 +700,10 @@ public class IIOMetadataNode
public void setTextContent(String textContent)
throws DOMException
{
- throw new Error("not implemented");
}
public Object setUserData(String key, Object data, UserDataHandler handler)
{
- throw new Error("not implemented");
+ return null;
}
}
diff --git a/javax/imageio/metadata/IIONamedNodeMap.java b/javax/imageio/metadata/IIONamedNodeMap.java
deleted file mode 100644
index 92da28d5b..000000000
--- a/javax/imageio/metadata/IIONamedNodeMap.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/* IIONamedNodeMap.java --
- Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package javax.imageio.metadata;
-
-import java.util.HashMap;
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * Simple NamedNodeMap class for IIOMetadataNode.
- *
- * @author jlquinn
- */
-class IIONamedNodeMap implements NamedNodeMap
-{
- HashMap attrs;
-
- /**
- * @param attrs
- * @param node
- */
- public IIONamedNodeMap(HashMap attrs)
- {
- this.attrs = attrs;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#getNamedItem(java.lang.String)
- */
- public Node getNamedItem(String name)
- {
- return (Node)attrs.get(name);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#setNamedItem(org.w3c.dom.Node)
- */
- public Node setNamedItem(Node arg) throws DOMException
- {
- if (arg instanceof IIOAttr)
- {
- IIOAttr attr = (IIOAttr) arg;
- // The only code that can successfully do this is in this package.
- if (attr.owner != null)
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, "");
- return (Node)attrs.put(attr.name, attr);
- }
- // Anything else gets treated as an invalid op.
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "");
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#removeNamedItem(java.lang.String)
- */
- public Node removeNamedItem(String name) throws DOMException
- {
- return (Node)attrs.remove(name);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#item(int)
- */
- public Node item(int index)
- {
- return (Node)attrs.values().toArray()[index];
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#getLength()
- */
- public int getLength()
- {
- return attrs.size();
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#getNamedItemNS(java.lang.String, java.lang.String)
- */
- public Node getNamedItemNS(String namespaceURI, String localName)
- {
- return getNamedItem(localName);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#setNamedItemNS(org.w3c.dom.Node)
- */
- public Node setNamedItemNS(Node arg) throws DOMException
- {
- return setNamedItem(arg);
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NamedNodeMap#removeNamedItemNS(java.lang.String, java.lang.String)
- */
- public Node removeNamedItemNS(String namespaceURI, String localName)
- throws DOMException
- {
- return removeNamedItem(localName);
- }
-
-}
diff --git a/javax/imageio/metadata/IIONodeList.java b/javax/imageio/metadata/IIONodeList.java
deleted file mode 100644
index 395d261b6..000000000
--- a/javax/imageio/metadata/IIONodeList.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* IIOAttr.java --
- Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package javax.imageio.metadata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Simple NodeList implementation for IIOMetadataNode.
- *
- * @author jlquinn
- *
- */
-class IIONodeList implements NodeList
-{
- List children = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NodeList#item(int)
- */
- public Node item(int index)
- {
- return (index < children.size()) ? (Node)children.get(index) : null;
- }
-
- /* (non-Javadoc)
- * @see org.w3c.dom.NodeList#getLength()
- */
- public int getLength()
- {
- return children.size();
- }
-
-}
diff --git a/javax/imageio/package.html b/javax/imageio/package.html
index ce36a7b44..f6a604de8 100644
--- a/javax/imageio/package.html
+++ b/javax/imageio/package.html
@@ -40,7 +40,48 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.imageio</title></head>
<body>
-<p></p>
-
+<p>
+This package provides image input/output APIs.
+</p>
+<p>
+The standard class library provides other ways of loading images (@see
+java.awt.Toolkit, @see java.awt.Component)) but the ImageIO package is
+more powerful.
+</p>
+<p>
+The static ImageIO class supports reading and writing images in many
+different formats along with most other basic image I/O operations.
+</p>
+<p>
+Other classes provide finer control of image-related operations;
+reading is controlled by ImageReader, ImageReadParam and
+ImageTypeSpecifyer, writing by ImageWriter and ImageWriteParam.
+ImageTranscoder allows fine-grained control over how images are
+converted between formats and IIOException reports errors. IIOImage
+describes an image file in detail including metadata and thumbnails.
+</p>
+<h2>Supported Formats</h2>
+<p>
+The default GNU Classpath ImageIO backend uses ImageMagick and so
+supports the following formats:
+<table>
+<tr>
+<th></th> <th>Read</th> <th>Write</th>
+</tr>
+<tr><td>JPEG</td><td>yes</td><td>yes</td></tr>
+<tr><td>PNG</td><td>yes</td><td>yes</td></tr>
+<tr><td>BMP</td><td>yes</td><td>yes</td></tr>
+<tr><td>WBMP</td><td>yes</td><td>yes</td></tr>
+<tr><td>GIF</td><td>yes</td><td>yes</td></tr>
+<tr><td>TIFF</td><td>yes</td><td>yes</td></tr>
+<tr><td>XPM</td><td>yes</td><td>yes</td></tr>
+<tr><td>TGA</td><td>yes</td><td>yes</td></tr>
+<tr><td>PDF</td><td>yes</td><td>no</td></tr>
+<tr><td>SVG</td><td>yes</td><td>no</td></tr>
+<table>
+</p>
+<p>
+@since 1.4
+</p>
</body>
</html>
diff --git a/javax/imageio/spi/ImageReaderWriterSpi.java b/javax/imageio/spi/ImageReaderWriterSpi.java
index 4aa7fd412..40d44e3d0 100644
--- a/javax/imageio/spi/ImageReaderWriterSpi.java
+++ b/javax/imageio/spi/ImageReaderWriterSpi.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.imageio.spi;
+import javax.imageio.metadata.IIOMetadataFormat;
+import javax.imageio.metadata.IIOMetadataFormatImpl;
/**
* An abstract superclass that contains the common parts of {@link
@@ -422,4 +424,88 @@ public abstract class ImageReaderWriterSpi
{
return extraImageMetadataFormatNames;
}
+
+ /**
+ * Returns an IIOMetadataFormat object that represents the requested
+ * stream metadata format or null if the given format is supported
+ * but no IIOMetadataFormat can be created for it.
+ *
+ * @param formatName the requested stream metadata format name
+ *
+ * @return an IIOMetadataFormat object or null
+ *
+ * @throws IllegalArgumentException if formatName is null or is not
+ * one of the standard metadata format or this provider's native or
+ * extra stream metadata formats
+ */
+ public IIOMetadataFormat getStreamMetadataFormat (String formatName)
+ {
+ if (formatName == null)
+ throw new IllegalArgumentException ("null stream metadata format name");
+
+ if (!formatName.equals (getNativeStreamMetadataFormatName())
+ && !formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+ {
+ String[] extraNames = getExtraStreamMetadataFormatNames ();
+ boolean foundName = false;
+ for (int i = 0; i < extraNames.length; i++)
+ {
+ if (formatName.equals(extraNames[i]))
+ {
+ foundName = true;
+ break;
+ }
+ }
+ if (!foundName)
+ throw new IllegalArgumentException ("unsupported stream metadata format name");
+ }
+
+ if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+ return IIOMetadataFormatImpl.getStandardFormatInstance ();
+ else
+ // Default implementation returns null.
+ return null;
+ }
+
+ /**
+ * Returns an IIOMetadataFormat object that represents the requested
+ * image metadata format or null if the given format is supported
+ * but no IIOMetadataFormat can be created for it.
+ *
+ * @param formatName the requested image metadata format name
+ *
+ * @return an IIOMetadataFormat object or null
+ *
+ * @throws IllegalArgumentException if formatName is null or is not
+ * one of the standard metadata format or this provider's native or
+ * extra image metadata formats
+ */
+ public IIOMetadataFormat getImageMetadataFormat (String formatName)
+ {
+ if (formatName == null)
+ throw new IllegalArgumentException ("null image metadata format name");
+
+ if (!formatName.equals (getNativeImageMetadataFormatName())
+ && !formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+ {
+ String[] extraNames = getExtraImageMetadataFormatNames ();
+ boolean foundName = false;
+ for (int i = 0; i < extraNames.length; i++)
+ {
+ if (formatName.equals(extraNames[i]))
+ {
+ foundName = true;
+ break;
+ }
+ }
+ if (!foundName)
+ throw new IllegalArgumentException ("unsupported image metadata format name");
+ }
+
+ if (formatName.equals (IIOMetadataFormatImpl.standardMetadataFormatName))
+ return IIOMetadataFormatImpl.getStandardFormatInstance ();
+ else
+ // Default implementation returns null.
+ return null;
+ }
}
diff --git a/javax/print/DocFlavor.java b/javax/print/DocFlavor.java
index e889a4544..1e96a70c0 100644
--- a/javax/print/DocFlavor.java
+++ b/javax/print/DocFlavor.java
@@ -54,7 +54,7 @@ public class DocFlavor implements Cloneable, Serializable
public static class BYTE_ARRAY
extends DocFlavor
{
- private static final long serialVersionUID = -906557800693857475L;
+ private static final long serialVersionUID = -9065578006593857475L;
public static final BYTE_ARRAY AUTOSENSE = new BYTE_ARRAY("application/octet-stream");
public static final BYTE_ARRAY GIF = new BYTE_ARRAY("image/gif");
diff --git a/javax/print/attribute/SetOfIntegerSyntax.java b/javax/print/attribute/SetOfIntegerSyntax.java
index d73b867d5..3990b66c5 100644
--- a/javax/print/attribute/SetOfIntegerSyntax.java
+++ b/javax/print/attribute/SetOfIntegerSyntax.java
@@ -38,7 +38,11 @@ exception statement from your version. */
package javax.print.attribute;
import java.io.Serializable;
-import java.util.Vector;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
/**
* @author Michael Koch
@@ -50,33 +54,41 @@ public abstract class SetOfIntegerSyntax
private int[][] members;
- private static int[][] normalize(Vector vecMembers)
+ private static int[][] normalize(int[][] values, int size)
{
- // XXX: Perhaps we should merge ranges that overlap.
-
- int current = 0;
- int[][] members = new int[vecMembers.size()][];
+ // Sort into increasing order. First the first index is
+ // compared, then the second.
+ Arrays.sort(values, 0, size, new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ int[] v1 = (int[]) o1;
+ int[] v2 = (int[]) o2;
+ if (v1[0] == v2[0])
+ return v1[1] - v2[1];
+ return v1[0] - v2[0];
+ }
+ });
- while (vecMembers.size() > 0)
+ // Now coalesce overlapping ranges.
+ int outIndex = 0;
+ for (int i = 0; i < size; ++i)
{
- // Search the lowest range.
- int[] range = (int[]) vecMembers.elementAt(0);
-
- for (int index = 1; index < vecMembers.size(); index++)
+ // Note that we compare with values[i][1]+1, since
+ // we can coalesce {0,1} with {2,x}.
+ int save = i;
+ while (i + 1 < size && values[i + 1][0] <= values[i][1] + 1)
{
- int[] tmp = (int[]) vecMembers.elementAt(index);
-
- if (range[0] > tmp[0]
- || (range[0] == tmp[0]
- && range[0] > tmp[0]))
- range = tmp;
+ values[i][1] = Math.max(values[i][1], values[i + 1][1]);
+ ++i;
}
-
- members[current] = range;
- current++;
+ values[outIndex++] = values[save];
}
- return members;
+ int[][] result = new int[outIndex][];
+ System.arraycopy(values, 0, result, 0, outIndex);
+
+ return result;
}
/**
@@ -104,10 +116,13 @@ public abstract class SetOfIntegerSyntax
*/
protected SetOfIntegerSyntax(int[][] members)
{
- Vector vecMembers = new Vector();
-
- if (members != null)
+ int[][] newMembers;
+ int outIndex = 0;
+ if (members == null)
+ newMembers = new int[0][];
+ else
{
+ newMembers = new int[members.length][];
for (int index = 0; index < members.length; index++)
{
int lower;
@@ -126,6 +141,7 @@ public abstract class SetOfIntegerSyntax
else
throw new IllegalArgumentException("invalid member element");
+ // We only want to reject non-null ranges where lower<0.
if (lower <= upper && lower < 0)
throw new IllegalArgumentException("invalid member element");
@@ -134,12 +150,81 @@ public abstract class SetOfIntegerSyntax
int[] range = new int[2];
range[0] = lower;
range[1] = upper;
- vecMembers.add(range);
+ newMembers[outIndex++] = range;
}
}
}
- this.members = normalize(vecMembers);
+ this.members = normalize(newMembers, outIndex);
+ }
+
+ private boolean skipWhitespace(StringCharacterIterator i)
+ {
+ while (Character.isWhitespace(i.current()))
+ i.next();
+ return i.current() == CharacterIterator.DONE;
+ }
+
+ private boolean skipNumber(StringCharacterIterator i)
+ {
+ boolean readAny = false;
+ while (Character.isDigit(i.current()))
+ {
+ readAny = true;
+ i.next();
+ }
+ return readAny;
+ }
+
+ protected SetOfIntegerSyntax(String s)
+ {
+ ArrayList vals = new ArrayList();
+
+ StringCharacterIterator it = new StringCharacterIterator(s);
+
+ while (true)
+ {
+ // Skip whitespace.
+ if (skipWhitespace(it))
+ break;
+
+ // Parse integer.
+ int index = it.getIndex();
+ if (! skipNumber(it))
+ throw new IllegalArgumentException();
+ int[] item = new int[2];
+ item[0] = Integer.parseInt(s.substring(index, it.getIndex()));
+
+ if (! skipWhitespace(it))
+ {
+ char c = it.current();
+ if (c == ':' || c == '-')
+ {
+ it.next();
+ if (skipWhitespace(it))
+ throw new IllegalArgumentException();
+ index = it.getIndex();
+ if (! skipNumber(it))
+ throw new IllegalArgumentException();
+ item[1] = Integer.parseInt(s.substring(index, it.getIndex()));
+ }
+ else
+ item[1] = item[0];
+ }
+ else
+ item[1] = item[0];
+
+ if (item[0] <= item[1])
+ vals.add(item);
+
+ if (skipWhitespace(it))
+ break;
+ if (it.current() != ',')
+ throw new IllegalArgumentException();
+ it.next();
+ }
+
+ members = normalize((int[][]) vals.toArray(new int[0][]), vals.size());
}
/**
@@ -153,6 +238,7 @@ public abstract class SetOfIntegerSyntax
*/
protected SetOfIntegerSyntax(int lowerBound, int upperBound)
{
+ // We only want to reject non-null ranges where lower<0.
if (lowerBound <= upperBound
&& lowerBound < 0)
throw new IllegalArgumentException();
@@ -175,7 +261,7 @@ public abstract class SetOfIntegerSyntax
{
if (value < members[index][0])
return false;
- else if (value < members[index][1])
+ else if (value <= members[index][1])
return true;
}
@@ -205,8 +291,16 @@ public abstract class SetOfIntegerSyntax
{
if (! (obj instanceof SetOfIntegerSyntax))
return false;
-
- throw new Error("not implemented");
+ SetOfIntegerSyntax other = (SetOfIntegerSyntax) obj;
+ if (other.members.length != members.length)
+ return false;
+ for (int i = 0; i < members.length; ++i)
+ {
+ if (members[i][0] != other.members[i][0]
+ || members[i][1] != other.members[i][1])
+ return false;
+ }
+ return true;
}
/**
@@ -216,7 +310,7 @@ public abstract class SetOfIntegerSyntax
*/
public int[][] getMembers()
{
- throw new Error("not implemented");
+ return (int[][]) members.clone();
}
/**
@@ -226,11 +320,14 @@ public abstract class SetOfIntegerSyntax
*/
public int hashCode()
{
- throw new Error("not implemented");
+ int result = 0;
+ for (int i = 0; i < members.length; ++i)
+ result += members[i][0] + members[i][1];
+ return result;
}
/**
- * Returns the smallest value that is greater then x.
+ * Returns the smallest value that is greater than x which is in this set.
*
* @param x an integer value
*
@@ -238,7 +335,16 @@ public abstract class SetOfIntegerSyntax
*/
public int next(int x)
{
- throw new Error("not implemented");
+ for (int i = 0; i < members.length; ++i)
+ {
+ if (x >= members[i][1])
+ continue;
+ if (x < members[i][0])
+ return members[i][0];
+ // X is in this range.
+ return x + 1;
+ }
+ return -1;
}
/**
@@ -248,6 +354,18 @@ public abstract class SetOfIntegerSyntax
*/
public String toString()
{
- throw new Error("not implemented");
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < members.length; ++i)
+ {
+ if (i > 0)
+ sb.append(',');
+ sb.append(members[i][0]);
+ if (members[i][0] != members[i][1])
+ {
+ sb.append('-');
+ sb.append(members[i][1]);
+ }
+ }
+ return sb.toString();
}
}
diff --git a/javax/rmi/BAD_OPERATION.java b/javax/rmi/BAD_OPERATION.java
deleted file mode 100644
index 36081a47c..000000000
--- a/javax/rmi/BAD_OPERATION.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package javax.rmi;
-
-/** XXX - Stub till we have org.omg.CORBA */
-public class BAD_OPERATION extends Exception { }
diff --git a/javax/rmi/CORBA/ClassDesc.java b/javax/rmi/CORBA/ClassDesc.java
index 01befa493..c8b38ead0 100644
--- a/javax/rmi/CORBA/ClassDesc.java
+++ b/javax/rmi/CORBA/ClassDesc.java
@@ -1,5 +1,5 @@
-/* ClassDesc.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* ClassDesc.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,16 +40,27 @@ package javax.rmi.CORBA;
import java.io.Serializable;
-public class ClassDesc
- implements Serializable
+/**
+ * This class is used to marshal java.lang.Class objects over IIOP.
+ * When used as a parameter type, return type, or data member, the Java Class
+ * is mapped to the OMG IDL type ::javax::rmi::CORBA::ClassDesc.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ClassDesc implements Serializable
{
- /*
- * The following is serialized form required by Java API Doc
+ /**
+ * Use serialVersionUID (V1.4) for interoperability.
*/
- private String repid;
- private String codebase;
+ private static final long serialVersionUID = -3477057297839810709L;
+
+ /**
+ * The class repository Id.
+ */
+ String repid;
- public ClassDesc()
- {
- }
+ /**
+ * Space separeted list of URL's from where the code can be downloaded.
+ */
+ String codebase;
}
diff --git a/javax/rmi/CORBA/ObjectImpl.java b/javax/rmi/CORBA/ObjectImpl.java
deleted file mode 100644
index d76d673ce..000000000
--- a/javax/rmi/CORBA/ObjectImpl.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package javax.rmi.CORBA;
-
-/** XXX - Stub till we have org.omg.CORBA */
-public class ObjectImpl
-{
- public ObjectImpl _orb() { return null; }
- public String object_to_string(ObjectImpl o)
- throws javax.rmi.BAD_OPERATION { return null; }
-}
diff --git a/javax/rmi/CORBA/PortableRemoteObjectDelegate.java b/javax/rmi/CORBA/PortableRemoteObjectDelegate.java
index 9ae45a33d..284970763 100644
--- a/javax/rmi/CORBA/PortableRemoteObjectDelegate.java
+++ b/javax/rmi/CORBA/PortableRemoteObjectDelegate.java
@@ -1,5 +1,5 @@
/* PortableRemoteObjectDelegate.java -- Interface supporting PortableRemoteObject
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,23 +43,95 @@ import java.rmi.Remote;
import java.rmi.RemoteException;
/**
- * A delegate is a singleton class that support delegation for method
- * implementation in PortableRemoteObject.
+ * A delegate, implementing the functionality, provided by the
+ * {@link PortableRemoteObject}.
+ *
+ * The default delegate can be altered by setting the system property
+ * "javax.rmi.CORBA.PortableRemoteObjectClass" to the name of the alternative
+ * class that must implement {@link PortableRemoteObjectDelegate}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public interface PortableRemoteObjectDelegate
{
+ /**
+ * <p>
+ * Makes the remote object <code>target</code> ready for remote
+ * communication using the same communications runtime as for the passed
+ * <code>source</code> parameter. Connection normally happens implicitly
+ * when the object is sent or received as an argument on a remote method call.
+ * </p>
+ * <p>
+ * The target object is connected to the same ORB as source by calling the
+ * {@link Stub#connect} if it is a stub or by associating its tie with an ORB
+ * if it is an implementation object.
+ * </p>
+ *
+ * @param target the target object that may be either an RMI/IDL stub or an
+ * exported RMI/IDL implementation object
+ * @param source the source object may also be either an RMI/IDL stub or an
+ * exported RMI/IDL implementation object.
+ *
+ * @throws RemoteException if the target is already connected to another ORB.
+ */
void connect(Remote target, Remote source)
throws RemoteException;
-
+
+ /**
+ * Register the passed object with the ORB runtimes, making it remotely
+ * accessible. When called on jre with no objects exported, creates a
+ * non-daemon thread that prevents jre from terminating until all objects are
+ * unexported. Also, such object cannot be collected by garbage collector.
+ * This is usually impemented via {@link Util#unexportObject}
+ *
+ * @param object the object to export.
+ *
+ * @throws RemoteException
+ */
void exportObject(Remote obj)
throws RemoteException;
+ /**
+ * Narrows the passed object to conform to the given interface or IDL type.
+ * This method may return different instance and cannot be replaced by the
+ * direct cast.
+ *
+ * @param narrowFrom an object to narrow.
+ * @param narrowTo a type to that the object must be narrowed.
+ *
+ * @return On success, an object of type narrowTo or null, if narrowFrom =
+ * null.
+ *
+ * @throws ClassCastException if no narrowing is possible.
+ */
Object narrow(Object narrowFrom, Class narrowTo)
throws ClassCastException;
-
+
+ /**
+ * Takes a server implementation object and returns a stub object that can be
+ * used to access that server object (target). If the target is connected, the
+ * returned stub is also connected to the same ORB. If the target is
+ * unconnected, the returned stub is unconnected.
+ *
+ * @param target a server side object.
+ * @return a stub object that can be used to access that server object.
+ *
+ * @throws NoSuchObjectException if a stub cannot be located for the given
+ * target.
+ */
Remote toStub(Remote obj)
throws NoSuchObjectException;
-
+
+ /**
+ * Deregister a currently exported server object from the ORB runtimes. The
+ * object to becomes available for garbage collection. This is usually
+ * impemented via {@link Util#unexportObject}
+ *
+ * @param object the object to unexport.
+ *
+ * @throws NoSuchObjectException if the passed object is not currently
+ * exported.
+ */
void unexportObject(Remote obj)
throws NoSuchObjectException;
}
diff --git a/javax/rmi/CORBA/Stub.java b/javax/rmi/CORBA/Stub.java
index a35a08fa9..190b10dad 100644
--- a/javax/rmi/CORBA/Stub.java
+++ b/javax/rmi/CORBA/Stub.java
@@ -1,5 +1,5 @@
-/* Stub.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* Stub.java --
+ Copyright (C) 2004, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,7 @@ exception statement from your version. */
package javax.rmi.CORBA;
import gnu.javax.rmi.CORBA.DelegateFactory;
-import gnu.javax.rmi.CORBA.GetDelegateInstanceException;
+import gnu.javax.rmi.CORBA.StubDelegateImpl;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -47,7 +47,27 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.rmi.RemoteException;
-public abstract class Stub extends ObjectImpl
+import javax.rmi.PortableRemoteObject;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA_2_3.portable.ObjectImpl;
+
+/**
+ * A Stub descendants provide access to the object on the client side. This base
+ * class implements methods, required for remote or local invocation using CORBA
+ * mechanisms. The most of the functionality is forwarded to the stub delegate.
+ * This delegate can be altered by setting the system property
+ * "javax.rmi.CORBA.StubClass" to the name of the alternative class that must
+ * implement {@link StubDelegate}. Hence Stub contains two delegates, one for
+ * Stub-related operations and another inherited from the ObjectImpl.
+ *
+ * @specnote GNU Classpath uses separate delegate per each Stub. The delegate
+ * holds information about the ORB and other data, specific for the each Stub.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class Stub
+ extends ObjectImpl
implements Serializable
{
/**
@@ -55,69 +75,129 @@ public abstract class Stub extends ObjectImpl
*/
private static final long serialVersionUID = 1087775603798577179L;
- private transient StubDelegate delegate;
-
- protected Stub()
- {
- try
- {
- delegate = (StubDelegate)DelegateFactory.getInstance("Stub");
- }
- catch(GetDelegateInstanceException e)
- {
- delegate = null;
- }
- }
+ /**
+ * The hashcode, computed once (expensive operation).
+ */
+ transient int m_hash = Integer.MIN_VALUE;
+
+ /**
+ * The stringified reference, computed once (expensive operation).
+ */
+ transient String m_ior;
+
+ /**
+ * The ORB, where the stub is connected on the client side.
+ */
+ transient ORB m_orb;
+ /**
+ * The associated delegate, responsible for the major of the functionality of
+ * this stub.
+ */
+ static StubDelegate delegate = (StubDelegate) DelegateFactory.getInstance(DelegateFactory.STUB);
+
+ /**
+ * Returns the same hashcode for all stubs that point to the same remote
+ * object.
+ */
public int hashCode()
{
- if(delegate != null)
- return delegate.hashCode(this);
- else
- return 0;
+ if (m_hash == Integer.MIN_VALUE)
+ m_hash = delegate.hashCode(this);
+ // This should finally result to the IOR comparison.
+ return m_hash;
}
- public boolean equals(Object obj)
+ /**
+ * The stubs are equal if they point to the same remote object.
+ */
+ public boolean equals(java.lang.Object obj)
{
- if(delegate != null)
- return delegate.equals(this, obj);
- else
- return false;
+ return delegate.equals(this, obj);
}
+ /**
+ * Get the string representation of this Stub.
+ *
+ * @return the CORBA IOR reference.
+ */
public String toString()
{
- String s = null;
- if(delegate != null)
- s = delegate.toString(this);
- if(s == null)
- s = super.toString();
- return s;
+ if (m_ior == null)
+ m_ior = delegate.toString(this);
+ return m_ior;
}
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- public void connect(javax.rmi.ORB orb)
+ /**
+ * <p>
+ * Finds the suitable {@link Tie} for this Stub and connects it to the given
+ * ORB. The tie is found by the name pattern. If the found tie is derived from
+ * {@link org.omg.CORBA.PortableServer.Servant}, it is connected to the root
+ * POA, also activating it (if not already active).
+ * </p>
+ * <p>
+ * This method does not allow to specify, to which POA the found Tie must be
+ * connected and requires to use the deprecated method {@link ORB#connect}.
+ * Many useful POA features remain unaccessible. A better alternative it might
+ * be to generate a {@link org.omg.CORBA.PortableServer.Servant} - derived Tie
+ * (-poa key in rmic) and connect it to POA in one of the many ways, listed in
+ * the description of the {@link orb.omg.PortableServer} package). The
+ * obtained CORBA object can be narrowed into stub using
+ * {@link PortableRemoteObject#narrow}.
+ * </p>
+ * <p>
+ * It is frequently easier to call {@link PortableRemoteObject#connect} rather
+ * than this method.
+ * </p>
+ *
+ * @param orb the ORB where the Stub must be connected.
+ *
+ * @throws RemoteException if the stub is already connected to some other ORB.
+ * If the stub is already connected to the ORB that was passed as parameter,
+ * the method returns without action.
+ *
+ * @throws BAD_PARAM if the name of this stub does not match the stub name
+ * pattern, "_*_Stub" or if the Tie class, "_*Impl_Tie", does not exists or an
+ * instance of this class cannot be instantiated.
+ */
+ public void connect(ORB orb)
throws RemoteException
{
- if(delegate != null)
- delegate.connect(this, orb);
+ if (m_orb != null && orb != null)
+ {
+ if (m_orb.equals(orb))
+ throw new RemoteException("Stub " + this
+ + " is connected to another ORB, " + orb);
+ else
+ return;
+ }
+ m_orb = orb;
+ delegate.connect(this, orb);
}
/**
- * The following two routines are required by serialized form of Java API doc.
+ * Required by serialized form of Java API doc.
*/
- private void readObject(ObjectInputStream stream)
+ private void readObject(ObjectInputStream input)
throws IOException, ClassNotFoundException
{
- if(delegate != null)
- delegate.readObject(this, stream);
+ if (delegate instanceof StubDelegateImpl)
+ ((StubDelegateImpl) delegate).readObject(this, input, m_orb);
+ else
+ delegate.readObject(this, input);
}
- private void writeObject(ObjectOutputStream stream)
+ /**
+ * Required by serialized form of Java API doc.
+ */
+ private void writeObject(ObjectOutputStream output)
throws IOException
{
- if(delegate != null)
- delegate.writeObject(this, stream);
- }
+ // The m_orb in this case may be either known or not.
+ if (delegate instanceof StubDelegateImpl)
+ ((StubDelegateImpl) delegate).writeObject(this, output, m_orb);
+ else
-}
+ delegate.writeObject(this, output);
+ }
+} \ No newline at end of file
diff --git a/javax/rmi/CORBA/StubDelegate.java b/javax/rmi/CORBA/StubDelegate.java
index 5c00a038f..cdf76e841 100644
--- a/javax/rmi/CORBA/StubDelegate.java
+++ b/javax/rmi/CORBA/StubDelegate.java
@@ -1,5 +1,5 @@
-/* StubDelegate.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* StubDelegate.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,28 +38,66 @@ exception statement from your version. */
package javax.rmi.CORBA;
+import org.omg.CORBA.ORB;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+
import java.rmi.RemoteException;
-//import org.omg.CORBA.ORB;
+/**
+ * A delegate, implementing the functionality, provided by the {@link Stub}.
+ * The default delegate can be altered by setting the system property
+ * "javax.rmi.CORBA.StubClass" to the name of the alternative class that must
+ * implement StubDelegate.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
public interface StubDelegate
{
-
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- void connect(Stub self, javax.rmi.ORB orb)
+ /**
+ * <p>
+ * Makes the stub ready for remote communication using the given ORB.
+ * </p>
+ * <p>
+ * It is frequently easier to call {@link PortableRemoteObject#connect} rather
+ * than this method.
+ * </p>
+ *
+ * @param orb the ORB where the Stub must be connected.
+ *
+ * @throws RemoteException if the stub is already connected to some other ORB.
+ * If the stub is already connected to the ORB that was passed as parameter,
+ * the method returns without action.
+ */
+ void connect(Stub self, ORB orb)
throws RemoteException;
+ /**
+ * The objects stubs are equal if they refer the same remote object.
+ */
boolean equals(Stub self, Object obj);
+ /**
+ * Get the hashcode fo this delegate.
+ */
int hashCode(Stub self);
+ /**
+ * Read this stub from the object input stream.
+ */
void readObject(Stub self, ObjectInputStream s)
throws IOException, ClassNotFoundException;
- String toString(Stub self);
-
+ /**
+ * Write this stub to the object output stream.
+ */
void writeObject(Stub self, ObjectOutputStream s)
throws IOException;
-}
+
+ /**
+ * Get the string representation of this stub.
+ */
+ String toString(Stub self);
+} \ No newline at end of file
diff --git a/javax/rmi/CORBA/SystemException.java b/javax/rmi/CORBA/SystemException.java
deleted file mode 100644
index f8afdc35e..000000000
--- a/javax/rmi/CORBA/SystemException.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package javax.rmi.CORBA;
-
-/** XXX - Stub till we have org.omg.CORBA */
-public class SystemException extends Exception { }
diff --git a/javax/rmi/CORBA/Tie.java b/javax/rmi/CORBA/Tie.java
index 4b1984c58..b86118388 100644
--- a/javax/rmi/CORBA/Tie.java
+++ b/javax/rmi/CORBA/Tie.java
@@ -1,5 +1,5 @@
-/* Tie.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* Tie.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,28 +35,91 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.rmi.CORBA;
+import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
-//import org.omg.CORBA.ORB;
-//import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.InvokeHandler;
-public interface Tie // XXX extends InvokeHandler
+/**
+ * <p>
+ * A Tie serves as a CORBA Servant or implementation base. It is connected to
+ * the ORB on a server side, providing the implementation of the required
+ * functionality. ORB access this implementation using {@link InvokeHandler}
+ * ._invoke(..). All such calls are finally delegated to the object, returned by
+ * {@link #getTarget()}.
+ * </p>
+ * <p>
+ * Ties are generated from implementations (name pattern *Impl) and have the
+ * name pattern _*Impl_Tie, for instance:<br>
+ * <code>rmic -keep -iiop -poa -always gnu.testlet.java.rmi.Remote.CalculatorImpl</code>
+ * </p>
+ * <p>
+ * Ties should normally be derived from the
+ * {@link org.omg.PortableServer.Servant}. Such ties are generated by
+ * <code>rmic</code> compiler using <code>-poa</code> key. Ties can be also
+ * derived from {@link org.omg.CORBA_2_3.portable.ObjectImpl}.
+ * </p>
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface Tie
+ extends InvokeHandler
{
-
- void deactivate();
-
+ /**
+ * Get the invocation target, where all method calls should be delegated.
+ *
+ * @return the object, implementing methods, defined in the interface being
+ * served by this Tie.
+ */
Remote getTarget();
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- javax.rmi.ORB orb();
-
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- void orb(javax.rmi.ORB orb);
-
+ /**
+ * Set the invocation target, where all method calls should be delegated.
+ *
+ * @param target the object, implementing methods, defined in the interface
+ * being served by this Tie. The code, produced by a typical rmic compiler
+ * usually requires the target to be an instance of the implementation from
+ * that the Tie was generated.
+ *
+ * @throws ClassCastException if the passed parameter is not an instance of
+ * the implementation from that the Tie was generated.
+ */
void setTarget(Remote target);
-
- // XXX Object -> org.omg.CORBA.Object
- Object thisObject();
-}
+
+ /**
+ * Get the ORB to that this Tie is connected.
+ *
+ * @see org.omg.PortableServer.Servant#_orb
+ */
+ ORB orb();
+
+ /**
+ * Connect this Tie to the given ORB.
+ */
+ void orb(ORB orb);
+
+ /**
+ * Get the object that delegates calls to this tie.
+ *
+ * @see org.omg.PortableServer.Servant#_this_object
+ */
+ org.omg.CORBA.Object thisObject();
+
+ /**
+ * Deactivate this Tie. The tie is normally deactivated using POA mechanisms.
+ * Depending on the POA policies, it may be possible to activate the Tie
+ * again. The ties that are not derived from
+ * {@link org.omg.PortableServer.Servant} deactivate themselves by
+ * {@link ORB.disconnect}.
+ *
+ * @throws NoSuchObjectException if there are no objects served by this Tie,
+ * or if the these objects are already deactivated.
+ *
+ * @see org.omg.PortableServer.POA#deactivate_object
+ */
+ void deactivate()
+ throws NoSuchObjectException;
+
+} \ No newline at end of file
diff --git a/javax/rmi/CORBA/Util.java b/javax/rmi/CORBA/Util.java
index 0370cce83..cfd3d7bd6 100644
--- a/javax/rmi/CORBA/Util.java
+++ b/javax/rmi/CORBA/Util.java
@@ -1,5 +1,5 @@
-/* Util.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* Util.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,148 +38,379 @@ exception statement from your version. */
package javax.rmi.CORBA;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.COMM_FAILURE;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.INVALID_TRANSACTION;
+import org.omg.CORBA.INV_OBJREF;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_PERMISSION;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.OMGVMCID;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TRANSACTION_REQUIRED;
+import org.omg.CORBA.TRANSACTION_ROLLEDBACK;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
import gnu.javax.rmi.CORBA.DelegateFactory;
-import gnu.javax.rmi.CORBA.GetDelegateInstanceException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.rmi.AccessException;
+import java.rmi.MarshalException;
+import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
+import java.rmi.ServerError;
+import java.rmi.ServerException;
+import java.rmi.UnexpectedException;
+import java.rmi.server.RMIClassLoader;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.TransactionRequiredException;
+import javax.transaction.TransactionRolledbackException;
+/**
+ * Provides utility methods used by stubs and ties to perform common operations.
+ * The functionality is forwarded to the enclosed UtilDelegate. This delegate
+ * can be altered by setting the system property "javax.rmi.CORBA.UtilClass" to
+ * the name of the alternative class that must implement {@link UtilDelegate}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
public class Util
{
+ /**
+ * The delegate, responsible for all functionality.
+ */
+ static UtilDelegate delegate = (UtilDelegate) DelegateFactory.getInstance(DelegateFactory.UTIL);
- private static UtilDelegate delegate;
- static
- {
- try
- {
- delegate = (UtilDelegate)DelegateFactory.getInstance("Util");
- }
- catch(GetDelegateInstanceException e)
- {
- delegate = null;
- }
- }
-
+ /**
+ * Prevents this class from being instantiated.
+ */
private Util()
{
}
- // XXX - javax.rmi.ORB -> org.omg.CORBA.ORB
- public static Object copyObject(Object obj, javax.rmi.ORB orb)
+ /**
+ * Used by local stubs to create a copy of the object. The object must be
+ * Serializable for this operation to succeed. Strings are not copied and
+ * 1D-3D string arrays are only cloned.
+ */
+ public static java.lang.Object copyObject(java.lang.Object object, ORB orb)
throws RemoteException
{
- if(delegate != null)
- return delegate.copyObject(obj, orb);
- else
- return null;
+ return delegate.copyObject(object, orb);
}
- // XXX - javax.rmi.ORB -> org.omg.CORBA.ORB
- public static Object[] copyObjects(Object obj[], javax.rmi.ORB orb)
+ /**
+ * Used by local stubs to create a multiple copies of the object, preserving
+ * sharing accross the parameters if necessary.
+ */
+ public static java.lang.Object[] copyObjects(java.lang.Object[] object,
+ ORB orb)
throws RemoteException
{
- if(delegate != null)
- return delegate.copyObjects(obj, orb);
- else
- return null;
+ return delegate.copyObjects(object, orb);
}
-
+
+ /**
+ * Get the value handler that Serializes Java objects to and from CDR (GIOP)
+ * streams.
+ *
+ * When using the default Util implementation, the class of the returned
+ * handler can be altered by setting by setting the system property
+ * "javax.rmi.CORBA.ValueHandlerClass" to the name of the alternative class
+ * that must implement {@link ValueHandler}.
+ */
public static ValueHandler createValueHandler()
{
- if(delegate != null)
- return delegate.createValueHandler();
- else
- return null;
+ return delegate.createValueHandler();
}
-
+
+ /**
+ * This call is finally delegated to {@link RMIClassLoader#getClassAnnotation};
+ */
public static String getCodebase(Class clz)
{
- if(delegate != null)
- return delegate.getCodebase(clz);
- else
- return null;
+ return delegate.getCodebase(clz);
}
-
+
+ /**
+ * Get the Tie that handles invocations on the given target. If the target/Tie
+ * pair has not been previously registered using {@link #registerTarget},
+ * this method tries to locate a tie class by the name pattern. If this
+ * succeeds, the tie-target pair is also registered.
+ *
+ * @return the Tie.
+ */
public static Tie getTie(Remote target)
{
- if(delegate != null)
- return delegate.getTie(target);
- else
- return null;
+ return delegate.getTie(target);
}
+ /**
+ * Checks if the given stub is local. The implementation it delegates call to
+ * {@link ObjectImpl#_is_local().
+ *
+ * @param stub a stub to check.
+ * @return true if the stub is local, false otherwise.
+ *
+ * @throws RemoteException if the {@link ObjectImpl#_is_local()} throws a
+ * {@link org.omg.CORBA.SystemException}.
+ */
public static boolean isLocal(Stub stub)
throws RemoteException
{
- if(delegate != null)
- return delegate.isLocal(stub);
- else
- return false;
+ return delegate.isLocal(stub);
}
- public static Class loadClass(String className, String remoteCodebase, ClassLoader loader)
+ /**
+ * Load the class. The method uses class loaders from the call stact first. If
+ * this fails, the further behaviour depends on the System Property
+ * "java.rmi.server.useCodebaseOnly" with default value "false".
+ *
+ * <ul>
+ * <li>If remoteCodebase is non-null and useCodebaseOnly is "false" then call
+ * java.rmi.server.RMIClassLoader.loadClass (remoteCodebase, className)</li>
+ * <li> If remoteCodebase is null or useCodebaseOnly is true then call
+ * java.rmi.server.RMIClassLoader.loadClass(className)</li>
+ * <li>If a class is still not successfully loaded and the loader != null
+ * then try Class.forName(className, false, loader). </li>
+ * </ul>
+ *
+ * @param className the name of the class.
+ * @param remoteCodebase the codebase.
+ * @param loader the class loader.
+ * @return the loaded class.
+ *
+ * @throws ClassNotFoundException of the class cannot be loaded.
+ */
+ public static Class loadClass(String className, String remoteCodebase,
+ ClassLoader loader)
throws ClassNotFoundException
{
- if(delegate != null)
- return delegate.loadClass(className, remoteCodebase, loader);
- else
- throw new ClassNotFoundException(className + ": delegate == null");
- }
-
- public static RemoteException mapSystemException(SystemException ex)
- {
- if(delegate != null)
- return delegate.mapSystemException(ex);
- else
- return null;
+ return delegate.loadClass(className, remoteCodebase, loader);
}
- public static Object readAny(InputStream in)
+ /**
+ * Converts CORBA {@link SystemException} into RMI {@link RemoteException}.
+ * The exception is converted as defined in the following table:
+ * <p>
+ * <table border = "1">
+ * <tr>
+ * <th>CORBA Exception</th>
+ * <th>RMI Exception</th>
+ * </tr>
+ * <tr>
+ * <td>{@link COMM_FAILURE}</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link INV_OBJREF}</td>
+ * <td>{@link NoSuchObjectException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link NO_PERMISSION}</td>
+ * <td>{@link AccessException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link MARSHAL}</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link BAD_PARAM} (all other cases)</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link OBJECT_NOT_EXIST}</td>
+ * <td>{@link NoSuchObjectException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link TRANSACTION_REQUIRED}</td>
+ * <td>{@link TransactionRequiredException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link TRANSACTION_ROLLEDBACK}</td>
+ * <td>{@link TransactionRolledbackException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link INVALID_TRANSACTION}</td>
+ * <td>{@link InvalidTransactionException}</td>
+ * </tr>
+ * <tr>
+ * <td bgcolor="lightgray">Any other {@link SystemException}</td>
+ * <td bgcolor="lightgray">{@link RemoteException}</td>
+ * </tr>
+ * </table>
+ * </p>
+ * <p>
+ * The exception detailed message always consists of
+ * <ol>
+ * <li>the string "CORBA "</li>
+ * <li>the CORBA name of the system exception</li>
+ * <li>single space</li>
+ * <li>the hexadecimal value of the system exception's minor code, preceeded
+ * by 0x (higher bits contain {@link OMGVMCID}).</li>
+ * <li>single space</li>
+ * <li>the {@link CompletionStatus} of the exception: "Yes", "No" or "Maybe".</li>
+ * </ol>
+ * The subsequent content is not part of the official RMI-IIOP standart and is
+ * added for compatibility with Sun's implementation:
+ * <ol>
+ * <li>the phrase "<code>; nested exception is: <i>(line feed)(tab)</i></code>"</li>
+ * <li>the full name of the mapped SystemException, as returned by
+ * Class.getName().</li>
+ * <li>the ": ".
+ * <li>the value, returned by .getMessage() of the passed parameter.</li>
+ * </ol>
+ * <p>
+ * For instance, if the Internet connection was refused:
+ * </p><p>
+ * <code>CORBA COMM_FAILURE 0x535500C9 No</code>
+ * </p><p>
+ * The original CORBA exception is set as the cause of the RemoteException
+ * being created.
+ * </p>
+ */
+ public static RemoteException mapSystemException(SystemException ex)
{
- if(delegate != null)
- return delegate.readAny(in);
- else
- return null;
+ return delegate.mapSystemException(ex);
}
+ /**
+ * Register the Tie-target pair. As the Tie is a Servant, it can potentially
+ * be connected to several objects and hence may be registered with several
+ * targets.
+ */
public static void registerTarget(Tie tie, Remote target)
{
- if(delegate != null)
- delegate.registerTarget(tie, target);
+ delegate.registerTarget(tie, target);
}
-
+
+ /**
+ * Deactivate the associated Tie, if it is found and is not connected to other
+ * registered targets. Independing from the POA policies, the transparent
+ * reactivation will not be possible.
+ */
public static void unexportObject(Remote target)
+ throws NoSuchObjectException
{
- if(delegate != null)
- delegate.unexportObject(target);
+ delegate.unexportObject(target);
}
-
- public static RemoteException wrapException(Throwable orig)
+
+ /**
+ * Converts the exception that was thrown by the implementation method on a
+ * server side into RemoteException that can be transferred and re-thrown on a
+ * client side. The method converts exceptions as defined in the following
+ * table: <table border = "1">
+ * <tr>
+ * <th>Exception to map (or subclass)</th>
+ * <th>Maps into</th>
+ * </tr>
+ * <tr>
+ * <td>{@link Error}</td>
+ * <td>{@link ServerError}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link RemoteException}</td>
+ * <td>{@link ServerException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link SystemException}</td>
+ * <td>wrapException({@link #mapSystemException})</td>
+ * </tr>
+ * <tr>
+ * <td>{@link RuntimeException}</td>
+ * <td><b>rethrows</b></td>
+ * </tr>
+ * <tr>
+ * <td>Any other exception</td>
+ * <td>{@link UnexpectedException}</td>
+ * </tr>
+ * </table>
+ *
+ * @param ex an exception that was thrown on a server side implementation.
+ *
+ * @return the corresponding RemoteException unless it is a RuntimeException.
+ *
+ * @throws RuntimeException the passed exception if it is an instance of
+ * RuntimeException.
+ *
+ * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0.
+ */
+ public static RemoteException wrapException(Throwable exception)
{
- if(delegate != null)
- return delegate.wrapException(orig);
- else
- return null;
+ return delegate.wrapException(exception);
}
-
- public static void writeAbstractObject(OutputStream out, Object obj)
+
+ /**
+ * Write abstract interface to the CORBA output stream. The write format is
+ * matching CORBA abstract interface. Remotes and CORBA objects are written as
+ * objects, other classes are supposed to be value types and are written as
+ * such. {@link Remote}s are processed as defined in
+ * {@link #writeRemoteObject}. The written data contains discriminator,
+ * defining, that was written. Another method that writes the same content is
+ * {@link org.omg.CORBA_2_3.portable.OutputStream#write_abstract_interface(java.lang.Object)}.
+ *
+ * @param output a stream to write to, must be
+ * {@link org.omg.CORBA_2_3.portable.OutputStream}.
+ *
+ * @param object an object to write, must be CORBA object, Remote
+ */
+ public static void writeAbstractObject(OutputStream output,
+ java.lang.Object object)
{
- if(delegate != null)
- delegate.writeAbstractObject(out, obj);
+ delegate.writeAbstractObject(output, object);
}
-
- public static void writeAny(OutputStream out, Object obj)
+
+ /**
+ * Write the passed java object to the output stream in the form of the CORBA
+ * {@link Any}. This includes creating an writing the object {@link TypeCode}
+ * first. Such Any can be later read by a non-RMI-IIOP CORBA implementation
+ * and manipulated, for instance, by means, provided in
+ * {@link org.omg.DynamicAny.DynAny}. Depending from the passed value, this
+ * method writes CORBA object, value type or value box. For value types Null
+ * is written with the abstract interface, its typecode having repository id
+ * "IDL:omg.org/CORBA/AbstractBase:1.0" and the empty string name.
+ *
+ * @param output the object to write.
+ * @param object the java object that must be written in the form of the CORBA
+ * {@link Any}.
+ */
+ public static void writeAny(OutputStream output, java.lang.Object object)
{
- if(delegate != null)
- delegate.writeAny(out, obj);
+ delegate.writeAny(output, object);
}
-
- public static void writeRemoteObject(OutputStream out, Object obj)
+
+ /**
+ * Read Any from the input stream.
+ */
+ public static java.lang.Object readAny(InputStream input)
{
- if(delegate != null)
- delegate.writeRemoteObject(out, obj);
+ return delegate.readAny(input);
}
-}
+ /**
+ * Write the passed parameter to the output stream as CORBA object. If the
+ * parameter is an instance of Remote and not an instance of Stub, the method
+ * instantiates a suitable Tie, connects the parameter to this Tie and then
+ * connects that Tie to the ORB that is requested from the output stream. Then
+ * the object reference is written to the stream, making remote invocations
+ * possible (the ORB is started and activated, if required). This method is
+ * used in write_value(..) method group in
+ * {@link org.omg.CORBA_2_3.portable.OutputStream} and also may be called
+ * directly from generated Stubs and Ties.
+ *
+ * @param output a stream to write to, must be
+ * org.omg.CORBA_2_3.portable.OutputStream
+ * @param object an object to write.
+ */
+ public static void writeRemoteObject(OutputStream output,
+ java.lang.Object object)
+ {
+ delegate.writeRemoteObject(output, object);
+ }
+} \ No newline at end of file
diff --git a/javax/rmi/CORBA/UtilDelegate.java b/javax/rmi/CORBA/UtilDelegate.java
index deeb94f68..cacb92581 100644
--- a/javax/rmi/CORBA/UtilDelegate.java
+++ b/javax/rmi/CORBA/UtilDelegate.java
@@ -1,5 +1,5 @@
-/* UtilDelegate.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* UtilDelegate.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,48 +38,273 @@ exception statement from your version. */
package javax.rmi.CORBA;
-import java.io.InputStream;
-import java.io.OutputStream;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.COMM_FAILURE;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.INVALID_TRANSACTION;
+import org.omg.CORBA.INV_OBJREF;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_PERMISSION;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.OMGVMCID;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TRANSACTION_REQUIRED;
+import org.omg.CORBA.TRANSACTION_ROLLEDBACK;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.rmi.AccessException;
+import java.rmi.MarshalException;
+import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
-//import org.omg.CORBA.ORB;
-//import org.omg.CORBA.SystemException;
-//import org.omg.CORBA.portable.InputStream;
-//import org.omg.CORBA.portable.OutputStream;
+import java.rmi.ServerError;
+import java.rmi.ServerException;
+import java.rmi.UnexpectedException;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.TransactionRequiredException;
+import javax.transaction.TransactionRolledbackException;
+/**
+ * A delegate, implementing the functionality, provided by the {@link Util}.
+ *
+ * The default delegate can be altered by setting the system property
+ * "javax.rmi.CORBA.UtilClass" to the name of the alternative class that must
+ * implement this interface.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
public interface UtilDelegate
{
+ /**
+ * Used by local stubs to create a copy of the object.
+ */
+ Object copyObject(Object obj, ORB orb)
+ throws RemoteException;
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- Object copyObject(Object obj, javax.rmi.ORB orb) throws RemoteException;
-
- // XXX javax.rmi.ORB -> org.omg.CORBA.ORB
- Object[] copyObjects(Object obj[], javax.rmi.ORB orb) throws RemoteException;
+ /**
+ * Used by local stubs to create a multiple copies of the object, preserving
+ * sharing accross the parameters if necessary.
+ */
+ Object[] copyObjects(Object[] obj, ORB orb)
+ throws RemoteException;
+ /**
+ * Get the value handler that Serializes Java objects to and from CDR (GIOP)
+ * streams.
+ */
ValueHandler createValueHandler();
-
+
String getCodebase(Class clz);
-
- Tie getTie(Remote target);
-
- boolean isLocal(Stub stub) throws RemoteException;
- Class loadClass(String className, String remoteCodebase,
- ClassLoader loader) throws ClassNotFoundException;
+ /**
+ * Checks if the given stub is local.
+ */
+ boolean isLocal(Stub stub)
+ throws RemoteException;
+
+ Class loadClass(String className, String remoteCodebase, ClassLoader loader)
+ throws ClassNotFoundException;
+ /**
+ * Converts CORBA {@link SystemException} into RMI {@link RemoteException}.
+ * The exception is converted as defined in the following table:
+ * <p>
+ * <table border = "1">
+ * <tr>
+ * <th>CORBA Exception</th>
+ * <th>RMI Exception</th>
+ * </tr>
+ * <tr>
+ * <td>{@link COMM_FAILURE}</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link INV_OBJREF}</td>
+ * <td>{@link NoSuchObjectException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link NO_PERMISSION}</td>
+ * <td>{@link AccessException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link MARSHAL}</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link BAD_PARAM} (all other cases)</td>
+ * <td>{@link MarshalException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link OBJECT_NOT_EXIST}</td>
+ * <td>{@link NoSuchObjectException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link TRANSACTION_REQUIRED}</td>
+ * <td>{@link TransactionRequiredException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link TRANSACTION_ROLLEDBACK}</td>
+ * <td>{@link TransactionRolledbackException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link INVALID_TRANSACTION}</td>
+ * <td>{@link InvalidTransactionException}</td>
+ * </tr>
+ * <tr>
+ * <td bgcolor="lightgray">Any other {@link SystemException}</td>
+ * <td bgcolor="lightgray">{@link RemoteException}</td>
+ * </tr>
+ * </table>
+ * </p>
+ * <p>
+ * The exception detailed message always consists of
+ * <ol>
+ * <li>the string "CORBA "</li>
+ * <li>the CORBA name of the system exception</li>
+ * <li>single space</li>
+ * <li>the hexadecimal value of the system exception's minor code, preceeded
+ * by 0x (higher bits contain {@link OMGVMCID}).</li>
+ * <li>single space</li>
+ * <li>the {@link CompletionStatus} of the exception: "Yes", "No" or "Maybe".</li>
+ * </ol>
+ * The subsequent content is not part of the official RMI-IIOP standart and is
+ * added for compatibility with Sun's implementation:
+ * <ol>
+ * <li>the phrase "<code>; nested exception is: <i>(line feed)(tab)</i></code>"</li>
+ * <li>the full name of the mapped SystemException, as returned by
+ * Class.getName().</li>
+ * <li>the ": ".
+ * <li>the value, returned by .getMessage() of the passed parameter.</li>
+ * </ol>
+ * <p>
+ * For instance, if the Internet connection was refused:
+ * </p><p>
+ * <code>CORBA COMM_FAILURE 0x535500C9 No</code>
+ * </p><p>
+ * The original CORBA exception is set as the cause of the RemoteException
+ * being created.
+ * </p>
+ */
RemoteException mapSystemException(SystemException ex);
- Object readAny(InputStream in);
+ /**
+ * Get the Tie that handles invocations on the given target. The target/Tie
+ * pair must be previously registered using {@link #registerTarget}.
+ *
+ * @return the Tie, or null if no such is known.
+ */
+ Tie getTie(Remote target);
+ /**
+ * Register the Tie-target pair.
+ */
void registerTarget(Tie tie, Remote target);
-
- void unexportObject(Remote target);
-
+
+ /**
+ * Deactivate the associated Tie, if it is found and is not connected to other
+ * registered targets.
+ */
+ void unexportObject(Remote target)
+ throws NoSuchObjectException;
+
+ /**
+ * Converts the exception that was thrown by the implementation method on a
+ * server side into RemoteException that can be transferred and re-thrown on a
+ * client side. The method converts exceptions as defined in the following
+ * table: <table border = "1">
+ * <tr>
+ * <th>Exception to map (or subclass)</th>
+ * <th>Maps into</th>
+ * </tr>
+ * <tr>
+ * <td>{@link Error}</td>
+ * <td>{@link ServerError}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link RemoteException}</td>
+ * <td>{@link ServerException}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link SystemException}</td>
+ * <td>wrapException({@link #mapSystemException})</td>
+ * </tr>
+ * <tr>
+ * <td>{@link RuntimeException}</td>
+ * <td><b>rethrows</b></td>
+ * </tr>
+ * <tr>
+ * <td>Any other exception</td>
+ * <td>{@link UnexpectedException}</td>
+ * </tr>
+ * </table>
+ *
+ * @param ex an exception that was thrown on a server side implementation.
+ *
+ * @return the corresponding RemoteException unless it is a RuntimeException.
+ *
+ * @throws RuntimeException the passed exception if it is an instance of
+ * RuntimeException.
+ *
+ * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0.
+ */
RemoteException wrapException(Throwable orig);
-
- void writeAbstractObject(OutputStream out, Object obj);
-
- void writeAny(OutputStream out, Object obj);
- void writeRemoteObject(OutputStream out, Object obj);
-}
+ /**
+ * Write the passed parameter to the output stream as CORBA object. If the
+ * parameter is an instance of Remote and not an instance of Stub, the method
+ * instantiates a suitable Tie, connects the parameter to this Tie and then
+ * connects that Tie to the ORB that is requested from the output stream. Then
+ * the object reference is written to the stream, making remote invocations
+ * possible. This method is used in write_value(..) method group in
+ * {@link org.omg.CORBA_2_3.portable.OutputStream} and also may be called
+ * directly from generated Stubs and Ties.
+ *
+ * @param output a stream to write to, must be
+ * org.omg.CORBA_2_3.portable.OutputStream
+ * @param object an object to write.
+ */
+ void writeRemoteObject(OutputStream output, Object obj);
+
+ /**
+ * Write abstract interface to the CORBA output stream. The write format is
+ * matching CORBA abstract interface. Remotes and CORBA objects are written as
+ * objects, other classes are supposed to be value types and are written as
+ * such. {@link Remote}s are processed as defined in
+ * {@link #writeRemoteObject}. The written data contains discriminator,
+ * defining, that was written. Another method that writes the same content is
+ * {@link org.omg.CORBA_2_3.portable.OutputStream#write_abstract_interface(java.lang.Object)}.
+ *
+ * @param output a stream to write to, must be
+ * {@link org.omg.CORBA_2_3.portable.OutputStream}.
+ *
+ * @param object an object to write, must be CORBA object, Remote
+ */
+ void writeAbstractObject(OutputStream output, Object object);
+
+ /**
+ * Write the passed java object to the output stream in the form of the CORBA
+ * {@link Any}. This includes creating an writing the object {@link TypeCode}
+ * first. Such Any can be later read by a non-RMI-IIOP CORBA implementation
+ * and manipulated, for instance, by means, provided in
+ * {@link org.omg.DynamicAny.DynAny}. Depending from the passed value, this
+ * method writes CORBA object, value type or value box. For value types Null
+ * is written with the abstract interface, its typecode having repository id
+ * "IDL:omg.org/CORBA/AbstractBase:1.0" and the empty string name.
+ *
+ * @param output the object to write.
+ * @param object the java object that must be written in the form of the CORBA
+ * {@link Any}.
+ */
+ void writeAny(OutputStream output, Object object);
+
+ /**
+ * Read Any from the input stream.
+ */
+ Object readAny(InputStream input);
+
+} \ No newline at end of file
diff --git a/javax/rmi/CORBA/ValueHandler.java b/javax/rmi/CORBA/ValueHandler.java
index f26e75b2a..c4213efdc 100644
--- a/javax/rmi/CORBA/ValueHandler.java
+++ b/javax/rmi/CORBA/ValueHandler.java
@@ -1,5 +1,5 @@
-/* ValueHandler.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* ValueHandler.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,28 +38,93 @@ exception statement from your version. */
package javax.rmi.CORBA;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.io.Serializable;
-//import org.omg.CORBA.portable.InputStream;
-//import org.omg.CORBA.portable.OutputStream;
-//import org.omg.SendingContext.RunTime;
+import org.omg.CORBA.CustomMarshal;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+import org.omg.SendingContext.RunTime;
+
+/**
+ * Serializes Java objects to and from CDR (GIOP) streams. The working instance
+ * of the value handler is returned by {@link Util#createValueHandler} and can
+ * be altered by setting the system property "javax.rmi.CORBA.ValueHandlerClass"
+ * to the name of the alternative class that must implement ValueHandler.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
public interface ValueHandler
{
-
+ /**
+ * Get CORBA repository Id for the given java class.
+ *
+ * The syntax of the repository ID is the initial ?RMI:?, followed by the Java
+ * class name, followed by name, followed by a hash code string, followed
+ * optionally by a serialization version UID string.
+ *
+ * For Java identifiers that contain illegal OMG IDL identifier characters
+ * such as ?$?, any such illegal characters are replaced by ?\U? followed by
+ * the 4 hexadecimal characters (in upper case) representing the Unicode
+ * value.
+ *
+ * @param clz a class for that the repository Id is required.
+ *
+ * @return the class repository id.
+ */
String getRMIRepositoryID(Class clz);
-
- // XXX Runtime -> RunTime
- Runtime getRunTimeCodeBase();
-
+
+ /**
+ * Returns the CodeBase for this ValueHandler.
+ *
+ * @return the codebase.
+ */
+ RunTime getRunTimeCodeBase();
+
+ /**
+ * Indicates that the given class is responsible itself for writing its
+ * content to the stream. Such classes implement either {@link Streamable}
+ * (default marshalling, generated by IDL-to-java compiler) or
+ * {@link CustomMarshal} (the user-programmed marshalling).
+ *
+ * @param clz the class being checked.
+ * @return true if the class supports custom or default marshalling, false
+ * otherwise.
+ */
boolean isCustomMarshaled(Class clz);
-
- // XXX Runtime -> RunTime
+
+ /**
+ * Read value from the CORBA input stream in the case when the value is not
+ * Streamable or CustomMarshall'ed. The fields of the class being written will
+ * be accessed using reflection.
+ *
+ * @param in a CORBA stream to read.
+ * @param offset the current position in the input stream.
+ * @param clz the type of value being read.
+ * @param repositoryID the repository Id of the value being read.
+ * @param sender the sending context that should provide data about the
+ * message originator.
+ *
+ * @return the object, extracted from the stream.
+ */
Serializable readValue(InputStream in, int offset, Class clz,
- String repositoryID, Runtime sender);
-
+ String repositoryID, RunTime sender);
+
+ /**
+ * When the value provides the writeReplace method, the result of this method
+ * is written. Otherwise, the value itself is written.
+ *
+ * @param the value that should be written to the stream.
+ *
+ * @return the value that will be actually written to the stream.
+ */
Serializable writeReplace(Serializable value);
-
+
+ /**
+ * Write value to CORBA output stream using java senmatics.
+ *
+ * @param out a stream to write into.
+ * @param value a java object to write.
+ */
void writeValue(OutputStream out, Serializable value);
-}
+} \ No newline at end of file
diff --git a/javax/rmi/CORBA/ValueHandlerMultiFormat.java b/javax/rmi/CORBA/ValueHandlerMultiFormat.java
new file mode 100644
index 000000000..4db65c1db
--- /dev/null
+++ b/javax/rmi/CORBA/ValueHandlerMultiFormat.java
@@ -0,0 +1,94 @@
+/* ValueHandlerMultiFormat.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.rmi.CORBA;
+
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+
+/**
+ * This interface extends the previous ValueHandler, supporting various stream
+ * format versions. The {@link ValueHandler} can be casted into this interface
+ * to access additional features.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ValueHandlerMultiFormat
+ extends ValueHandler
+{
+ /**
+ * Get the maximal supported version for the value types, supported by
+ * this value handler. The versions are integer numbers, the currently valid
+ * values being 1 and 2.
+ *
+ * These two versions differ in how the additional data, stored by the
+ * writeObject method, are encoded.
+ * <ul>
+ * <li> For version 1 (GNU Classpath default), that data (if present) are
+ * written "as is". </li>
+ * <li>For version 2, this data fragment is enclosed within a CDR custom
+ * valuetype with no codebase and repository Id "RMI:org.omg.custom.<class>"
+ * where <class> is the fully-qualified name of the class whose writeObject
+ * method is being invoked. If the object does not write any data via
+ * writeObject method, the null valuetype (0x0) must be written.</li>
+ * </ul>
+ * As the version number is part of the value type record, there is no need
+ * to the format control during the reading.
+ *
+ * @return the maximal supported version.
+ */
+ byte getMaximumStreamFormatVersion();
+
+ /**
+ * Write the value type to the output stream using the given format version.
+ * The older method {@link ValueHandler#writeValue} always uses the version 1.
+ *
+ * @param output the stream, where the value should be written, must implement
+ * {@link ValueOutputStream}.
+ * @param value the value that should be written.
+ * @param version the version of the format that must be used to write the
+ * value.
+ *
+ * @throws BAD_PARAM if the version number is less than 1 or greater than the
+ * maximal supported version.
+ */
+ void writeValue(OutputStream output, Serializable value, byte version);
+}
diff --git a/javax/rmi/CORBA/package.html b/javax/rmi/CORBA/package.html
index f5a5ac758..6014c8c85 100644
--- a/javax/rmi/CORBA/package.html
+++ b/javax/rmi/CORBA/package.html
@@ -1,5 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- package.html - describes classes in javax.rmi.CORBA package.
+<!-- package.html - describes classes in javax.rmi package.
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,7 +40,37 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.rmi.CORBA</title></head>
<body>
-<p></p>
-
+<p>
+Java RMI over IIOP combines RMI technology with CORBA technology. Like plain RMI,
+RMI over IIOP allows to work completely in the Java programming language
+(no IDL). When CORBA needs a separate helper class for each structure being
+passed, RMI over IIOP only needs stubs and ties for the objects that are remotely
+accessible. As a result, development with RMI-IIOP is easier. However the
+specialised pure CORBA helpers needs no reflection to transfer they structures
+and hence may be faster than methods, used by both RMI-IIOP and plain RMI.
+</p><p>
+Like RMI, RMI over IIOP provides flexibility by allowing to pass any serializable
+Java object (Objects By Value) between application components. A certain
+"imaginary IDL" is automatically supposed; this IDL can be explicitly generated
+and later used to interoperate with non-java application.
+</p><p>
+Like CORBA, RMI over IIOP is based on open standards defined with the
+participation of hundredsof vendors and users in the OMG. It uses IIOP
+communication protocol that provides much better interoperability with other
+programming languages.
+</p><p>
+With RMI/IIOP you can use advanced CORBA features: multiple objects per servant
+and servants per object, servant activators and locators, servant, client and
+ior interceptors, CORBA naming service, various ORB policies, stringified object
+references and so on. This functionality is based on CORBA value type standard.
+RMI/IIOP supports (and GNU Classpath implements) transferring of the arbitrary
+connected object graphs (graph flattenning).
+</p><p>
+GNU Classpath RMI-IIOP functionality is implemented as described in
+OMG formal/03-09-04 (IDL to Java mapping v1.3). Value types are written as
+described in formal/04-03-12 (CORBA 3.0.3).
+</p>
+@author Wu Gansha (gansha.wu@intel.com), headers.
+@author Audrius Meskauskas (AudriusA@Bioinformatics.org), implementation.
</body>
</html>
diff --git a/javax/rmi/ORB.java b/javax/rmi/ORB.java
deleted file mode 100644
index be7a894e6..000000000
--- a/javax/rmi/ORB.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package javax.rmi;
-
-/** XXX - Stub till we have org.omg.CORBA */
-public class ORB { }
diff --git a/javax/rmi/PortableRemoteObject.java b/javax/rmi/PortableRemoteObject.java
index 5e5d1fd29..5bb6b1126 100644
--- a/javax/rmi/PortableRemoteObject.java
+++ b/javax/rmi/PortableRemoteObject.java
@@ -1,5 +1,5 @@
-/* PortableRemoteObject.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* PortableRemoteObject.java --
+ Copyright (C) 2004, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,77 +39,190 @@ exception statement from your version. */
package javax.rmi;
import gnu.javax.rmi.CORBA.DelegateFactory;
-import gnu.javax.rmi.CORBA.GetDelegateInstanceException;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import javax.rmi.CORBA.PortableRemoteObjectDelegate;
-
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.CORBA.Util;
+
+/**
+ * <p>
+ * An utility class for RMI/IDL server side object implementations. Server side
+ * implementation objects may inherit from this class, but this is not
+ * mandatory, as the needed methds are static. Server side implementations may
+ * choose to inherit from {@link ObjectImpl} or {@link Servant} instead.
+ * </p>
+ * <p>
+ * The functionality of methods in this class is forwarded to the enclosed
+ * PortableRemoteObjectDelegate. This delegate can be altered by setting the
+ * system property "javax.rmi.CORBA.PortableRemoteObjectClass" to the name of
+ * the alternative class that must implement
+ * {@link PortableRemoteObjectDelegate}.
+ * </p>
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
public class PortableRemoteObject
- implements Remote /* why doc doesn't say should implement Remote */
{
-
- private static PortableRemoteObjectDelegate delegate;
- static
- {
- try
- {
- delegate = (PortableRemoteObjectDelegate)DelegateFactory.getInstance
- ("PortableRemoteObject");
- }
- catch(GetDelegateInstanceException e)
- {
- e.printStackTrace();
- delegate = null;
- }
- }
-
+ /**
+ * A delegate where the functionality is forwarded.
+ */
+ static PortableRemoteObjectDelegate delegate = (PortableRemoteObjectDelegate) DelegateFactory.getInstance(DelegateFactory.PORTABLE_REMOTE_OBJECT);
+
+ /**
+ * The protected constructor calls {@link exportObject} (this).
+ *
+ * @throws RemoteException if the exportObject(this) throws one.
+ */
protected PortableRemoteObject()
throws RemoteException
{
- if(delegate != null)
- exportObject((Remote)this);
+ exportObject((Remote) this);
}
+ /**
+ * <p>
+ * Makes the remote object <code>a_target</code> ready for remote
+ * communication using the same communications runtime as for the passed
+ * <code>a_source</code> parameter. The a_target is connected to the same
+ * ORB (and, if applicable, to the same {@link POA}) as the a_source.
+ *
+ * @param a_target the target to connect to ORB, must be an instance of either
+ * {@link ObjectImpl} (Stubs and old-style ties) or {@link Tie}.
+ *
+ * @param a_source the object, providing the connection information, must be
+ * an instance of either {@link ObjectImpl} (Stubs and old-style ties) or
+ * {@link Servant} (the next-generation Ties supporting {@link POA}).
+ *
+ * @throws RemoteException if the target is already connected to another ORB.
+ */
public static void connect(Remote target, Remote source)
throws RemoteException
{
- if(delegate != null)
- delegate.connect(target, source);
+ delegate.connect(target, source);
}
-
- public static void exportObject(Remote obj)
+
+ /**
+ * <p>
+ * Makes a server object ready for remote calls. The subclasses of
+ * PortableRemoteObject do not need to call this method, as it is called by
+ * the constructor.
+ * </p>
+ * <p>
+ * This method only creates a tie object and caches it for future usage. The
+ * created tie does not have a delegate or an ORB associated.
+ * </p>
+ *
+ * @param object the object to export.
+ *
+ * @throws RemoteException if export fails due any reason.
+ */
+ public static void exportObject(Remote object)
throws RemoteException
{
- if(delegate != null)
- delegate.exportObject(obj);
+ delegate.exportObject(object);
}
- public static Object narrow(Object narrowFrom, Class narrowTo)
+ /**
+ * Narrows the passed object to conform to the given interface or IDL type. In
+ * RMI-IIOP, this method replaces the narrow(org.omg.CORBA.Object) method that
+ * was present in the CORBA Helpers. This method frequently returns different
+ * instance and cannot be replaced by the direct cast. The typical narrowing
+ * cases (all supported by GNU Classpath) are:
+ * <ul>
+ * <li>A CORBA object (for instance, returned by the
+ * {@link ORB#string_to_object} or from the naming service) can be narrowed
+ * into interface, derived from Remote. The method will try to locate an
+ * appropriate {@link Stub} by the name pattern (_*_Stub). If the object being
+ * narrowed is connected to an ORB, the returned instance will inherit that
+ * connection, representing the same remote (or local) object, but now with
+ * the possibility to invoke remote methods. </li>
+ * <li>A CORBA object may be directly narrowed into the appropriate
+ * {@link Stub} class, if it is and passed as a second parameter. This allows
+ * to use non-standard stubs without parameterless constructors.</li>
+ * <li>Any two classes, derived from the {@link ObjectImpl} (may be Stub's)
+ * can be narrowed one into another (a delegate is transferred). </li>
+ * <li>An implementation of Remote can be narrowed into {@link Tie} that can
+ * later connected to an ORB, making the methods accessible remotely. The
+ * Remote being narrowed normally provides a local implementation, but you can
+ * also narrow remote Stub, creating "forwarding Tie".</li>
+ * <li>null is narrowed into null regardless of the second parameter.</li>
+ * <li>A {@link Tie} can be narrowed into Remote, representing the
+ * implementation for this Tie (if one is set).</li>
+ * </ul>
+ *
+ * @param object the object like CORBA Object, Stub or Remote that must be
+ * narrowed to the given interface.
+ *
+ * @param narrowToInstaceOf the class of the interface to that the object must
+ * be narrowed.
+ *
+ * @return On success, an object of type narrowTo or null, if narrowFrom =
+ * null.
+ *
+ * @throws ClassCastException if no narrowing is possible.
+ */
+ public static Object narrow(Object object, Class narrowToInstaceOf)
throws ClassCastException
{
- if(delegate != null)
- return delegate.narrow(narrowFrom, narrowTo);
- else
- return null;
+ return delegate.narrow(object, narrowToInstaceOf);
}
- public static Remote toStub(Remote obj)
+ /**
+ * <p>
+ * Takes a server implementation object (name pattern *imp) and returns a stub
+ * object that can be used to access that server object (target), name
+ * (pattern _*_Stub).
+ *
+ * The returned stub is not connected to any ORB and must be explicitly
+ * connected using {@link #connect}.
+ * </p>
+ * <p>
+ * The method signature prevents it from returning stubs that does not
+ * implement Remote (ClassCastException will be thrown).
+ * </p>
+ *
+ * @param target a server side object implementation.
+ * @return a stub object that can be used to access that server object.
+ *
+ * @throws NoSuchObjectException if a stub class cannot be located by supposed
+ * name pattern, or an instance of stub fails to be instantiated.
+ *
+ * @throws ClassCastException if the stub class can be located, but it does
+ * not inherit from Remote.
+ *
+ * @throws BAD_PARAM if the name of the passed class does not match the
+ * implementation name pattern (does not end by 'Impl').
+ */
+ public static Remote toStub(Remote targetImpl)
throws NoSuchObjectException
{
- if(delegate != null)
- return delegate.toStub(obj);
- else
- return null;
+ return delegate.toStub(targetImpl);
}
- public static void unexportObject(Remote obj)
+ /**
+ * Deregister a currently exported server object from the ORB runtimes. The
+ * object to becomes available for garbage collection. This is usually
+ * impemented via {@link Util#unexportObject}
+ *
+ * @param object the object to unexport.
+ *
+ * @throws NoSuchObjectException if the passed object is not currently
+ * exported.
+ */
+ public static void unexportObject(Remote object)
throws NoSuchObjectException
{
- if(delegate != null)
- delegate.unexportObject(obj);
+ delegate.unexportObject(object);
}
-
-}
+} \ No newline at end of file
diff --git a/javax/rmi/package.html b/javax/rmi/package.html
index febf59bd6..6014c8c85 100644
--- a/javax/rmi/package.html
+++ b/javax/rmi/package.html
@@ -37,10 +37,40 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. -->
<html>
-<head><title>GNU Classpath - javax.rmi</title></head>
+<head><title>GNU Classpath - javax.rmi.CORBA</title></head>
<body>
-<p></p>
-
+<p>
+Java RMI over IIOP combines RMI technology with CORBA technology. Like plain RMI,
+RMI over IIOP allows to work completely in the Java programming language
+(no IDL). When CORBA needs a separate helper class for each structure being
+passed, RMI over IIOP only needs stubs and ties for the objects that are remotely
+accessible. As a result, development with RMI-IIOP is easier. However the
+specialised pure CORBA helpers needs no reflection to transfer they structures
+and hence may be faster than methods, used by both RMI-IIOP and plain RMI.
+</p><p>
+Like RMI, RMI over IIOP provides flexibility by allowing to pass any serializable
+Java object (Objects By Value) between application components. A certain
+"imaginary IDL" is automatically supposed; this IDL can be explicitly generated
+and later used to interoperate with non-java application.
+</p><p>
+Like CORBA, RMI over IIOP is based on open standards defined with the
+participation of hundredsof vendors and users in the OMG. It uses IIOP
+communication protocol that provides much better interoperability with other
+programming languages.
+</p><p>
+With RMI/IIOP you can use advanced CORBA features: multiple objects per servant
+and servants per object, servant activators and locators, servant, client and
+ior interceptors, CORBA naming service, various ORB policies, stringified object
+references and so on. This functionality is based on CORBA value type standard.
+RMI/IIOP supports (and GNU Classpath implements) transferring of the arbitrary
+connected object graphs (graph flattenning).
+</p><p>
+GNU Classpath RMI-IIOP functionality is implemented as described in
+OMG formal/03-09-04 (IDL to Java mapping v1.3). Value types are written as
+described in formal/04-03-12 (CORBA 3.0.3).
+</p>
+@author Wu Gansha (gansha.wu@intel.com), headers.
+@author Audrius Meskauskas (AudriusA@Bioinformatics.org), implementation.
</body>
</html>
diff --git a/javax/security/auth/login/LoginContext.java b/javax/security/auth/login/LoginContext.java
index 8fc2ca759..a3cbf8f06 100644
--- a/javax/security/auth/login/LoginContext.java
+++ b/javax/security/auth/login/LoginContext.java
@@ -220,7 +220,9 @@ public class LoginContext
Exception cause = null;
try
{
- module = (LoginModule) Class.forName (entry.getLoginModuleName()).newInstance();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Class c = Class.forName(entry.getLoginModuleName(), true, cl);
+ module = (LoginModule) c.newInstance();
}
catch (ClassNotFoundException cnfe)
{
diff --git a/javax/security/auth/x500/X500Principal.java b/javax/security/auth/x500/X500Principal.java
index 78c35ade1..fcbb4950a 100644
--- a/javax/security/auth/x500/X500Principal.java
+++ b/javax/security/auth/x500/X500Principal.java
@@ -140,6 +140,22 @@ public final class X500Principal implements Principal, Serializable
// Instance methods.
// ------------------------------------------------------------------------
+ public int hashCode()
+ {
+ int result = size();
+ for (int i = 0; i < size(); ++i)
+ {
+ Map m = (Map) components.get(i);
+ for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); )
+ {
+ Map.Entry e = (Map.Entry) it2.next();
+ // We don't bother looking at the value of the entry.
+ result = result * 31 + ((OID) e.getKey()).hashCode();
+ }
+ }
+ return result;
+ }
+
public boolean equals(Object o)
{
if (!(o instanceof X500Principal))
diff --git a/javax/security/sasl/AuthenticationException.java b/javax/security/sasl/AuthenticationException.java
index 12a8fe052..0f674645d 100644
--- a/javax/security/sasl/AuthenticationException.java
+++ b/javax/security/sasl/AuthenticationException.java
@@ -1,5 +1,5 @@
/* AuthenticationException.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -49,6 +49,8 @@ package javax.security.sasl;
* instead of <code>AuthenticationException</code> if it is unable to determine
* the nature of the failure, or if does not want to disclose the nature of the
* failure, for example, due to security reasons.</p>
+ *
+ * @since 1.5
*/
public class AuthenticationException extends SaslException
{
diff --git a/javax/security/sasl/AuthorizeCallback.java b/javax/security/sasl/AuthorizeCallback.java
index bf1b8470d..fa3b29a3d 100644
--- a/javax/security/sasl/AuthorizeCallback.java
+++ b/javax/security/sasl/AuthorizeCallback.java
@@ -1,5 +1,5 @@
/* AuthorizeCallback.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,19 +38,23 @@ exception statement from your version. */
package javax.security.sasl;
+import java.io.Serializable;
import javax.security.auth.callback.Callback;
/**
* This callback is used by {@link SaslServer} to determine whether one entity
* (identified by an authenticated authentication ID) can act on behalf of
* another entity (identified by an authorization ID).
+ *
+ * @since 1.5
*/
-public class AuthorizeCallback implements Callback
+public class AuthorizeCallback implements Callback, Serializable
{
-
// Constants and variables
// -------------------------------------------------------------------------
+ private static final long serialVersionUID = -2353344186490470805L;
+
/** @serial The (authenticated) authentication id to check. */
private String authenticationID = null;
diff --git a/javax/security/sasl/RealmCallback.java b/javax/security/sasl/RealmCallback.java
index 12d834054..7cb36433f 100644
--- a/javax/security/sasl/RealmCallback.java
+++ b/javax/security/sasl/RealmCallback.java
@@ -1,5 +1,5 @@
/* RealmCallback.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,8 @@ import javax.security.auth.callback.TextInputCallback;
/**
* This callback is used by {@link SaslClient} and {@link SaslServer} to
* retrieve realm information.
+ *
+ * @since 1.5
*/
public class RealmCallback extends TextInputCallback
{
diff --git a/javax/security/sasl/RealmChoiceCallback.java b/javax/security/sasl/RealmChoiceCallback.java
index d16e61f6a..7068a504b 100644
--- a/javax/security/sasl/RealmChoiceCallback.java
+++ b/javax/security/sasl/RealmChoiceCallback.java
@@ -1,5 +1,5 @@
/* RealmChoiceCallback.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,8 @@ import javax.security.auth.callback.ChoiceCallback;
/**
* This callback is used by {@link SaslClient} and {@link SaslServer} to obtain
* a realm given a list of realm choices.
+ *
+ * @since 1.5
*/
public class RealmChoiceCallback extends ChoiceCallback
{
diff --git a/javax/security/sasl/Sasl.java b/javax/security/sasl/Sasl.java
index 058e4f6e1..dbe4cc8c2 100644
--- a/javax/security/sasl/Sasl.java
+++ b/javax/security/sasl/Sasl.java
@@ -74,6 +74,8 @@ import javax.security.auth.callback.CallbackHandler;
* Sasl.createSaslServer(mechanism, protocol, serverName, props,
* callbackHandler);
* </pre>
+ *
+ * @since 1.5
*/
public class Sasl
{
diff --git a/javax/security/sasl/SaslClient.java b/javax/security/sasl/SaslClient.java
index 544ab17d6..58eb5e298 100644
--- a/javax/security/sasl/SaslClient.java
+++ b/javax/security/sasl/SaslClient.java
@@ -1,5 +1,5 @@
/* SaslClient.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -102,6 +102,8 @@ package javax.security.sasl;
*
* @see Sasl
* @see SaslClientFactory
+ *
+ * @since 1.5
*/
public interface SaslClient
{
@@ -216,7 +218,7 @@ public interface SaslClient
* @throws IllegalStateException if this authentication exchange has not
* completed.
*/
- Object getNegotiatedProperty(String propName) throws SaslException;
+ Object getNegotiatedProperty(String propName);
/**
* Disposes of any system resources or security-sensitive information the
diff --git a/javax/security/sasl/SaslClientFactory.java b/javax/security/sasl/SaslClientFactory.java
index d6e8cd5ff..ae36171c5 100644
--- a/javax/security/sasl/SaslClientFactory.java
+++ b/javax/security/sasl/SaslClientFactory.java
@@ -1,5 +1,5 @@
/* SaslClientFactory.java
- Copyright (C) 2003, Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,6 +55,8 @@ import javax.security.auth.callback.CallbackHandler;
*
* @see SaslClient
* @see Sasl
+ *
+ * @since 1.5
*/
public interface SaslClientFactory
{
diff --git a/javax/security/sasl/SaslException.java b/javax/security/sasl/SaslException.java
index 13113e6bc..89764bb18 100644
--- a/javax/security/sasl/SaslException.java
+++ b/javax/security/sasl/SaslException.java
@@ -1,5 +1,5 @@
/* SaslException.java
- Copyright (C) 2003, Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,6 +45,8 @@ import java.io.Serializable;
/**
* This class represents an error that has occurred when using SASL.
+ *
+ * @since 1.5
*/
public class SaslException extends IOException implements Serializable
{
@@ -52,6 +54,8 @@ public class SaslException extends IOException implements Serializable
// Constants and variables
// -------------------------------------------------------------------------
+ private static final long serialVersionUID = 4579784287983423626L;
+
/**
* @serial The possibly null root cause exception.
*/
diff --git a/javax/security/sasl/SaslServer.java b/javax/security/sasl/SaslServer.java
index f5a04975d..d30b8f6ba 100644
--- a/javax/security/sasl/SaslServer.java
+++ b/javax/security/sasl/SaslServer.java
@@ -1,5 +1,5 @@
-/* SasServer.java
- Copyright (C) 2003, Free Software Foundation, Inc.
+/* SaslServer.java
+ Copyright (C) 2003, 2005, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -92,6 +92,8 @@ package javax.security.sasl;
*
* @see Sasl
* @see SaslServerFactory
+ *
+ * @since 1.5
*/
public interface SaslServer
{
@@ -211,7 +213,7 @@ public interface SaslServer
* @throws IllegalStateException if this authentication exchange has not
* completed.
*/
- Object getNegotiatedProperty(String propName) throws SaslException;
+ Object getNegotiatedProperty(String propName);
/**
* Disposes of any system resources or security-sensitive information the
diff --git a/javax/security/sasl/SaslServerFactory.java b/javax/security/sasl/SaslServerFactory.java
index 0fff32fa4..fc43fb636 100644
--- a/javax/security/sasl/SaslServerFactory.java
+++ b/javax/security/sasl/SaslServerFactory.java
@@ -1,5 +1,5 @@
/* SaslServerFactory.java
- Copyright (C) 2003, Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,6 +55,8 @@ import javax.security.auth.callback.CallbackHandler;
*
* @see SaslServer
* @see Sasl
+ *
+ * @since 1.5
*/
public interface SaslServerFactory
{
diff --git a/javax/sound/midi/ControllerEventListener.java b/javax/sound/midi/ControllerEventListener.java
new file mode 100644
index 000000000..eb075b32f
--- /dev/null
+++ b/javax/sound/midi/ControllerEventListener.java
@@ -0,0 +1,58 @@
+/* ControllerEventListener.java -- Listener for MIDI controller events
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+import java.util.EventListener;
+
+/**
+ * The interface defines the methods to be implemented by classes wanting
+ * to be notified on MIDI controller events from a Sequencer.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface ControllerEventListener extends EventListener
+{
+ /**
+ * Called on MIDI controller events.
+ * @param event the controller change event message
+ */
+ public void controlChange(ShortMessage event);
+}
diff --git a/javax/sound/midi/Instrument.java b/javax/sound/midi/Instrument.java
new file mode 100644
index 000000000..3402e8289
--- /dev/null
+++ b/javax/sound/midi/Instrument.java
@@ -0,0 +1,77 @@
+/* Instrument.java -- A MIDI Instrument
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * The abstract base class for all MIDI instruments.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public abstract class Instrument extends SoundbankResource
+{
+ // The instrument patch.
+ private Patch patch;
+
+ /**
+ * Create a new Instrument.
+ *
+ * @param soundbank the Soundbank containing the instrument.
+ * @param patch the patch for this instrument
+ * @param name the name of this instrument
+ * @param dataClass the class used to represent sample data for this instrument
+ */
+ protected Instrument(Soundbank soundbank, Patch patch,
+ String name, Class dataClass)
+ {
+ super(soundbank, name, dataClass);
+ this.patch = patch;
+ }
+
+ /**
+ * Get the patch for this instrument.
+ *
+ * @return the patch for this instrument
+ */
+ public Patch getPatch()
+ {
+ return patch;
+ }
+}
diff --git a/javax/sound/midi/InvalidMidiDataException.java b/javax/sound/midi/InvalidMidiDataException.java
new file mode 100644
index 000000000..d7f770757
--- /dev/null
+++ b/javax/sound/midi/InvalidMidiDataException.java
@@ -0,0 +1,90 @@
+/* InvalidMidiDataException.java -- Thrown for invalid MIDI data.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * This exception is thrown when we encounter bad MIDI data.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class InvalidMidiDataException extends Exception
+{
+ private static final long serialVersionUID = 2780771756789932067L;
+
+ /**
+ * Create an InvalidMidiDataException object.
+ */
+ public InvalidMidiDataException()
+ {
+ super();
+ }
+
+ /**
+ * Create an InvalidMidiDataException object.
+ *
+ * @param s the exception message string
+ */
+ public InvalidMidiDataException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an InvalidMidiDataException object.
+ *
+ * @param s the exception message string
+ * @param cause the root cause of the exception
+ */
+ public InvalidMidiDataException(String s, Throwable cause)
+ {
+ super(s, cause);
+ }
+
+ /**
+ * Create an InvalidMidiDataException object.
+ *
+ * @param cause the root cause of the exception
+ */
+ public InvalidMidiDataException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/gnu/java/awt/FocusManager.java b/javax/sound/midi/MetaEventListener.java
index 49b40bfc1..dd7b8a24b 100644
--- a/gnu/java/awt/FocusManager.java
+++ b/javax/sound/midi/MetaEventListener.java
@@ -1,4 +1,4 @@
-/* FocusManager.java -- Provide Swing FocusManager API compatibility
+/* MetaEventListener.java -- Listener for MIDI meta events
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,18 +35,24 @@ 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 gnu.java.awt;
+
+package javax.sound.midi;
+
+import java.util.EventListener;
/**
- * This is a subclass of the otherwise abstract class
- * {@link javax.swing.FocusManager}. Its sole purpose is to make the Swing
- * FocusManager usable as a FocusManager in AWT, so that we can provide both
- * the new (1.4) KeyboardFocusManager API and still support the older
- * Swing FocusManager.
+ * The interface defines the methods to be implemented by classes wanting
+ * to be notified on MIDI meta events from a Sequencer.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
*
- * @author Roman Kennke
*/
-public class FocusManager
- extends javax.swing.FocusManager
+public interface MetaEventListener extends EventListener
{
+ /**
+ * Called on MIDI meta events.
+ * @param meta the meta event message
+ */
+ public void meta(MetaMessage meta);
}
diff --git a/javax/sound/midi/MetaMessage.java b/javax/sound/midi/MetaMessage.java
new file mode 100644
index 000000000..2ca93accd
--- /dev/null
+++ b/javax/sound/midi/MetaMessage.java
@@ -0,0 +1,176 @@
+/* MetaMessage.java -- A meta message for MIDI files.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * A system exclusive MIDI message.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class MetaMessage extends MidiMessage
+{
+ /**
+ * The META status code. Only valid for MIDI files, not the wire protocol.
+ */
+ public static final int META = 0xFF;
+
+ // The length of the variable length data length encoding.
+ private int lengthLength = 0;
+
+ /**
+ * Create a default valid meta message.
+ *
+ * The official specs don't specify what message is to be
+ * created. For now, we create a zero length meta message
+ * with a type code of 0.
+ */
+ public MetaMessage()
+ {
+ super(new byte[4]);
+ data[0] = (byte) META;
+ data[1] = (byte) 0; // Type
+ data[2] = (byte) 1; // Length length
+ data[3] = (byte) 0; // Length
+ lengthLength = 1;
+ }
+
+ /**
+ * Create a MetaMessage object.
+ * @param data a complete system exclusive message
+ */
+ public MetaMessage(byte[] data)
+ {
+ super(data);
+ int index = 2;
+ lengthLength = 1;
+ while ((data[index++] & 0x80) > 0)
+ lengthLength++;
+ }
+
+ /**
+ * Set the meta message.
+ *
+ * @param type the meta type byte (< 128)
+ * @param data the message data
+ * @param length the length of the message data
+ * @throws InvalidMidiDataException if this message is invalid
+ */
+ public void setMessage(int type, byte[] data, int length)
+ throws InvalidMidiDataException
+ {
+ if (type > 127)
+ throw new InvalidMidiDataException("Meta type 0x"
+ + Integer.toHexString(type)
+ + " must be less than 128");
+
+ // For a nice description of how variable length values are handled,
+ // see http://www.borg.com/~jglatt/tech/midifile.htm
+
+ // First compute the length of the length value
+ lengthLength = 0;
+ int lengthValue = length;
+ do {
+ lengthValue = lengthValue >> 7;
+ lengthLength++;
+ } while (lengthValue > 0);
+
+ // Now allocate our data array
+ this.length = 2 + lengthLength + length;
+ this.data = new byte[this.length];
+ this.data[0] = (byte) META;
+ this.data[1] = (byte) type;
+
+ // Now compute the length representation
+ long buffer = length & 0x7F;
+ while ((length >>= 7) > 0)
+ {
+ buffer <<= 8;
+ buffer |= ((length & 0x7F) | 0x80);
+ }
+
+ // Now store the variable length length value
+ int index = 2;
+ do
+ {
+ this.data[index++] = (byte) (buffer & 0xFF);
+ if ((buffer & 0x80) == 0)
+ break;
+ buffer >>= 8;
+ } while (true);
+
+ // Now copy the real data.
+ System.arraycopy(data, 0, this.data, index, length);
+ }
+
+ /**
+ * Get the meta message type.
+ *
+ * @return the meta message type
+ */
+ public int getType()
+ {
+ return data[1];
+ }
+
+ /**
+ * Get the data for this message, not including the status,
+ * type, or length information.
+ *
+ * @return the message data, not including status, type or lenght info
+ */
+ public byte[] getData()
+ {
+ int dataLength = length - 2 - lengthLength;
+ byte[] result = new byte[dataLength];
+ System.arraycopy(data, 2 + lengthLength, result, 0, dataLength);
+ return result;
+ }
+
+ /* Create a deep-copy clone of this object.
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ {
+ byte message[] = new byte[length];
+ System.arraycopy(data, 0, message, 0, length);
+ return new MetaMessage(message);
+ }
+}
diff --git a/javax/sound/midi/MidiChannel.java b/javax/sound/midi/MidiChannel.java
new file mode 100644
index 000000000..fe3b5111a
--- /dev/null
+++ b/javax/sound/midi/MidiChannel.java
@@ -0,0 +1,236 @@
+/* MidiChannel.java -- A MIDI channel
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * A MIDI channel.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface MidiChannel
+{
+
+ /**
+ * Start playing a note.
+ *
+ * @param noteNumber the MIDI note number
+ * @param velocity the velocity at which the key was pressed
+ */
+ public void noteOn(int noteNumber, int velocity);
+
+ /**
+ * Stop playing a note.
+ *
+ * @param noteNumber the MIDI note number
+ * @param velocity the volcity at which the ket was released
+ */
+ public void noteOff(int noteNumber, int velocity);
+
+ /**
+ * Stop playing a note.
+ *
+ * @param noteNumber the MIDI note number
+ */
+ public void noteOff(int noteNumber);
+
+ /**
+ * Change in a key pressure for a note.
+ *
+ * @param noteNumber the MIDI note number
+ * @param pressure the key pressure
+ */
+ public void setPolyPressure(int noteNumber, int pressure);
+
+ /**
+ * Get the key pressure for a note.
+ *
+ * @param noteNumber the MIDI note number
+ * @return the key pressure
+ */
+ public int getPolyPressure(int noteNumber);
+
+ /**
+ * Set the key pressure for the channel.
+ *
+ * @param pressure the key pressure
+ */
+ public void setChannelPressure(int pressure);
+
+ /**
+ * Get the key pressure for the channel.
+ *
+ * @return the key pressure
+ */
+ public int getChannelPressure();
+
+ /**
+ * Set a change in a controller's value.
+ *
+ * @param controller the MIDI controller number (0 to 127)
+ * @param value the new value (0 to 127)
+ */
+ public void controlChange(int controller, int value);
+
+ /**
+ * Get a controller's value.
+ *
+ * @param controller the MIDI controller number (0 to 127)
+ * @return the controller's value (0 to 127)
+ */
+ public int getController(int controller);
+
+ /**
+ * Change the patch for this channel.
+ *
+ * @param program the patch number to switch to (0 to 127)
+ */
+ public void programChange(int program);
+
+ /**
+ * Change the bank and patch for this channel.
+ *
+ * @param bank the bank to switch to (0 to 16383)
+ * @param program the patch to switch to (0 to 127)
+ */
+ public void programChange(int bank, int program);
+
+ /**
+ * Get the current patch for this channel.
+ *
+ * @return current patch (0 to 127)
+ */
+ public int getProgram();
+
+ /**
+ * Change the pitch bend for this channel using a positive 14-bit value.
+ *
+ * @param bend the new pitch bend value
+ */
+ public void setPitchBend(int bend);
+
+ /**
+ * Get the pitch bend for this channel as a positive 14-bit value.
+ *
+ * @return the current patch bend value
+ */
+ public int getPitchBend();
+
+ /**
+ * Reset all MIDI controllers to their default values.
+ */
+ public void resetAllControllers();
+
+ /**
+ * Stop playing all notes. Sound may not stop.
+ */
+ public void allNotesOff();
+
+ /**
+ * Stop all sound.
+ */
+ public void allSoundOff();
+
+ /**
+ * Set whether or not local controls are on or off. They are on by
+ * default.
+ *
+ * @param on true to enable local controls, false to disable
+ * @return the new value
+ */
+ public boolean localControl(boolean on);
+
+ /**
+ * Turns mono mode on or off.
+ *
+ * @param on true to enable mono mode, false to disable
+ */
+ public void setMono(boolean on);
+
+ /**
+ * Get the current mono mode.
+ *
+ * @return true if mono is enabled, false otherwise
+ */
+ public boolean getMono();
+
+ /**
+ * Turns omni mode on or off.
+ *
+ * @param on true to enable omni mode, false to disable
+ */
+ public void setOmni(boolean on);
+
+ /**
+ * Get the current omni mode.
+ *
+ * @return true if omni is enabled, false otherwise
+ */
+ public boolean getOmni();
+
+ /**
+ * Turns mute mode on or off.
+ *
+ * @param mute true to enable mute mode, false to disable
+ */
+ public void setMute(boolean mute);
+
+ /**
+ * Get the current mute mode.
+ *
+ * @return true if mute is enabled, false otherwise
+ */
+ public boolean getMute();
+
+ /**
+ * Turns solo mode on or off. If any channels are soloed, then only those
+ * channels make sounds, otherwise all channels will make sound.
+ *
+ * @param solo true to enable solo mode, false to disable
+ */
+ public void setSolo(boolean solo);
+
+ /**
+ * Get the current solo mode.
+ *
+ * @return true is solo is enabled, false otherwise.
+ */
+ public boolean getSolo();
+}
diff --git a/javax/sound/midi/MidiDevice.java b/javax/sound/midi/MidiDevice.java
new file mode 100644
index 000000000..6f43c2548
--- /dev/null
+++ b/javax/sound/midi/MidiDevice.java
@@ -0,0 +1,220 @@
+/* MidiDevice.java -- Interface for MIDI devices
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * Interface for all MIDI devices.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface MidiDevice
+{
+ /**
+ * Get the Info object describing this device.
+ * @return the Info object describing this device
+ */
+ public Info getDeviceInfo();
+
+ /**
+ * Open this MIDI device and allocate any system resource we need.
+ *
+ * @throws MidiUnavailableException if we're not able to open for some reason
+ */
+ public void open() throws MidiUnavailableException;
+
+ /**
+ * Close this MIDI device, and release any system resources we're using.
+ */
+ public void close();
+
+ /**
+ * Returns true if this MIDI device is open and false otherwise.
+ *
+ * @return true if this is open, false otherwise
+ */
+ public boolean isOpen();
+
+ /**
+ * If this device supports time-stamps, then it will return the number
+ * of microseconds since this device has been open, and -1 otherwise.
+ *
+ * @return -1 or the number of microseconds since this was opened
+ */
+ public long getMicrosecondPosition();
+
+ /**
+ * The maximum number of MIDI IN connections we can get as Receivers,
+ * or -1 if there is no maximum.
+ *
+ * @return -1 or the maximum number of Receivers we can get
+ */
+ public int getMaxReceivers();
+
+ /**
+ * The maximum number of MIDI OUT connections we can get as Transmitters,
+ * or -1 if there is no maximum.
+ *
+ * @return -1 or the maximum number of Transmitters we can get
+ */
+ public int getMaxTransmitters();
+
+ /**
+ * Get a MIDI IN Receiver for this device.
+ *
+ * @return a MIDI IN Receiver for this device
+ * @throws MidiUnavailableException if we can't get a Receiver
+ */
+ public Receiver getReceiver() throws MidiUnavailableException;
+
+ /**
+ * Get a MIDI OUT Transmitter for this device.
+ *
+ * @return a MIDI OUT Transmitter for this device
+ * @throws MidiUnavailableException if we can't get a Transmitter
+ */
+ public Transmitter getTransmitter() throws MidiUnavailableException;
+
+ /**
+ * A MIDI device descriptor object.
+ *
+ * @author green@redhat.com
+ *
+ */
+ public static class Info
+ {
+ // Private data describing this device
+ private String name;
+ private String vendor;
+ private String description;
+ private String version;
+
+ /**
+ * Create an Info object for a MIDI device
+ *
+ * @param name the device name
+ * @param vendor the vendor name
+ * @param description the device description
+ * @param version the device version string
+ */
+ public Info(String name, String vendor, String description, String version)
+ {
+ this.name = name;
+ this.vendor = vendor;
+ this.description = description;
+ this.version = version;
+ }
+
+ /**
+ * This equals method only returns true if this object
+ * is the same as obj.
+ *
+ * @param obj the object we're comparing to
+ * @return true if this is the same object
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj)
+ {
+ return super.equals(obj);
+ }
+
+ /**
+ * A hash code for this object.
+ *
+ * @return the hash code for this object
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Get the device name.
+ *
+ * @return the device name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the device vendor.
+ *
+ * @return the device vendor
+ */
+ public String getVendor()
+ {
+ return vendor;
+ }
+
+ /**
+ * Get the device description
+ *
+ * @return the device description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * get the device version
+ *
+ * @return the device version
+ */
+ public String getVersion()
+ {
+ return version;
+ }
+
+ /**
+ * Simple return the name of the device.
+ *
+ * @return the device name
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return name;
+ }
+ }
+}
diff --git a/javax/sound/midi/MidiEvent.java b/javax/sound/midi/MidiEvent.java
new file mode 100644
index 000000000..3ca5c21ea
--- /dev/null
+++ b/javax/sound/midi/MidiEvent.java
@@ -0,0 +1,95 @@
+/* MidiEvent.java -- A MIDI Event
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * A MIDI event is the combination of a MIDI message and a timestamp specified
+ * in MIDI ticks.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class MidiEvent
+{
+ private final MidiMessage message;
+ private long tick;
+
+ /**
+ * Create a MIDI event object from the given MIDI message and timestamp.
+ *
+ * @param message the MidiMessage for this event
+ * @param tick the timestamp for this event
+ */
+ public MidiEvent(MidiMessage message, long tick)
+ {
+ this.message = message;
+ this.tick = tick;
+ }
+
+ /**
+ * Get the MIDI message for this event.
+ *
+ * @return the MidiMessage for this event
+ */
+ public MidiMessage getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * Set the timestemp for this event in MIDI ticks.
+ *
+ * @param tick the timestamp
+ */
+ public void setTick(long tick)
+ {
+ this.tick = tick;
+ }
+
+ /**
+ * Get the timestamp for this event in MIDI ticks.
+ *
+ * @return the timestamp for this even in MIDI ticks
+ */
+ public long getTick()
+ {
+ return tick;
+ }
+}
diff --git a/javax/sound/midi/MidiFileFormat.java b/javax/sound/midi/MidiFileFormat.java
new file mode 100644
index 000000000..79fa9fe29
--- /dev/null
+++ b/javax/sound/midi/MidiFileFormat.java
@@ -0,0 +1,158 @@
+/* MidiFileFormat.java -- Information about a MIDI file
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * Describe a MIDI file, including specifics about its type, length and timing.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class MidiFileFormat
+{
+ /**
+ * The MIDI file type. This is either 0, 1 or 2.
+ *
+ * Type 0 files contain a single track and represents a single song
+ * performance.
+ * Type 1 may contain multiple tracks for a single song performance.
+ * Type 2 may contain multiple tracks, each representing a
+ * separate song performance.
+ *
+ * See http://en.wikipedia.org/wiki/MIDI#MIDI_file_formats for more
+ * information.
+ */
+ protected int type;
+
+ /**
+ * The division type of the MIDI file.
+ */
+ protected float divisionType;
+
+ /**
+ * The timing resolution of the MIDI file.
+ */
+ protected int resolution;
+
+ /**
+ * The size of the MIDI file in bytes.
+ */
+ protected int byteLength = UNKNOWN_LENGTH;
+
+ /**
+ * The length of the MIDI file in microseconds.
+ */
+ protected long microsecondLength = UNKNOWN_LENGTH;
+
+ /**
+ * A special value indicating an unknown quantity.
+ */
+ public static final int UNKNOWN_LENGTH = -1; // FIXME is this really -1?
+
+ /**
+ * Create a MidiFileFormat object from the given parameters.
+ *
+ * @param type the MIDI file type (0, 1, or 2)
+ * @param divisionType the MIDI file division type
+ * @param resolution the MIDI file timing resolution
+ * @param bytes the MIDI file size in bytes
+ * @param microseconds the MIDI file length in microseconds
+ */
+ public MidiFileFormat(int type, float divisionType,
+ int resolution, int bytes, long microseconds)
+ {
+ this.type = type;
+ this.divisionType = divisionType;
+ this.resolution = resolution;
+ this.byteLength = bytes;
+ this.microsecondLength = microseconds;
+ }
+
+ /**
+ * Get the MIDI file type (0, 1, or 2).
+ *
+ * @return the MIDI file type (0, 1, or 2)
+ */
+ public int getType()
+ {
+ return type;
+ }
+
+ /**
+ * Get the file division type.
+ *
+ * @return the file divison type
+ */
+ public float getDivisionType()
+ {
+ return divisionType;
+ }
+
+ /**
+ * Get the file timing resolution. If the division type is PPQ, then this
+ * is value represents ticks per beat, otherwise it's ticks per frame (SMPTE).
+ *
+ * @return the timing resolution in ticks per beat or ticks per frame
+ */
+ public int getResolution()
+ {
+ return resolution;
+ }
+
+ /**
+ * Get the file length in bytes.
+ *
+ * @return the file length in bytes or UNKNOWN_LENGTH
+ */
+ public int getByteLength()
+ {
+ return byteLength;
+ }
+
+ /**
+ * Get the file length in microseconds.
+ *
+ * @return the file length in microseconds or UNKNOWN_LENGTH
+ */
+ public long getMicrosecondLength()
+ {
+ return microsecondLength;
+ }
+}
diff --git a/javax/sound/midi/MidiMessage.java b/javax/sound/midi/MidiMessage.java
new file mode 100644
index 000000000..e265b5ead
--- /dev/null
+++ b/javax/sound/midi/MidiMessage.java
@@ -0,0 +1,126 @@
+/* MidiMessage.java -- base class for MIDI messages.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * The base class for all MIDI messages.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public abstract class MidiMessage implements Cloneable
+{
+ /**
+ * MIDI message data.
+ */
+ protected byte data[];
+
+ /**
+ * The total length of the MIDI message.
+ */
+ protected int length;
+
+ /**
+ * MidiMessage contructor.
+ *
+ * @param data a valid MIDI message
+ */
+ protected MidiMessage(byte[] data)
+ {
+ this.data = data;
+ this.length = data.length;
+ }
+
+ /**
+ * Set the complete MIDI message.
+ *
+ * @param data The complete MIDI message.
+ * @param length The length of the MIDI message.
+ * @throws InvalidMidiDataException Thrown when the MIDI message is invalid.
+ */
+ protected void setMessage(byte[] data, int length)
+ throws InvalidMidiDataException
+ {
+ this.data = new byte[length];
+ System.arraycopy(data, 0, this.data, 0, length);
+ this.length = length;
+ }
+
+ /**
+ * Get the MIDI message data.
+ *
+ * @return an array containing the MIDI message data
+ */
+ public byte[] getMessage()
+ {
+ byte copy[] = new byte[length];
+ System.arraycopy(data, 0, copy, 0, length);
+ return copy;
+ }
+
+ /**
+ * Get the status byte of the MIDI message (as an int)
+ *
+ * @return the status byte of the MIDI message (as an int), or zero if the message length is zero.
+ */
+ public int getStatus()
+ {
+ if (length > 0)
+ return (data[0] & 0xff);
+ else
+ return 0;
+ }
+
+ /**
+ * Get the length of the MIDI message.
+ *
+ * @return the length of the MIDI messsage
+ */
+ public int getLength()
+ {
+ return length;
+ }
+
+ /* Create a clone of this object.
+ *
+ * @see java.lang.Object#clone()
+ */
+ public abstract Object clone();
+}
diff --git a/javax/sound/midi/MidiSystem.java b/javax/sound/midi/MidiSystem.java
new file mode 100644
index 000000000..8ea12eb70
--- /dev/null
+++ b/javax/sound/midi/MidiSystem.java
@@ -0,0 +1,566 @@
+/* MidiSystem.java -- Access system MIDI resources
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+import gnu.classpath.ServiceFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+
+import javax.sound.midi.spi.MidiDeviceProvider;
+import javax.sound.midi.spi.MidiFileReader;
+import javax.sound.midi.spi.MidiFileWriter;
+import javax.sound.midi.spi.SoundbankReader;
+
+/**
+ * MidiSystem provides access to the computer system's MIDI resources,
+ * as well as utility routines for reading MIDI files and more.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class MidiSystem
+{
+ /**
+ * Get an array of all available MIDI devices.
+ *
+ * @return a possibly empty array of all available MIDI devices
+ */
+ public static MidiDevice.Info[] getMidiDeviceInfo()
+ {
+ Iterator deviceProviders =
+ ServiceFactory.lookupProviders(MidiDeviceProvider.class);
+ List infoList = new ArrayList();
+
+ while (deviceProviders.hasNext())
+ {
+ MidiDeviceProvider provider = (MidiDeviceProvider) deviceProviders.next();
+ MidiDevice.Info[] infos = provider.getDeviceInfo();
+ for (int i = infos.length; i > 0; )
+ infoList.add(infos[--i]);
+ }
+
+ return (MidiDevice.Info[])
+ infoList.toArray(new MidiDevice.Info[infoList.size()]);
+ }
+
+ /**
+ * Get the specified MIDI device.
+ *
+ * @param info a description of the device we're looking for
+ * @return the requested MIDI device
+ * @throws MidiUnavailableException if no MIDI devices are configured or found
+ * @throws IllegalArgumentException if the device described by info is not found
+ */
+ public static MidiDevice getMidiDevice(MidiDevice.Info info)
+ throws MidiUnavailableException
+ {
+ Iterator deviceProviders =
+ ServiceFactory.lookupProviders(MidiDeviceProvider.class);
+
+ if (! deviceProviders.hasNext())
+ throw new MidiUnavailableException("No MIDI device providers available.");
+
+ do
+ {
+ MidiDeviceProvider provider =
+ (MidiDeviceProvider) deviceProviders.next();
+ if (provider.isDeviceSupported(info))
+ return provider.getDevice(info);
+ } while (deviceProviders.hasNext());
+
+ throw new IllegalArgumentException("MIDI device "
+ + info + " not available.");
+ }
+
+ /**
+ * Get the default Receiver instance. This just picks the first one
+ * it finds for now.
+ *
+ * @return the default Receiver instance
+ * @throws MidiUnavailableException if no Receiver is found
+ */
+ public static Receiver getReceiver() throws MidiUnavailableException
+ {
+ // TODO: The 1.5 spec has a fancy mechanism to specify the default
+ // receiver device. For now, well just return the first one we find.
+ MidiDevice.Info[] infos = getMidiDeviceInfo();
+ for (int i = 0; i < infos.length; i++)
+ {
+ MidiDevice device = getMidiDevice(infos[i]);
+ if (device instanceof Receiver)
+ return (Receiver) device;
+ }
+ throw new MidiUnavailableException("No Receiver device available");
+ }
+
+ /**
+ * Get the default Transmitter instance. This just picks the first one
+ * it finds for now.
+ *
+ * @return the default Transmitter instance
+ * @throws MidiUnavailableException if no Transmitter is found
+ */
+ public static Transmitter getTransmitter() throws MidiUnavailableException
+ {
+ // TODO: The 1.5 spec has a fancy mechanism to specify the default
+ // Transmitter device. For now, well just return the first one we find.
+ MidiDevice.Info[] infos = getMidiDeviceInfo();
+ for (int i = 0; i < infos.length; i++)
+ {
+ MidiDevice device = getMidiDevice(infos[i]);
+ if (device instanceof Transmitter)
+ return (Transmitter) device;
+ }
+ throw new MidiUnavailableException("No Transmitter device available");
+ }
+
+ /**
+ * Get the default Synthesizer instance. This just picks the first one
+ * it finds for now.
+ *
+ * @return the default Synthesizer instance
+ * @throws MidiUnavailableException if no Synthesizer is found
+ */
+ public static Synthesizer getSynthesizer() throws MidiUnavailableException
+ {
+ // TODO: The 1.5 spec has a fancy mechanism to specify the default
+ // Synthesizer device. For now, well just return the first one we find.
+ MidiDevice.Info[] infos = getMidiDeviceInfo();
+ for (int i = 0; i < infos.length; i++)
+ {
+ MidiDevice device = getMidiDevice(infos[i]);
+ if (device instanceof Synthesizer)
+ return (Synthesizer) device;
+ }
+ throw new MidiUnavailableException("No Synthesizer device available");
+ }
+
+ /**
+ * Get the default Sequencer instance. This just picks the first one
+ * it finds for now.
+ *
+ * @return the default Sequencer instance
+ * @throws MidiUnavailableException if no Sequencer is found
+ */
+ public static Sequencer getSequencer() throws MidiUnavailableException
+ {
+ // TODO: The 1.5 spec has a fancy mechanism to specify the default
+ // Sequencer device. For now, well just return the first one we find.
+ MidiDevice.Info[] infos = getMidiDeviceInfo();
+ for (int i = 0; i < infos.length; i++)
+ {
+ MidiDevice device = getMidiDevice(infos[i]);
+ if (device instanceof Sequencer)
+ return (Sequencer) device;
+ }
+ throw new MidiUnavailableException("No Sequencer device available");
+ }
+
+ /**
+ * Read a Soundbank object from the given stream.
+ *
+ * @param stream the stream from which to read the Soundbank
+ * @return the Soundbank object
+ * @throws InvalidMidiDataException if we were unable to read the soundbank
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static Soundbank getSoundbank(InputStream stream)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(SoundbankReader.class);
+ while (readers.hasNext())
+ {
+ SoundbankReader sr = (SoundbankReader) readers.next();
+ Soundbank sb = sr.getSoundbank(stream);
+ if (sb != null)
+ return sb;
+ }
+ throw new InvalidMidiDataException("Cannot read soundbank from stream");
+ }
+
+ /**
+ * Read a Soundbank object from the given url.
+ *
+ * @param url the url from which to read the Soundbank
+ * @return the Soundbank object
+ * @throws InvalidMidiDataException if we were unable to read the soundbank
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static Soundbank getSoundbank(URL url)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(SoundbankReader.class);
+ while (readers.hasNext())
+ {
+ SoundbankReader sr = (SoundbankReader) readers.next();
+ Soundbank sb = sr.getSoundbank(url);
+ if (sb != null)
+ return sb;
+ }
+ throw new InvalidMidiDataException("Cannot read from url " + url);
+ }
+
+ /**
+ * Read a Soundbank object from the given file.
+ *
+ * @param file the file from which to read the Soundbank
+ * @return the Soundbank object
+ * @throws InvalidMidiDataException if we were unable to read the soundbank
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static Soundbank getSoundbank(File file)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(SoundbankReader.class);
+ while (readers.hasNext())
+ {
+ SoundbankReader sr = (SoundbankReader) readers.next();
+ Soundbank sb = sr.getSoundbank(file);
+ if (sb != null)
+ return sb;
+ }
+ throw new InvalidMidiDataException("Cannot read soundbank from file "
+ + file);
+ }
+
+ /**
+ * Read a MidiFileFormat object from the given stream.
+ *
+ * @param stream the stream from which to read the MidiFileFormat
+ * @return the MidiFileFormat object
+ * @throws InvalidMidiDataException if we were unable to read the MidiFileFormat
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static MidiFileFormat getMidiFileFormat(InputStream stream)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
+ while (readers.hasNext())
+ {
+ MidiFileReader sr = (MidiFileReader) readers.next();
+ MidiFileFormat sb = sr.getMidiFileFormat(stream);
+ if (sb != null)
+ return sb;
+ }
+ throw new InvalidMidiDataException("Can't read MidiFileFormat from stream");
+ }
+
+ /**
+ * Read a MidiFileFormat object from the given url.
+ *
+ * @param url the url from which to read the MidiFileFormat
+ * @return the MidiFileFormat object
+ * @throws InvalidMidiDataException if we were unable to read the MidiFileFormat
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static MidiFileFormat getMidiFileFormat(URL url)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
+ while (readers.hasNext())
+ {
+ MidiFileReader sr = (MidiFileReader) readers.next();
+ MidiFileFormat sb = sr.getMidiFileFormat(url);
+ if (sb != null)
+ return sb;
+ }
+ throw new InvalidMidiDataException("Cannot read from url " + url);
+ }
+
+ /**
+ * Read a MidiFileFormat object from the given file.
+ *
+ * @param file the file from which to read the MidiFileFormat
+ * @return the MidiFileFormat object
+ * @throws InvalidMidiDataException if we were unable to read the MidiFileFormat
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static MidiFileFormat getMidiFileFormat(File file)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
+ while (readers.hasNext())
+ {
+ MidiFileReader sr = (MidiFileReader) readers.next();
+ MidiFileFormat sb = sr.getMidiFileFormat(file);
+ if (sb != null)
+ return sb;
+ }
+ throw new InvalidMidiDataException("Can't read MidiFileFormat from file "
+ + file);
+ }
+
+ /**
+ * Read a Sequence object from the given stream.
+ *
+ * @param stream the stream from which to read the Sequence
+ * @return the Sequence object
+ * @throws InvalidMidiDataException if we were unable to read the Sequence
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static Sequence getSequence(InputStream stream)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
+ while (readers.hasNext())
+ {
+ MidiFileReader sr = (MidiFileReader) readers.next();
+ Sequence sq = sr.getSequence(stream);
+ if (sq != null)
+ return sq;
+ }
+ throw new InvalidMidiDataException("Can't read Sequence from stream");
+ }
+
+ /**
+ * Read a Sequence object from the given url.
+ *
+ * @param url the url from which to read the Sequence
+ * @return the Sequence object
+ * @throws InvalidMidiDataException if we were unable to read the Sequence
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static Sequence getSequence(URL url)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
+ while (readers.hasNext())
+ {
+ MidiFileReader sr = (MidiFileReader) readers.next();
+ Sequence sq = sr.getSequence(url);
+ if (sq != null)
+ return sq;
+ }
+ throw new InvalidMidiDataException("Cannot read from url " + url);
+ }
+
+ /**
+ * Read a Sequence object from the given file.
+ *
+ * @param file the file from which to read the Sequence
+ * @return the Sequence object
+ * @throws InvalidMidiDataException if we were unable to read the Sequence
+ * @throws IOException if an I/O error happened while reading
+ */
+ public static Sequence getSequence(File file)
+ throws InvalidMidiDataException, IOException
+ {
+ Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
+ while (readers.hasNext())
+ {
+ MidiFileReader sr = (MidiFileReader) readers.next();
+ Sequence sq = sr.getSequence(file);
+ if (sq != null)
+ return sq;
+ }
+ throw new InvalidMidiDataException("Can't read Sequence from file "
+ + file);
+ }
+
+ /**
+ * Return an array of supported MIDI file types on this system.
+ *
+ * @return the array of supported MIDI file types
+ */
+ public static int[] getMidiFileTypes()
+ {
+ // We only support a max of 3 MIDI file types.
+ boolean supported[] = new boolean[3];
+ // The number of supported formats.
+ int count = 0;
+ Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
+ while (writers.hasNext())
+ {
+ MidiFileWriter fw = (MidiFileWriter) writers.next();
+ int types[] = fw.getMidiFileTypes();
+ for (int i = types.length; i > 0;)
+ {
+ int type = types[--i];
+ if (supported[type] == false)
+ {
+ count++;
+ supported[type] = true;
+ }
+ }
+ }
+ int result[] = new int[count];
+ for (int i = supported.length; i > 0;)
+ {
+ if (supported[--i])
+ result[--count] = i;
+ }
+ return result;
+ }
+
+ /**
+ * Return true if the system supports writing files of type fileType.
+ *
+ * @param fileType the MIDI file type we want to write
+ * @return true if we can write fileType files, false otherwise
+ */
+ public static boolean isFileTypeSupported(int fileType)
+ {
+ Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
+ while (writers.hasNext())
+ {
+ MidiFileWriter fw = (MidiFileWriter) writers.next();
+
+ if (fw.isFileTypeSupported(fileType))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return an array of supported MIDI file types on this system
+ * for the given sequnce.
+ *
+ * @param sequence the sequnce to write
+ * @return the array of supported MIDI file types
+ */
+ public static int[] getMidiFileTypes(Sequence sequence)
+ {
+ // We only support a max of 3 MIDI file types.
+ boolean supported[] = new boolean[3];
+ // The number of supported formats.
+ int count = 0;
+ Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
+ while (writers.hasNext())
+ {
+ MidiFileWriter fw = (MidiFileWriter) writers.next();
+ int types[] = fw.getMidiFileTypes(sequence);
+ for (int i = types.length; i > 0;)
+ {
+ int type = types[--i];
+ if (supported[type] == false)
+ {
+ count++;
+ supported[type] = true;
+ }
+ }
+ }
+ int result[] = new int[count];
+ for (int i = supported.length; i > 0;)
+ {
+ if (supported[--i])
+ result[--count] = i;
+ }
+ return result;
+ }
+
+ /**
+ * Return true if the system supports writing files of type fileType
+ * for the given sequence.
+ *
+ * @param fileType the MIDI file type we want to write
+ * @param sequence the Sequence we want to write
+ * @return true if we can write fileType files for sequence, false otherwise
+ */
+ public static boolean isFileTypeSupported(int fileType, Sequence sequence)
+ {
+ Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
+ while (writers.hasNext())
+ {
+ MidiFileWriter fw = (MidiFileWriter) writers.next();
+
+ if (fw.isFileTypeSupported(fileType, sequence))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Write a sequence to an output stream using a specific MIDI file format.
+ *
+ * @param in the sequence to write
+ * @param fileType the MIDI file format to use
+ * @param out the output stream to write to
+ * @return the number of bytes written
+ * @throws IOException if an I/O exception happens
+ * @throws IllegalArgumentException if fileType is not supported for in
+ */
+ public static int write(Sequence in, int fileType, OutputStream out)
+ throws IOException
+ {
+ Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
+ while (writers.hasNext())
+ {
+ MidiFileWriter fw = (MidiFileWriter) writers.next();
+
+ if (fw.isFileTypeSupported(fileType, in))
+ return fw.write(in, fileType, out);
+ }
+ throw new IllegalArgumentException("File type "
+ + fileType + " is not supported");
+ }
+
+ /**
+ * Write a sequence to a file using a specific MIDI file format.
+ *
+ * @param in the sequence to write
+ * @param fileType the MIDI file format to use
+ * @param out the file to write to
+ * @return the number of bytes written
+ * @throws IOException if an I/O exception happens
+ * @throws IllegalArgumentException if fileType is not supported for in
+ */
+ public static int write(Sequence in, int fileType, File out)
+ throws IOException
+ {
+ Iterator writers = ServiceFactory.lookupProviders(MidiFileWriter.class);
+ while (writers.hasNext())
+ {
+ MidiFileWriter fw = (MidiFileWriter) writers.next();
+
+ if (fw.isFileTypeSupported(fileType, in))
+ return fw.write(in, fileType, out);
+ }
+ throw new IllegalArgumentException("File type "
+ + fileType + " is not supported");
+ }
+}
+
diff --git a/javax/sound/midi/MidiUnavailableException.java b/javax/sound/midi/MidiUnavailableException.java
new file mode 100644
index 000000000..d4b85e810
--- /dev/null
+++ b/javax/sound/midi/MidiUnavailableException.java
@@ -0,0 +1,90 @@
+/* MidiUnavailableException.java -- MIDI resources are not available
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * This exception is thrown when MIDI resources are not available.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class MidiUnavailableException extends Exception
+{
+ private static final long serialVersionUID = 6093809578628944323L;
+
+ /**
+ * Create a MidiUnavailableException.
+ */
+ public MidiUnavailableException()
+ {
+ super();
+ }
+
+ /**
+ * Create an MidiUnavailableException object.
+ *
+ * @param s the exception message string
+ */
+ public MidiUnavailableException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an MidiUnavailableException object.
+ *
+ * @param s the exception message string
+ * @param cause the root cause of the exception
+ */
+ public MidiUnavailableException(String s, Throwable cause)
+ {
+ super(s, cause);
+ }
+
+ /**
+ * Create an MidiUnavailableException object.
+ *
+ * @param cause the root cause of the exception
+ */
+ public MidiUnavailableException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/javax/sound/midi/Patch.java b/javax/sound/midi/Patch.java
new file mode 100644
index 000000000..eb9d8bc3b
--- /dev/null
+++ b/javax/sound/midi/Patch.java
@@ -0,0 +1,86 @@
+/* Patch.java -- A MIDI patch.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * A Patch describes where an Instrument is loaded on a Synthesizer.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class Patch
+{
+ // Private data describing the patch
+ private int bank = 0;
+ private int program = 0;
+
+ /**
+ * Create a Patch object, specifying the bank and program in which this Patch
+ * is located.
+ *
+ * @param bank the bank in which this Patch is located
+ * @param program the program in which this Patch is located
+ */
+ public Patch(int bank, int program)
+ {
+ this.bank = bank;
+ this.program = program;
+ }
+
+ /**
+ * Get the bank in which this Patch is located.
+ *
+ * @return the bank in which this Patch is located
+ */
+ public int getBank()
+ {
+ return bank;
+ }
+
+ /**
+ * Get the program in which this Patch is located.
+ *
+ * @return the program in which this Patch is located
+ */
+ public int getProgram()
+ {
+ return program;
+ }
+}
diff --git a/javax/sound/midi/Receiver.java b/javax/sound/midi/Receiver.java
new file mode 100644
index 000000000..0e70b2809
--- /dev/null
+++ b/javax/sound/midi/Receiver.java
@@ -0,0 +1,66 @@
+/* Receiver.java -- An interface for objects receiving MIDI data
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * This interface describes the methods required by objects receiving MIDI
+ * messages.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface Receiver
+{
+ /**
+ * Send a MIDI message and timestamp. Some receivers don't support
+ * timestamps, in which case timeStamp should be -1.
+ *
+ * @param message the MIDI message to send
+ * @param timeStamp time timestamp for this message in microseconds (or -1)
+ * @throws IllegalStateException if the receiver is closed
+ */
+ public void send(MidiMessage message, long timeStamp)
+ throws IllegalStateException;
+
+ /**
+ * Close this receiver, possibly freeing system resources.
+ */
+ public void close();
+}
diff --git a/javax/sound/midi/Sequence.java b/javax/sound/midi/Sequence.java
new file mode 100644
index 000000000..1a43d207c
--- /dev/null
+++ b/javax/sound/midi/Sequence.java
@@ -0,0 +1,248 @@
+/* Sequence.java -- A sequence of MIDI events
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * Objects of this type represent sequences of MIDI messages that can be
+ * played back by a Sequencer.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class Sequence
+{
+ /**
+ * The timing division type for this sequence (PPQ or SMPTE*)
+ */
+ protected float divisionType;
+
+ /**
+ * The timing resolution in ticks/beat or ticks/frame, depending on the
+ * division type.
+ */
+ protected int resolution;
+
+ /**
+ * The MIDI tracks used by this sequence.
+ */
+ protected Vector tracks;
+
+ /**
+ * Tempo-based timing. Resolution is specified in ticks per beat.
+ */
+ public static final float PPQ = 0.0f;
+
+ /**
+ * 24 frames/second timing. Resolution is specific in ticks per frame.
+ */
+ public static final float SMPTE_24 = 24.0f;
+
+ /**
+ * 25 frames/second timing. Resolution is specific in ticks per frame.
+ */
+ public static final float SMPTE_25 = 25.0f;
+
+ /**
+ * 30 frames/second timing. Resolution is specific in ticks per frame.
+ */
+ public static final float SMPTE_30 = 30.0f;
+
+ /**
+ * 29.97 frames/second timing. Resolution is specific in ticks per frame.
+ */
+ public static final float SMPTE_30DROP = 29.97f;
+
+ // Private helper class
+ private void init(float divisionType, int resolution, int numTracks)
+ throws InvalidMidiDataException
+ {
+ if (divisionType != PPQ
+ && divisionType != SMPTE_24
+ && divisionType != SMPTE_25
+ && divisionType != SMPTE_30
+ && divisionType != SMPTE_30DROP)
+ throw new InvalidMidiDataException("Invalid division type ("
+ + divisionType + ")");
+
+ this.divisionType = divisionType;
+ this.resolution = resolution;
+
+ tracks = new Vector(numTracks);
+ while (numTracks > 0)
+ tracks.set(--numTracks, new Track());
+ }
+
+ /**
+ * Create a MIDI sequence object with no initial tracks.
+ *
+ * @param divisionType the division type (must be one of PPQ or SMPTE_*)
+ * @param resolution the timing resolution
+ * @throws InvalidMidiDataException if the division type is invalid
+ */
+ public Sequence(float divisionType, int resolution)
+ throws InvalidMidiDataException
+ {
+ init(divisionType, resolution, 0);
+ }
+
+ /**
+ * Create a MIDI seqence object.
+ *
+ * @param divisionType the division type (must be one of PPQ or SMPTE_*)
+ * @param resolution the timing resolution
+ * @param numTracks the number of initial tracks
+ * @throws InvalidMidiDataException if the division type is invalid
+ */
+ public Sequence(float divisionType, int resolution, int numTracks)
+ throws InvalidMidiDataException
+ {
+ init(divisionType, resolution, 0);
+ }
+
+ /**
+ * The division type of this sequence.
+ *
+ * @return division type of this sequence
+ */
+ public float getDivisionType()
+ {
+ return divisionType;
+ }
+
+ /**
+ * The timing resolution for this sequence, relative to the division type.
+ *
+ * @return the timing resolution for this sequence
+ */
+ public int getResolution()
+ {
+ return resolution;
+ }
+
+ /**
+ * Create a new empty MIDI track and add it to this sequence.
+ *
+ * @return the newly create MIDI track
+ */
+ public Track createTrack()
+ {
+ Track track = new Track();
+ tracks.add(track);
+ return track;
+ }
+
+ /**
+ * Remove the specified MIDI track from this sequence.
+ *
+ * @param track the track to remove
+ * @return true if track was removed and false othewise
+ */
+ public boolean deleteTrack(Track track)
+ {
+ return tracks.remove(track);
+ }
+
+ /**
+ * Get an array of MIDI tracks used in this sequence.
+ *
+ * @return a possibly empty array of tracks
+ */
+ public Track[] getTracks()
+ {
+ return (Track[]) tracks.toArray(new Track[tracks.size()]);
+ }
+
+ /**
+ * The length of this sequence in microseconds.
+ *
+ * @return the length of this sequence in microseconds
+ */
+ public long getMicrosecondLength()
+ {
+ long tickLength = getTickLength();
+
+ if (divisionType == PPQ)
+ {
+ // FIXME
+ // How can this possible be computed? PPQ is pulses per quarter-note,
+ // which is dependent on the tempo of the Sequencer.
+ throw new
+ UnsupportedOperationException("Can't compute PPQ based lengths yet");
+ }
+ else
+ {
+ // This is a fixed tick per frame computation
+ return (long) ((tickLength * 1000000) / (divisionType * resolution));
+ }
+ }
+
+ /**
+ * The length of this sequence in MIDI ticks.
+ *
+ * @return the length of this sequence in MIDI ticks
+ */
+ public long getTickLength()
+ {
+ long length = 0;
+ Iterator itr = tracks.iterator();
+ while (itr.hasNext())
+ {
+ Track track = (Track) itr.next();
+ long trackTicks = track.ticks();
+ if (trackTicks > length)
+ length = trackTicks;
+ }
+ return length;
+ }
+
+ /**
+ * Get an array of patches used in this sequence.
+ *
+ * @return an array of patches used in this sequence
+ */
+ public Patch[] getPatchList()
+ {
+ // FIXE: not quite sure how to do this yet.
+ throw new UnsupportedOperationException("Can't get patch list yet");
+ }
+}
diff --git a/javax/sound/midi/Sequencer.java b/javax/sound/midi/Sequencer.java
new file mode 100644
index 000000000..894d876e9
--- /dev/null
+++ b/javax/sound/midi/Sequencer.java
@@ -0,0 +1,402 @@
+/* Sequencer.java -- A MIDI sequencer object
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A Sequencer object plays MIDI sequences described as Sequence objects.
+ * This class provides methods for loading and unloading sequences, as well
+ * as basic transport controls.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface Sequencer extends MidiDevice
+{
+ /**
+ * Set the Sequence object for this sequencer.
+ *
+ * @param seq the Sequence to process
+ * @throws InvalidMidiDataException if the sequence is invalid for any reason
+ */
+ public void setSequence(Sequence seq) throws InvalidMidiDataException;
+
+ /**
+ * Set the sequence for this sequencer. istream reads on a valid MIDI file.
+ *
+ * @param istream an input stream for a valid MIDI file
+ * @throws IOException if an I/O exception happens
+ * @throws InvalidMidiDataException if the MIDI file contains bad data
+ */
+ public void setSequence(InputStream istream)
+ throws IOException, InvalidMidiDataException;
+
+ /**
+ * Get the current sequence object for this sequencer.
+ *
+ * @return the current sequence object. May be null.
+ */
+ public Sequence getSequence();
+
+ /**
+ * Start playback of the current sequence.
+ */
+ public void start();
+
+ /**
+ * Stop playback of the current sequence.
+ */
+ public void stop();
+
+ /**
+ * Returns true if the sequence is playing.
+ *
+ * @return true if the sequence is playing and false otherwise
+ */
+ public boolean isRunning();
+
+ /**
+ * Start playback and record of MIDI events.
+ * Any tracks enabled for recording will have their events replaced.
+ * Any newly recorded events, and all events from non-recording tracks
+ * will be sent to the sequencer's transmitter.
+ */
+ public void startRecording();
+
+ /**
+ * Stop recording, although continue playing.
+ */
+ public void stopRecording();
+
+ /**
+ * Returns true if sequence is recording.
+ *
+ * @return true if the sequence is recording and false otherwise
+ */
+ public boolean isRecording();
+
+ /**
+ * Enable recording for a specific track using data from a specific channel.
+ *
+ * @param track the track to enable for recording
+ * @param channel the channel from which to record
+ */
+ public void recordEnable(Track track, int channel);
+
+ /**
+ * Disable recording for a specific track.
+ *
+ * @param track the track to disable recording for
+ */
+ public void recordDisable(Track track);
+
+ /**
+ * Get the current tempo in beats per minute.
+ *
+ * @return the current tempo in beats per minute
+ */
+ public float getTempoInBPM();
+
+ /**
+ * Sets the current tempo in beats per minute.
+ *
+ * @param bpm the new tempo in bears per minutes
+ */
+ public void setTempoInBPM(float bpm);
+
+ /**
+ * Get the current tempo in microseconds per quarter note.
+ *
+ * @return the current tempo in microseconds per quarter note.
+ */
+ public float getTempoInMPQ();
+
+ /**
+ * Sets the current tempo in microseconds per quarter note.
+ *
+ * @param mpq the new tempo in microseconds per quarter note.
+ */
+ public void setTempoInMPQ(float mpq);
+
+ /**
+ * Set a scaling factor for the playback tempo, which is 1.0 by default.
+ *
+ * @param factor the new tempo scaling factor
+ */
+ public void setTempoFactor(float factor);
+
+ /**
+ * Get the current scaling factor for the playback tempo.
+ *
+ * @return the current tempo scaling factor
+ */
+ public float getTempoFactor();
+
+ /**
+ * Get the length of the current sequence in MIDI ticks.
+ *
+ * @return the length of the current sequence in MIDI ticks
+ */
+ public long getTickLength();
+
+ /**
+ * Get the current playback position of the sequencer in MIDI ticks.
+ *
+ * @return the current playback position of the sequencer in MIDI ticks
+ */
+ public long getTickPosition();
+
+ /**
+ * Set the current playback position of the sequencer in MIDI ticks.
+ *
+ * @param tick the new playback position of the sequencer in MIDI ticks
+ */
+ public void setTickPosition(long tick);
+
+ /**
+ * Get the length of the current sequence in microseconds.
+ *
+ * @return the length of the current sequence in microseconds
+ */
+ public long getMicrosecondLength();
+
+ /**
+ * Get the current playback position of the sequencer in microseconds.
+ *
+ * @return the current playback position of the sequencer in microseconds
+ */
+ public long getMicrosecondPosition();
+
+ /**
+ * Set the current playback position of the sequencer in microseconds.
+ *
+ * @param microsecond the new playback position of the sequencer in microseconds
+ */
+ public void setMicrosecondPosition(long microsecond);
+
+ /**
+ * Set the source of timing information. sync must be found in the array
+ * returned by getMasterSyncModes().
+ * FIXME: What happens if it isn't?
+ *
+ * @param sync the new source of timing information
+ */
+ public void setMasterSyncMode(SyncMode sync);
+
+ /**
+ * Get the source of timing information.
+ *
+ * @return the current source of timing information
+ */
+ public SyncMode getMasterSyncMode();
+
+ /**
+ * Get an array of timing sources supported by this sequencer.
+ *
+ * @return an array of timing sources supported by this sequencer
+ */
+ public SyncMode[] getMasterSyncModes();
+
+ /**
+ * Set the slave synchronization mode for this sequencer. sync must be
+ * found in the array returned by getSlaveSyncModes().
+ * FIXME: What happens if it isn't?
+ *
+ * @param sync the new slave sync mode for this sequencer
+ */
+ public void setSlaveSyncMode(SyncMode sync);
+
+ /**
+ * Get the current slave synchronization mode.
+ *
+ * @return the current slave synchronization mode
+ */
+ public SyncMode getSlaveSyncMode();
+
+ /**
+ * Get an array of slave sync modes supported by this sequencer.
+ *
+ * @return an array of slave sync modes supported by this sequencer
+ */
+ public SyncMode[] getSlaveSyncModes();
+
+ /**
+ * Sets the mute state for a specific track.
+ *
+ * @param track the track to modify
+ * @param mute the new mute state
+ */
+ public void setTrackMute(int track, boolean mute);
+
+ /**
+ * Get the mute state of a specific track.
+ *
+ * @param track the track to query
+ * @return the mute state for track
+ */
+ public boolean getTrackMute(int track);
+
+ /**
+ * Sets the solo state for a specific track.
+ *
+ * @param track the track to modify
+ * @param solo the new solo state
+ */
+ public void setTrackSolo(int track, boolean solo);
+
+ /**
+ * Get the solo state for a specific track.
+ *
+ * @param track the track to query
+ * @return the solo state for track
+ */
+ public boolean getTrackSolo(int track);
+
+ /**
+ * Add a meta event listening object to this sequencer. It will receive
+ * notification whenever the sequencer processes a meta event.
+ * A listener may fail to get added if this sequencer doesn't support
+ * meta events.
+ *
+ * @param listener the listener to add
+ * @return true if listener was added, false othewise
+ */
+ public boolean addMetaEventListener(MetaEventListener listener);
+
+ /**
+ * Remove a meta event listener from this sequencer.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeMetaEventListener(MetaEventListener listener);
+
+ /**
+ * Add a controller event listening object to this sequencer. It will
+ * receive notification whenever the sequencer processes a controller
+ * event for a specified controller number..
+ *
+ * @param listener the listener to add
+ * @param controllers the conroller numbers to listen to
+ * @return the controller numbers being listened to
+ */
+ public int[] addControllerEventListener(ControllerEventListener listener,
+ int controllers[]);
+
+ /**
+ * Remove a controller listener from this sequencer for the specified
+ * controller numbers.
+ *
+ * @param listener the listener to remove
+ * @param controllers the controllers to unlisten
+ * @return the controller numbers being unlistened
+ */
+ public int[] removeControllerEventListener(ControllerEventListener listener,
+ int controllers[]);
+
+ /**
+ * A SyncMode object represents the mechanism by which a MIDI sequencer
+ * synchronizes time with a master or slave device.
+ *
+ * @author green@redhat.com
+ *
+ */
+ public static class SyncMode
+ {
+ /**
+ * A master sync mode indicating the use of an internal sequencer clock.
+ */
+ public static final SyncMode INTERNAL_CLOCK = new SyncMode("Internal Clock");
+
+ /**
+ * A master or slave sync mode indicating the use of MIDI clock messages.
+ */
+ public static final SyncMode MIDI_SYNC = new SyncMode("MIDI Sync");
+
+ /**
+ * A master or slave sync mode indicating the use of MIDI Time Code
+ * messages.
+ */
+ public static final SyncMode MIDI_TIME_CODE = new SyncMode("MIDI Time Code");
+
+ /**
+ * A slave sync mode indicating that no timing info will be transmitted.
+ */
+ public static final SyncMode NO_SYNC = new SyncMode("No Timing");
+
+ // The name
+ private String name;
+
+ /**
+ * Create a new SyncMode object
+ * @param name the SyncMode name
+ */
+ protected SyncMode(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * SyncMode objects are only equal when identical.
+ */
+ public final boolean equals(Object o)
+ {
+ return super.equals(o);
+ }
+
+ /**
+ * SyncMode objects use the Object hashCode.
+ */
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ /**
+ * Use the SyncMode name as the string representation.
+ * @see java.lang.Object#toString()
+ */
+ public final String toString()
+ {
+ return name;
+ }
+ }
+}
diff --git a/javax/sound/midi/ShortMessage.java b/javax/sound/midi/ShortMessage.java
new file mode 100644
index 000000000..43c0e25fe
--- /dev/null
+++ b/javax/sound/midi/ShortMessage.java
@@ -0,0 +1,344 @@
+/* ShortMessage.java -- A MIDI message no longer than 3 bytes
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * A short MIDI message that is no longer than 3 bytes long.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class ShortMessage extends MidiMessage
+{
+ /**
+ * Status byte for System Exclusive message.
+ */
+ public static final int SYSTEM_EXCLUSIVE = 0xF0;
+
+ /**
+ * Status byte for Time Code message.
+ */
+ public static final int MIDI_TIME_CODE = 0xF1;
+
+ /**
+ * Status byte for Song Position Pointer message.
+ */
+ public static final int SONG_POSITION_POINTER = 0xF2;
+
+ /**
+ * Status byte for Song Select message.
+ */
+ public static final int SONG_SELECT = 0xF3;
+
+ /**
+ * Status byte for Tune Request message.
+ */
+ public static final int TUNE_REQUEST = 0xF6;
+
+ /**
+ * Status byte for End Of Exclusive message.
+ */
+ public static final int END_OF_EXCLUSIVE = 0xF7;
+
+ /**
+ * Status byte for Timing Clock message.
+ */
+ public static final int TIMING_CLOCK = 0xF8;
+
+ /**
+ * Status byte for Start message.
+ */
+ public static final int START = 0xFA;
+
+ /**
+ * Status byte for Continue message.
+ */
+ public static final int CONTINUE = 0xFB;
+
+ /**
+ * Status byte for Stop message.
+ */
+ public static final int STOP = 0xFC;
+
+ /**
+ * Status byte for Active Sensing message.
+ */
+ public static final int ACTIVE_SENSING = 0xFE;
+
+ /**
+ * Status byte for System Reset message.
+ */
+ public static final int SYSTEM_RESET = 0xFF;
+
+ /**
+ * Status nibble for Note Off message.
+ */
+ public static final int NOTE_OFF = 0x80;
+
+ /**
+ * Status nibble for Note On message.
+ */
+ public static final int NOTE_ON = 0x90;
+
+ /**
+ * Status nibble for Poly Pressure message.
+ */
+ public static final int POLY_PRESSURE = 0xA0;
+
+ /**
+ * Status nibble for Control Change message.
+ */
+ public static final int CONTROL_CHANGE = 0xB0;
+
+ /**
+ * Status nibble for Program Change message.
+ */
+ public static final int PROGRAM_CHANGE = 0xC0;
+
+ /**
+ * Statue nibble for Channel Pressure message.
+ */
+ public static final int CHANNEL_PRESSURE = 0xD0;
+
+ /**
+ * Status nibble for Pitch Bend message.
+ */
+ public static final int PITCH_BEND = 0xE0;
+
+ // Create and initialize a default, arbitrary message.
+ private static byte[] defaultMessage;
+ static
+ {
+ defaultMessage = new byte[1];
+ defaultMessage[0] = (byte) STOP;
+ }
+
+ /**
+ * Create a short MIDI message.
+ *
+ * The spec requires that this represent a valid MIDI message, but doesn't
+ * specify what it should be. We've chosen the STOP message for our
+ * implementation.
+ */
+ public ShortMessage()
+ {
+ this(defaultMessage);
+ }
+
+ /**
+ * Create a short MIDI message.
+ *
+ * The data argument should be a valid MIDI message. Unfortunately the spec
+ * does not allow us to throw an InvalidMidiDataException if data is invalid.
+ *
+ * @param data the message data
+ */
+ public ShortMessage(byte[] data)
+ {
+ super(data);
+ }
+
+ /**
+ * Set the MIDI message.
+ *
+ * @param status the status byte for this message
+ * @param data1 the first data byte for this message
+ * @param data2 the second data byte for this message
+ * @throws InvalidMidiDataException if status is bad, or data is out of range
+ */
+ public void setMessage(int status, int data1, int data2)
+ throws InvalidMidiDataException
+ {
+ length = getDataLength(status);
+ length++;
+ if (data == null || data.length < length)
+ data = new byte[length];
+ data[0] = (byte) status;
+ if (length > 1)
+ {
+ if (data1 < 0 || data1 > 127)
+ throw new InvalidMidiDataException("data1 (" + data1
+ + ") must be between 0 and 127.");
+ data[1] = (byte) data1;
+ if (length > 2)
+ {
+ if (data2 < 0 || data2 > 127)
+ throw new InvalidMidiDataException("data2 (" + data2
+ + ") must be between 0 and 127.");
+ data[2] = (byte) data2;
+ }
+ }
+ }
+
+ public void setMessage(int command, int channel, int data1, int data2)
+ throws InvalidMidiDataException
+ {
+ // TODO: This could probably stand some error checking.
+ // It currently assumes command and channel are valid values.
+ setMessage(command + channel, data1, data2);
+ }
+
+ /**
+ * Set the MIDI message to one that requires no data bytes.
+ *
+ * @param status the status byte for this message
+ * @throws InvalidMidiDataException if status is bad, or requires data
+ */
+ public void setMessage(int status) throws InvalidMidiDataException
+ {
+ int length = getDataLength(status);
+ if (length != 0)
+ throw new InvalidMidiDataException("Status byte 0x"
+ + Integer.toHexString(status)
+ + " requires "
+ + length + " bytes of data.");
+ setMessage(status, 0, 0);
+ }
+
+
+ /**
+ * Return the number of data bytes needed for a given MIDI status byte.
+ *
+ * @param status the status byte for a short MIDI message
+ * @return the number of data bytes needed for this status byte
+ * @throws InvalidMidiDataException if status is an invalid status byte
+ */
+ protected final int getDataLength(int status) throws InvalidMidiDataException
+ {
+ int originalStatus = status;
+
+ if ((status & 0xF0) != 0xF0)
+ status &= 0xF0;
+
+ switch (status)
+ {
+ case NOTE_OFF:
+ case NOTE_ON:
+ case POLY_PRESSURE:
+ case CONTROL_CHANGE:
+ case PITCH_BEND:
+ case SONG_POSITION_POINTER:
+ return 2;
+
+ case PROGRAM_CHANGE:
+ case CHANNEL_PRESSURE:
+ case SONG_SELECT:
+ case 0xF5: // FIXME: unofficial bus select. Not in spec??
+ return 1;
+
+ case SYSTEM_EXCLUSIVE:
+ return 0; // FIXME: is this correct?
+
+ case TUNE_REQUEST:
+ case END_OF_EXCLUSIVE:
+ case TIMING_CLOCK:
+ case START:
+ case CONTINUE:
+ case STOP:
+ case ACTIVE_SENSING:
+ case SYSTEM_RESET:
+ return 0;
+
+ default:
+ throw new InvalidMidiDataException("Invalid status: 0x"
+ + Integer.toHexString(originalStatus));
+ }
+ }
+
+ /**
+ * Get the channel information from this MIDI message, assuming it is a
+ * MIDI channel message.
+ *
+ * @return the MIDI channel for this message
+ */
+ public int getChannel()
+ {
+ return data[0] & 0x0F;
+ }
+
+ /**
+ * Get the command nibble from this MIDI message, assuming it is a MIDI
+ * channel message.
+ *
+ * @return the MIDI command for this message
+ */
+ public int getCommand()
+ {
+ return data[0] & 0xF0;
+ }
+
+ /**
+ * Get the first data byte from this message, assuming it exists, and
+ * zero otherwise.
+ *
+ * @return the first data byte or zero if none exists.
+ */
+ public int getData1()
+ {
+ if (length > 1)
+ return data[1];
+ else
+ return 0;
+ }
+
+ /**
+ * Get the second data byte from this message, assuming it exists, and
+ * zero otherwise.
+ *
+ * @return the second date byte or zero if none exists.
+ */
+ public int getData2()
+ {
+ if (length > 2)
+ return data[2];
+ else
+ return 0;
+ }
+
+ /* Create a deep-copy clone of this object.
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ {
+ byte message[] = new byte[length];
+ System.arraycopy(data, 0, message, 0, length);
+ return new ShortMessage(message);
+ }
+}
diff --git a/javax/sound/midi/Soundbank.java b/javax/sound/midi/Soundbank.java
new file mode 100644
index 000000000..16d9d79ea
--- /dev/null
+++ b/javax/sound/midi/Soundbank.java
@@ -0,0 +1,101 @@
+/* Soundbank.java -- Container of Instruments to be loaded into a Synthesizer
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * A Soundbank is a container for instruments which may be loaded into
+ * a Synthesizer.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface Soundbank
+{
+ /**
+ * Get the sound bank name.
+ *
+ * @return the sound bank name
+ */
+ String getName();
+
+ /**
+ * Get the sound bank version.
+ *
+ * @return the sound bank version
+ */
+ String getVersion();
+
+ /**
+ * Get the sound bank vendor.
+ *
+ * @return the sound bank vendor
+ */
+ String getVendor();
+
+
+ /**
+ * Get the sound bank description.
+ *
+ * @return the sound bank description
+ */
+ String getDescription();
+
+ /**
+ * Get an array of non-Instrument resources in this sound bank.
+ *
+ * @return an array of non-instrument resources in this sound bank
+ */
+ SoundbankResource[] getResources();
+
+ /**
+ * Get an array of Instruments in this sound bank.
+ *
+ * @return an array of instruments in this sound bank
+ */
+ Instrument[] getInstruments();
+
+ /**
+ * Get the Instrument for the given Patch.
+ *
+ * @param patch the Patch to search for
+ * @return the Instrument corresponding to patch
+ */
+ Instrument getInstrument(Patch patch);
+}
diff --git a/javax/sound/midi/SoundbankResource.java b/javax/sound/midi/SoundbankResource.java
new file mode 100644
index 000000000..435017e4c
--- /dev/null
+++ b/javax/sound/midi/SoundbankResource.java
@@ -0,0 +1,104 @@
+/* SoundbankResource.java -- An audio resource from a sound bank
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * SoundbankResource objects represent audio data stored in a sound bank.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public abstract class SoundbankResource
+{
+ private final Soundbank soundbank;
+ private final String name;
+ private final Class dataClass;
+
+ /**
+ * Create a SoundbankResource object.
+ *
+ * @param soundbank the soundbank object containing this resource
+ * @param name the name of the resource
+ * @param dataClass the class used to represent the audio data
+ */
+ protected SoundbankResource(Soundbank soundbank, String name, Class dataClass)
+ {
+ this.soundbank = soundbank;
+ this.name = name;
+ this.dataClass = dataClass;
+ }
+
+ /**
+ * Get the sound bank containing this resource.
+ *
+ * @return the sound bank in which this resource resides
+ */
+ public Soundbank getSoundbank()
+ {
+ return soundbank;
+ }
+
+ /**
+ * Get the name of this resource.
+ *
+ * @return the name of this resource
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the class used to represent the audio data for this resource.
+ *
+ * @return the class used to represent the audio data for this resource
+ */
+ public Class getDataClass()
+ {
+ return dataClass;
+ }
+
+ /**
+ * Get the audio data for this resource.
+ *
+ * @return the audio data object for this resource
+ */
+ public abstract Object getData();
+}
diff --git a/javax/sound/midi/Synthesizer.java b/javax/sound/midi/Synthesizer.java
new file mode 100644
index 000000000..22e5e9256
--- /dev/null
+++ b/javax/sound/midi/Synthesizer.java
@@ -0,0 +1,173 @@
+/* Synthesizer.java -- A MIDI audio synthesizer interface
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * Interface for MIDI audio synthesizer devices.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface Synthesizer extends MidiDevice
+{
+ /**
+ * Get the maximum number of notes that the synth can play at once.
+ *
+ * @return the maximum number of notes that the synth can play at once
+ */
+ public int getMaxPolyphony();
+
+ /**
+ * The processing latency for this synth in microseconds.
+ *
+ * @return the processing latency for this synth in microseconds
+ */
+ public long getLatency();
+
+ /**
+ * Get the set of MIDI channels controlled by this synth.
+ *
+ * @return an array of MIDI channels controlled by this synth
+ */
+ public MidiChannel[] getChannels();
+
+ /**
+ * Get the current status for the voices produced by this synth.
+ *
+ * @return an array of VoiceStatus objects, getMaxPolyphony() in length
+ */
+ public VoiceStatus[] getVoiceStatus();
+
+ /**
+ * Returns true is this synth is capable of loading soundbank.
+ *
+ * @param soundbank the Soundbank to examine
+ * @return true if soundbank can be loaded, false otherwise
+ */
+ public boolean isSoundbankSupported(Soundbank soundbank);
+
+ /**
+ * Load an instrument into this synth. The instrument must be part of a
+ * supported soundbank.
+ *
+ * @param instrument the Instrument to load
+ * @return true if the instrument was loaded and false otherwise
+ * @throws IllegalArgumentException if this synth doesn't support instrument
+ */
+ public boolean loadInstrument(Instrument instrument);
+
+ /**
+ * Unload an instrument from this synth.
+ *
+ * @param instrument the Instrument to unload
+ * @throws IllegalArgumentException if this synth doesn't support instrument
+ */
+ public void unloadInstrument(Instrument instrument);
+
+ /**
+ * Move an intrument from one place to another. The instrument at the
+ * target location is unloaded.
+ *
+ * @param from the instrument source
+ * @param to the instrument target
+ * @return if from was remapped
+ * @throws IllegalArgumentException
+ */
+ public boolean remapInstrument(Instrument from, Instrument to);
+
+ /**
+ * Get the default Soundbank for this synth. Return null if there is no
+ * default.
+ *
+ * @return the default Soundbank for this synth, possibly null.
+ */
+ public Soundbank getDefaultSoundbank();
+
+ /**
+ * Get an array containing all instruments in this synthesizer.
+ *
+ * @return an array containing all instruments in this synthesizer
+ */
+ public Instrument[] getAvailableInstruments();
+
+ /**
+ * Get an array containing all instruments loaded in this synthesizer.
+ *
+ * @return an array containing all instruments loaded in this synthesizer
+ */
+ public Instrument[] getLoadedInstruments();
+
+ /**
+ * Load all soundbank instruments into this synthesizer.
+ *
+ * @param soundbank the Soundbank from which to load instruments
+ * @return true if all instruments were loaded, false othewise
+ * @throws IllegalArgumentException if the soundbank isn't supported by this
+ */
+ public boolean loadAllInstruments(Soundbank soundbank);
+
+ /**
+ * Unload all soundbank instruments from this synthesizer.
+ *
+ * @param soundbank the Soundbank containing the instruments to unload
+ * @throws IllegalArgumentException if the soundbank isn't supported by this
+ */
+ public void unloadAllInstruments(Soundbank soundbank);
+
+ /**
+ * Load a subset of soundbank instruments into this synthesizer. The
+ * subset is defined by an array of Patch objects.
+ *
+ * @param soundbank the Soundbank from which to load instruments
+ * @param patchList the array of patches identifying instruments to load
+ * @return true if instruments were loaded, false otherwise
+ * @throws IllegalArgumentException if the soundbank isn't supported by this
+ */
+ public boolean loadInstruments(Soundbank soundbank, Patch[] patchList);
+
+ /**
+ * Unload a subset of soundbank instruments from this synthesizer.
+ *
+ * @param soundbank the Soundbank containing the instruments to unload
+ * @param patchList the array of patches identifying instruments to unload
+ * @throws IllegalArgumentException if the soundbank isn't supported by this
+ */
+ public void unloadInstruments(Soundbank soundbank, Patch[] patchList);
+}
diff --git a/javax/sound/midi/SysexMessage.java b/javax/sound/midi/SysexMessage.java
new file mode 100644
index 000000000..7ab60f4b6
--- /dev/null
+++ b/javax/sound/midi/SysexMessage.java
@@ -0,0 +1,139 @@
+/* SysexMessage.java -- System Exclusive MIDI message.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * A system exclusive MIDI message.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class SysexMessage extends MidiMessage
+{
+ public static final int SYSTEM_EXCLUSIVE = 0xF0;
+
+ public static final int SPECIAL_SYSTEM_EXCLUSIVE = 0xF7;
+
+ /**
+ * Create a default valid system exclusive message.
+ *
+ * The official specs don't specify what message is to be
+ * created. Our implementation creates an empty
+ * system exclusive message.
+ */
+ public SysexMessage()
+ {
+ super(new byte[2]);
+ data[0] = (byte) SYSTEM_EXCLUSIVE;
+ data[1] = (byte) ShortMessage.END_OF_EXCLUSIVE;
+ }
+
+ /**
+ * Create a SysexMessage object.
+ * @param data a complete system exclusive message
+ */
+ public SysexMessage(byte[] data)
+ {
+ super(data);
+ }
+
+ /**
+ * Set the sysex message. The first data byte (status) must be
+ * 0xF0 or 0xF7.
+ *
+ * @param data the message data
+ * @param length the length of the message data
+ * @throws InvalidMidiDataException if the status byte is not 0xF0 or 0xF7
+ */
+ public void setMessage(byte[] data, int length)
+ throws InvalidMidiDataException
+ {
+ if (data[0] != SYSTEM_EXCLUSIVE
+ || data[0] != SPECIAL_SYSTEM_EXCLUSIVE)
+ throw new InvalidMidiDataException("Sysex message starts with 0x"
+ + Integer.toHexString(data[0])
+ + " instead of 0xF0 or 0xF7");
+ super.setMessage(data, length);
+ }
+
+ /**
+ * Set the sysex message. status must be either 0xF0 or 0xF7.
+ *
+ * @param status the sysex statys byte (0xF0 or 0xF7)
+ * @param data the message data
+ * @param length the length of the message data
+ * @throws InvalidMidiDataException if status is not 0xF0 or 0xF7
+ */
+ public void setMessage(int status, byte[] data, int length)
+ throws InvalidMidiDataException
+ {
+ if (status != SYSTEM_EXCLUSIVE
+ || status != SPECIAL_SYSTEM_EXCLUSIVE)
+ throw new InvalidMidiDataException("Sysex message starts with 0x"
+ + Integer.toHexString(status)
+ + " instead of 0xF0 or 0xF7");
+ this.data = new byte[length+1];
+ this.data[0] = (byte) status;
+ System.arraycopy(data, 0, this.data, 1, length);
+ this.length = length+1;
+ }
+
+ /**
+ * Get the data for this message, not including the status byte.
+ * @return the message data, not including the status byte
+ */
+ public byte[] getData()
+ {
+ byte[] result = new byte[length - 1];
+ System.arraycopy(data, 1, result, 0, length - 1);
+ return result;
+ }
+
+ /* Create a deep-copy clone of this object.
+ * @see java.lang.Object#clone()
+ */
+ public Object clone()
+ {
+ byte message[] = new byte[length];
+ System.arraycopy(data, 0, message, 0, length);
+ return new SysexMessage(message);
+ }
+}
+
diff --git a/javax/sound/midi/Track.java b/javax/sound/midi/Track.java
new file mode 100644
index 000000000..da7ef2ef3
--- /dev/null
+++ b/javax/sound/midi/Track.java
@@ -0,0 +1,160 @@
+/* Track.java -- A track of MIDI events
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+import java.util.HashSet;
+import java.util.Vector;
+
+/**
+ * A Track contains a list of timecoded MIDI events for processing
+ * by a Sequencer.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class Track
+{
+ /**
+ * The list of MidiEvents for this track.
+ */
+ protected Vector events;
+
+ // A HashSet to speed processing
+ private HashSet eventSet;
+
+ /**
+ * Add a new event to this track. Specific events may only be added once.
+ * The event will be inserted into the appropriate spot in the event list
+ * based on its timecode.
+ *
+ * @param event the event to add
+ * @return true if the event was added, false otherwise
+ */
+ public boolean add(MidiEvent event)
+ {
+ synchronized (events)
+ {
+ if (eventSet.contains(event))
+ return false;
+
+ eventSet.add(event);
+
+ long targetTick = event.getTick();
+ int i = events.size() - 1;
+ while (i >= 0 && (((MidiEvent)events.get(i)).getTick() > targetTick))
+ i--;
+ events.add(i+1, event);
+ return true;
+ }
+ }
+
+ /**
+ * Remove an event from this track.
+ *
+ * @param event the event to remove
+ * @return true if the event was removed, false otherwise
+ */
+ public boolean remove(MidiEvent event)
+ {
+ synchronized (events)
+ {
+ if (! eventSet.remove(event))
+ return false;
+
+ int i = events.indexOf(event);
+ if (i >= 0)
+ {
+ events.remove(i);
+ return true;
+ }
+
+ throw new InternalError("event in set but not list");
+ }
+ }
+
+ /**
+ * Get an event idetified by its order index
+ *
+ * @param index the location of the event to get
+ * @return the event at index
+ * @throws ArrayIndexOutOfBoundsException if index is out of bounds
+ */
+ public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException
+ {
+ synchronized (events)
+ {
+ try
+ {
+ return (MidiEvent) events.get(index);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw (ArrayIndexOutOfBoundsException)
+ new ArrayIndexOutOfBoundsException().initCause(e);
+ }
+ }
+ }
+
+
+ /**
+ * Get the number events in this track.
+ *
+ * @return the number of events in this track
+ */
+ public int size()
+ {
+ return events.size();
+ }
+
+ /**
+ * Get the length of the track in MIDI ticks.
+ *
+ * @return the length of the track in MIDI ticks
+ */
+ public long ticks()
+ {
+ synchronized (events)
+ {
+ int size = events.size();
+ return ((MidiEvent) events.get(size - 1)).getTick();
+ }
+ }
+ }
+
diff --git a/javax/sound/midi/Transmitter.java b/javax/sound/midi/Transmitter.java
new file mode 100644
index 000000000..d788725e0
--- /dev/null
+++ b/javax/sound/midi/Transmitter.java
@@ -0,0 +1,70 @@
+/* Transmitter.java -- A interface for objects sending MIDI events
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * This interface specifies the methods required by objects which send
+ * MIDI events to Receivers, including MIDI IN ports and Sequencers.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public interface Transmitter
+{
+ /**
+ * Set the Receiver to which MIDI events will be sent.
+ *
+ * @param receiver the Receiver to which MIDI events will be sent
+ */
+ public void setReceiver(Receiver receiver);
+
+ /**
+ * Get the Receiver to which MIDI events will be sent (possibly null)
+ *
+ * @return the Receiver to which MIDI events will be sent (possibly null)
+ */
+ public Receiver getReceiver();
+
+ /**
+ * Close this Transmitter, possibly releasing system resources.
+ * FIXME: Does this mean the Receiver is closed? I think it must.
+ */
+ public void close();
+}
diff --git a/javax/sound/midi/VoiceStatus.java b/javax/sound/midi/VoiceStatus.java
new file mode 100644
index 000000000..a6a9c3f87
--- /dev/null
+++ b/javax/sound/midi/VoiceStatus.java
@@ -0,0 +1,79 @@
+/* VoiceStatus.java -- the current status of a Synthesizer voice
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi;
+
+/**
+ * Objects of this type define the status of a Synthesizer voice.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public class VoiceStatus
+{
+ /**
+ * True if this voice is processing a MIDI note.
+ */
+ public boolean active = false;
+
+ /**
+ * The channel for this voice when active.
+ */
+ public int channel = 0;
+
+ /**
+ * The bank of the voice when active.
+ */
+ public int bank = 0;
+
+ /**
+ * The program for this voice when active.
+ */
+ public int program = 0;
+
+ /**
+ * The note for this voice when active.
+ */
+ public int note = 0;
+
+ /**
+ * The volume for this voice when active.
+ */
+ public int volume = 0;
+}
diff --git a/javax/sound/midi/spi/MidiDeviceProvider.java b/javax/sound/midi/spi/MidiDeviceProvider.java
new file mode 100644
index 000000000..537edb2b3
--- /dev/null
+++ b/javax/sound/midi/spi/MidiDeviceProvider.java
@@ -0,0 +1,90 @@
+/* MidiDeviceProvider.java -- Abstract parent for a MIDI device provider.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi.spi;
+
+import javax.sound.midi.*;
+
+/**
+ * The abstract base class for all MidiDeviceProvider types.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public abstract class MidiDeviceProvider
+{
+ /**
+ * Returns true if this provider supports a specific MIDI device.
+ *
+ * @param info the MIDI device descriptor
+ * @return true if this provider supports info
+ */
+ public boolean isDeviceSupported(MidiDevice.Info info)
+ {
+ MidiDevice.Info infos[] = getDeviceInfo();
+
+ int i = infos.length;
+
+ while (i > 0)
+ {
+ if (info.equals(infos[--i]))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the list descriptors for all MIDI devices supported by
+ * this provider.
+ *
+ * @return an array of descriptors for all supported MIDI devices.
+ */
+ public abstract MidiDevice.Info[] getDeviceInfo();
+
+ /**
+ * Get the MidiDevice for the MIDI device described by info
+ *
+ * @param info the descriptor for the MIDI device we want
+ * @return the MidiDevice we're looking for
+ * @throws IllegalArgumentException is this provider doesn't support info
+ */
+ public abstract MidiDevice getDevice(MidiDevice.Info info)
+ throws IllegalArgumentException;
+}
diff --git a/javax/sound/midi/spi/MidiFileReader.java b/javax/sound/midi/spi/MidiFileReader.java
new file mode 100644
index 000000000..4342ebf5e
--- /dev/null
+++ b/javax/sound/midi/spi/MidiFileReader.java
@@ -0,0 +1,125 @@
+/* MidiFilerReader.java -- MIDI file reading services
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi.spi;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MidiFileFormat;
+import javax.sound.midi.Sequence;
+
+/**
+ * The MidiFileReader abstract class defines the methods to be provided
+ * by a MIDI file reader.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public abstract class MidiFileReader
+{
+ /**
+ * Read a MidiFileFormat from the given stream.
+ *
+ * @param stream the stream from which to read the MIDI data
+ * @return the MidiFileFormat object
+ * @throws InvalidMidiDataException if the stream refers to invalid data
+ * @throws IOException if an I/O exception occurs while reading
+ */
+ public abstract MidiFileFormat getMidiFileFormat(InputStream stream)
+ throws InvalidMidiDataException, IOException;
+
+ /**
+ * Read a MidiFileFormat from the given stream.
+ *
+ * @param url the url from which to read the MIDI data
+ * @return the MidiFileFormat object
+ * @throws InvalidMidiDataException if the url refers to invalid data
+ * @throws IOException if an I/O exception occurs while reading
+ */
+ public abstract MidiFileFormat getMidiFileFormat(URL url)
+ throws InvalidMidiDataException, IOException;
+
+ /**
+ * Read a MidiFileFormat from the given stream.
+ *
+ * @param file the file from which to read the MIDI data
+ * @return the MidiFileFormat object
+ * @throws InvalidMidiDataException if the file refers to invalid data
+ * @throws IOException if an I/O exception occurs while reading
+ */
+ public abstract MidiFileFormat getMidiFileFormat(File file)
+ throws InvalidMidiDataException, IOException;
+
+ /**
+ * Read a Sequence from the given stream.
+ *
+ * @param stream the stream from which to read the MIDI data
+ * @return the Sequence object
+ * @throws InvalidMidiDataException if the stream refers to invalid data
+ * @throws IOException if an I/O exception occurs while reading
+ */
+ public abstract Sequence getSequence(InputStream stream)
+ throws InvalidMidiDataException, IOException;
+
+ /**
+ * Read a Sequence from the given stream.
+ *
+ * @param url the url from which to read the MIDI data
+ * @return the Sequence object
+ * @throws InvalidMidiDataException if the url refers to invalid data
+ * @throws IOException if an I/O exception occurs while reading
+ */
+ public abstract Sequence getSequence(URL url)
+ throws InvalidMidiDataException, IOException;
+
+ /**
+ * Read a Sequence from the given stream.
+ *
+ * @param file the file from which to read the MIDI data
+ * @return the Sequence object
+ * @throws InvalidMidiDataException if the file refers to invalid data
+ * @throws IOException if an I/O exception occurs while reading
+ */
+ public abstract Sequence getSequence(File file)
+ throws InvalidMidiDataException, IOException;
+}
diff --git a/javax/sound/midi/spi/MidiFileWriter.java b/javax/sound/midi/spi/MidiFileWriter.java
new file mode 100644
index 000000000..e2a1f55c6
--- /dev/null
+++ b/javax/sound/midi/spi/MidiFileWriter.java
@@ -0,0 +1,143 @@
+/* MidiFileWriter.java -- MIDI file writing services
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi.spi;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.sound.midi.Sequence;
+
+/**
+ * MidiFileWriter provides MIDI file writing services.
+ *
+ * There are three types of Standard MIDI File (SMF) formats,
+ * represented by integers 0, 1, and 2.
+ *
+ * Type 0 files contain a single track and represents a single song
+ * performance.
+ * Type 1 may contain multiple tracks for a single song performance.
+ * Type 2 may contain multiple tracks, each representing a
+ * separate song performance.
+ *
+ * See http://en.wikipedia.org/wiki/MIDI#MIDI_file_formats for more
+ * information.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public abstract class MidiFileWriter
+{
+ /**
+ * Return the MIDI file types supported by this writer.
+ *
+ * @return the MIDI file types, or an empty array
+ */
+ public abstract int[] getMidiFileTypes();
+
+ /**
+ * Return the MIDI file types supported by this writer for the
+ * given sequence.
+ *
+ * @param sequence the sequence we'd like to write
+ * @return the MIDI file types, or an empty array
+ */
+ public abstract int[] getMidiFileTypes(Sequence sequence);
+
+ /**
+ * Returns true if this writer supports the given file type.
+ *
+ * @param fileType the file type we're asking about
+ * @return true if this writer supports fileType, false otherwise
+ */
+ public boolean isFileTypeSupported(int fileType)
+ {
+ int types[] = getMidiFileTypes();
+ for (int i = types.length; i > 0;)
+ {
+ if (types[--i] == fileType)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this writer supports the given file type for the
+ * given sequence.
+ *
+ * @param fileType the file type we're asking about
+ * @param sequence the sequence we'd like to write
+ * @return true if this writer supports fileType, false otherwise
+ */
+ public boolean isFileTypeSupported(int fileType, Sequence sequence)
+ {
+ int types[] = getMidiFileTypes(sequence);
+ for (int i = types.length; i > 0;)
+ {
+ if (types[--i] == fileType)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Write a sequence to a stream using the specified MIDI file type.
+ *
+ * @param in the sequence to write
+ * @param fileType the MIDI file type to use
+ * @param out the output stream to write to
+ * @return the number of byte written
+ * @throws IOException if an I/O exception happens
+ */
+ public abstract int write(Sequence in, int fileType, OutputStream out)
+ throws IOException;
+
+ /**
+ * Write a sequence to a file using the specified MIDI file type.
+ *
+ * @param in the sequence to write
+ * @param fileType the MIDI file type to use
+ * @param out the file to write to
+ * @return the number of byte written
+ * @throws IOException if an I/O exception happens
+ */
+ public abstract int write(Sequence in, int fileType, File out)
+ throws IOException;
+}
diff --git a/javax/sound/midi/spi/SoundbankReader.java b/javax/sound/midi/spi/SoundbankReader.java
new file mode 100644
index 000000000..dbf2bb018
--- /dev/null
+++ b/javax/sound/midi/spi/SoundbankReader.java
@@ -0,0 +1,97 @@
+/* SoundbankReader.java -- Soundbank file reading services
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.sound.midi.spi;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.Soundbank;
+
+/**
+ * The SoundbankReader abstract class defines the methods to be provided
+ * by a soundbank file reader.
+ *
+ * @author Anthony Green (green@redhat.com)
+ * @since 1.3
+ *
+ */
+public abstract class SoundbankReader
+{
+ /**
+ * Get a Soundbank from the given URL.
+ *
+ * @param url from which to read the Soundbank
+ *
+ * @return the Soundbank object
+ *
+ * @throws InvalidMidiDataException if the data provided by url cannot be recognized
+ * @throws IOException if the data provided by url cannot be read
+ */
+ public abstract Soundbank getSoundbank(URL url)
+ throws InvalidMidiDataException, IOException;
+
+ /**
+ * Get a Soundbank from the given InputStream.
+ *
+ * @param stream from which to read the Soundbank
+ *
+ * @return the Soundbank object
+ *
+ * @throws InvalidMidiDataException if the data provided by InputStream cannot be recognized
+ * @throws IOException if the data provided by InputStream cannot be read
+ */
+ public abstract Soundbank getSoundbank(InputStream stream)
+ throws InvalidMidiDataException, IOException;
+
+ /**
+ * Get a Soundbank from the given File.
+ *
+ * @param file from which to read the Soundbank
+ *
+ * @return the Soundbank object
+ *
+ * @throws InvalidMidiDataException if the data provided by File cannot be recognized
+ * @throws IOException if the data provided by File cannot be read
+ */
+ public abstract Soundbank getSoundbank(File file)
+ throws InvalidMidiDataException, IOException;
+}
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index 21c4fc0a2..9d9597639 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -165,6 +165,8 @@ public abstract class AbstractButton extends JComponent
*/
public void stateChanged(ChangeEvent ev)
{
+ AbstractButton.this.fireStateChanged();
+ repaint();
}
}
@@ -375,6 +377,7 @@ public abstract class AbstractButton extends JComponent
protected AccessibleAbstractButton()
{
+ // Nothing to do here yet.
}
public AccessibleStateSet getAccessibleStateSet()
@@ -509,11 +512,37 @@ public abstract class AbstractButton extends JComponent
}
/**
- * Creates a new AbstractButton object.
+ * Creates a new AbstractButton object. Subclasses should call the following
+ * sequence in their constructor in order to initialize the button correctly:
+ * <pre>
+ * super();
+ * init(text, icon);
+ * </pre>
+ *
+ * The {@link #init(String, Icon)} method is not called automatically by this
+ * constructor.
+ *
+ * @see #init(String, Icon)
*/
public AbstractButton()
{
- init("", null);
+ actionListener = createActionListener();
+ changeListener = createChangeListener();
+ itemListener = createItemListener();
+
+ horizontalAlignment = CENTER;
+ horizontalTextPosition = TRAILING;
+ verticalAlignment = CENTER;
+ verticalTextPosition = CENTER;
+ borderPainted = true;
+ contentAreaFilled = true;
+ focusPainted = true;
+ setFocusable(true);
+ setAlignmentX(CENTER_ALIGNMENT);
+ setAlignmentY(CENTER_ALIGNMENT);
+ setDisplayedMnemonicIndex(-1);
+ setOpaque(true);
+ text = "";
updateUI();
}
@@ -524,7 +553,7 @@ public abstract class AbstractButton extends JComponent
*/
public ButtonModel getModel()
{
- return model;
+ return model;
}
/**
@@ -569,25 +598,6 @@ public abstract class AbstractButton extends JComponent
if (icon != null)
default_icon = icon;
-
- actionListener = createActionListener();
- changeListener = createChangeListener();
- itemListener = createItemListener();
-
- horizontalAlignment = CENTER;
- horizontalTextPosition = TRAILING;
- verticalAlignment = CENTER;
- verticalTextPosition = CENTER;
- borderPainted = true;
- contentAreaFilled = true;
-
- focusPainted = true;
- setFocusable(true);
-
- setAlignmentX(LEFT_ALIGNMENT);
- setAlignmentY(CENTER_ALIGNMENT);
-
- setDisplayedMnemonicIndex(-1);
}
/**
@@ -615,7 +625,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setActionCommand(String actionCommand)
{
- model.setActionCommand(actionCommand);
+ if (model != null)
+ model.setActionCommand(actionCommand);
}
/**
@@ -782,7 +793,10 @@ public abstract class AbstractButton extends JComponent
*/
public int getMnemonic()
{
- return getModel().getMnemonic();
+ ButtonModel mod = getModel();
+ if (mod != null)
+ return mod.getMnemonic();
+ return -1;
}
/**
@@ -810,11 +824,15 @@ public abstract class AbstractButton extends JComponent
*/
public void setMnemonic(int mne)
{
- int old = getModel().getMnemonic();
+ ButtonModel mod = getModel();
+ int old = -1;
+ if (mod != null)
+ old = mod.getMnemonic();
if (old != mne)
{
- getModel().setMnemonic(mne);
+ if (mod != null)
+ mod.setMnemonic(mne);
if (text != null && !text.equals(""))
{
@@ -907,7 +925,9 @@ public abstract class AbstractButton extends JComponent
*/
public void setSelected(boolean s)
{
- getModel().setSelected(s);
+ ButtonModel mod = getModel();
+ if (mod != null)
+ mod.setSelected(s);
}
/**
@@ -918,7 +938,10 @@ public abstract class AbstractButton extends JComponent
*/
public boolean isSelected()
{
- return getModel().isSelected();
+ ButtonModel mod = getModel();
+ if (mod != null)
+ return mod.isSelected();
+ return false;
}
/**
@@ -929,8 +952,13 @@ public abstract class AbstractButton extends JComponent
*/
public void setEnabled(boolean b)
{
+ // Do nothing if state does not change.
+ if (b == isEnabled())
+ return;
super.setEnabled(b);
- getModel().setEnabled(b);
+ ButtonModel mod = getModel();
+ if (mod != null)
+ mod.setEnabled(b);
}
/**
@@ -1608,16 +1636,9 @@ public abstract class AbstractButton extends JComponent
*
* @return The new ChangeListener
*/
- protected ChangeListener createChangeListener()
+ protected ChangeListener createChangeListener()
{
- return new ChangeListener()
- {
- public void stateChanged(ChangeEvent e)
- {
- AbstractButton.this.fireStateChanged();
- AbstractButton.this.repaint();
- }
- };
+ return new ButtonChangeListener();
}
/**
@@ -1669,18 +1690,22 @@ public abstract class AbstractButton extends JComponent
*/
public void doClick(int pressTime)
{
- getModel().setArmed(true);
- getModel().setPressed(true);
- try
+ ButtonModel mod = getModel();
+ if (mod != null)
{
- java.lang.Thread.sleep(pressTime);
- }
- catch (java.lang.InterruptedException e)
- {
- // probably harmless
+ mod.setArmed(true);
+ mod.setPressed(true);
+ try
+ {
+ java.lang.Thread.sleep(pressTime);
+ }
+ catch (java.lang.InterruptedException e)
+ {
+ // probably harmless
+ }
+ mod.setPressed(false);
+ mod.setArmed(false);
}
- getModel().setPressed(false);
- getModel().setArmed(false);
}
/**
@@ -1979,6 +2004,7 @@ public abstract class AbstractButton extends JComponent
*/
public void updateUI()
{
+ // TODO: What to do here?
}
/**
diff --git a/javax/swing/AbstractSpinnerModel.java b/javax/swing/AbstractSpinnerModel.java
index 2590fe195..9402c1565 100644
--- a/javax/swing/AbstractSpinnerModel.java
+++ b/javax/swing/AbstractSpinnerModel.java
@@ -61,6 +61,7 @@ public abstract class AbstractSpinnerModel implements SpinnerModel
*/
public AbstractSpinnerModel()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/ActionMap.java b/javax/swing/ActionMap.java
index c14bafdb4..56bc41de6 100644
--- a/javax/swing/ActionMap.java
+++ b/javax/swing/ActionMap.java
@@ -80,6 +80,7 @@ public class ActionMap
*/
public ActionMap()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/BorderFactory.java b/javax/swing/BorderFactory.java
index 45cf3bbe0..ca78deb12 100644
--- a/javax/swing/BorderFactory.java
+++ b/javax/swing/BorderFactory.java
@@ -71,7 +71,7 @@ public class BorderFactory
*/
public static Border createLineBorder(Color color)
{
- return null;
+ return createLineBorder(color, 1);
}
/**
diff --git a/javax/swing/BoundedRangeModel.java b/javax/swing/BoundedRangeModel.java
index 5ca5a7e04..54446acd5 100644
--- a/javax/swing/BoundedRangeModel.java
+++ b/javax/swing/BoundedRangeModel.java
@@ -165,13 +165,13 @@ public interface BoundedRangeModel
*
* @param value the value
* @param extent the extent
- * @param minnimum the minimum value
+ * @param minimum the minimum value
* @param maximum the maximum value
* @param adjusting a flag that indicates the model is being adjusted
* continuously.
*/
void setRangeProperties(int value, int extent, int minimum, int maximum,
- boolean adjusting);
+ boolean adjusting);
/**
* Adds a <code>ChangeListener</code> to this object.
diff --git a/javax/swing/Box.java b/javax/swing/Box.java
index 9cd4421a2..57519f6fc 100644
--- a/javax/swing/Box.java
+++ b/javax/swing/Box.java
@@ -70,6 +70,7 @@ public class Box extends JComponent implements Accessible
protected AccessibleBox()
{
+ // Nothing to do here.
}
public AccessibleRole getAccessibleRole()
@@ -95,6 +96,7 @@ public class Box extends JComponent implements Accessible
protected AccessibleBoxFiller()
{
+ // Nothing to do here.
}
public AccessibleRole getAccessibleRole()
@@ -103,8 +105,6 @@ public class Box extends JComponent implements Accessible
}
}
- protected AccessibleContext accessibleContext;
-
private transient Dimension min, pref, max;
/**
diff --git a/javax/swing/BoxLayout.java b/javax/swing/BoxLayout.java
index 28bb53928..fb540e478 100644
--- a/javax/swing/BoxLayout.java
+++ b/javax/swing/BoxLayout.java
@@ -45,12 +45,6 @@ import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager2;
import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import gnu.java.awt.AWTUtilities;
/**
* A layout that stacks the children of a container in a Box, either
@@ -63,248 +57,6 @@ public class BoxLayout implements LayoutManager2, Serializable
{
/**
- * This is an abstraction that allows the BoxLayout algorithm to
- * be applied to both direction (X and Y) without duplicating the
- * algorithm. It defines several methods that access properties of
- * a component for a specific direction.
- */
- static interface Direction
- {
- /**
- * Returns the correct part of <code>d</code> for this direction. This will
- * be <code>d.width</code> for horizontal and <code>d.height</code> for
- * vertical direction.
- *
- * @param d the size as Dimension object
- *
- * @return the correct part of <code>d</code> for this direction
- */
- int size(Dimension d);
-
- /**
- * Returns the lower bounds of the {@link Insets} object according to this
- * direction. This will be <code>insets.top</code> for vertical direction
- * and <code>insets.left</code> for horizontal direction.
- *
- * @param the {@link Insets} object from which to return the lower bounds
- *
- * @return the lower bounds of the {@link Insets} object according to this
- * direction
- */
- int lower(Insets insets);
-
- /**
- * Returns the alignment property according to this direction.
- *
- * @param comp the Component for which to return the alignment property
- *
- * @return the alignment property according to this direction
- */
- float alignment(Component comp);
-
- /**
- * Sets the location for Component <code>c</code>. <code>coord1</code>
- * specifies the coordinate of the location in this direction,
- * <code>coord2</code> the coordinate of the location in the opposite
- * direction.
- *
- * @param c the Component for which to set the location
- * @param coord1 the coordinate in this direction
- * @param coord2 the coordinate in the opposite direction
- */
- void setLocation(Component c, int coord1, int coord2);
-
- /**
- * Sets the size for Component <code>c</code>. <code>coord1</code>
- * specifies the size in this direction,
- * <code>coord2</code> the size in the opposite
- * direction.
- *
- * @param c the Component for which to set the size
- * @param size1 the size in this direction
- * @param size2 the size in the opposite direction
- */
- void setSize(Component c, int size1, int size2);
- }
-
- /**
- * The horizontal direction.
- */
- static class Horizontal implements Direction
- {
- /**
- * Returns the correct part of <code>d</code> for this direction. This will
- * be <code>d.width</code> for horizontal and <code>d.height</code> for
- * vertical direction.
- *
- * @param d the size as Dimension object
- *
- * @return the correct part of <code>d</code> for this direction
- */
- public int size(Dimension d)
- {
- return d.width;
- }
-
- /**
- * Returns the lower bounds of the {@link Insets} object according to this
- * direction. This will be <code>insets.top</code> for vertical direction
- * and <code>insets.left</code> for horizontal direction.
- *
- * @param insets the {@link Insets} object from which to return the lower
- * bounds
- *
- * @return the lower bounds of the {@link Insets} object according to this
- * direction
- */
- public int lower(Insets insets)
- {
- return insets.left;
- }
-
- /**
- * Returns the alignment property according to this direction.
- *
- * @param comp the Component for which to return the alignment property
- *
- * @return the alignment property according to this direction
- */
- public float alignment(Component comp)
- {
- return comp.getAlignmentX();
- }
-
- /**
- * Sets the location for Component <code>c</code>. <code>coord1</code>
- * specifies the coordinate of the location in this direction,
- * <code>coord2</code> the coordinate of the location in the opposite
- * direction.
- *
- * @param c the Component for which to set the location
- * @param coord1 the coordinate in this direction
- * @param coord2 the coordinate in the opposite direction
- */
- public void setLocation(Component c, int coord1, int coord2)
- {
- c.setLocation(coord1, coord2);
- }
-
- /**
- * Sets the size for Component <code>c</code>. <code>coord1</code>
- * specifies the size in this direction,
- * <code>coord2</code> the size in the opposite
- * direction.
- *
- * @param c the Component for which to set the size
- * @param size1 the size in this direction
- * @param size2 the size in the opposite direction
- */
- public void setSize(Component c, int size1, int size2)
- {
- c.setSize(size1, size2);
- }
- }
- /**
- * The vertical direction.
- */
- static class Vertical implements Direction
- {
- /**
- * Returns the correct part of <code>d</code> for this direction. This will
- * be <code>d.width</code> for horizontal and <code>d.height</code> for
- * vertical direction.
- *
- * @param d the size as Dimension object
- *
- * @return the correct part of <code>d</code> for this direction
- */
- public int size(Dimension d)
- {
- return d.height;
- }
-
- /**
- * Returns the lower bounds of the {@link Insets} object according to this
- * direction. This will be <code>insets.top</code> for vertical direction
- * and <code>insets.left</code> for horizontal direction.
- *
- * @param insets the {@link Insets} object from which to return the lower
- * bounds
- *
- * @return the lower bounds of the {@link Insets} object according to this
- * direction
- */
- public int lower(Insets insets)
- {
- return insets.top;
- }
-
- /**
- * Returns the alignment property according to this direction.
- *
- * @param comp the Component for which to return the alignment property
- *
- * @return the alignment property according to this direction
- */
- public float alignment(Component comp)
- {
- return comp.getAlignmentY();
- }
-
- /**
- * Sets the location for Component <code>c</code>. <code>coord1</code>
- * specifies the coordinate of the location in this direction,
- * <code>coord2</code> the coordinate of the location in the opposite
- * direction.
- *
- * @param c the Component for which to set the location
- * @param coord1 the coordinate in this direction
- * @param coord2 the coordinate in the opposite direction
- */
- public void setLocation(Component c, int coord1, int coord2)
- {
- c.setLocation(coord2, coord1);
- }
-
- /**
- * Sets the size for Component <code>c</code>. <code>coord1</code>
- * specifies the size in this direction,
- * <code>coord2</code> the size in the opposite
- * direction.
- *
- * @param c the Component for which to set the size
- * @param size1 the size in this direction
- * @param size2 the size in the opposite direction
- */
- public void setSize(Component c, int size1, int size2)
- {
- c.setSize(size2, size1);
- }
- }
-
- /**
- * A helper class that temporarily stores the size specs of a component.
- */
- static class SizeReq
- {
- int size;
- int min;
- int pref;
- int max;
- float align;
- Component comp;
- SizeReq(Component comp, Direction dir)
- {
- this.min = dir.size(comp.getMinimumSize());
- this.pref = dir.size(comp.getPreferredSize());
- this.max = dir.size(comp.getMaximumSize());
- this.size = dir.size(comp.getSize());
- this.align = dir.alignment(comp);
- this.comp = comp;
- }
- }
-
- /**
* Specifies that components are laid out left to right.
*/
public static final int X_AXIS = 0;
@@ -334,16 +86,50 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
private Container container;
- /*
+ /**
* Current type of component layouting. Defaults to X_AXIS.
*/
private int way = X_AXIS;
- /** Constant for the horizontal direction. */
- private static final Direction HORIZONTAL = new Horizontal();
+ /**
+ * The size requirements of the containers children for the X direction.
+ */
+ private SizeRequirements[] xChildren;
- /** Constant for the vertical direction. */
- private static final Direction VERTICAL = new Vertical();
+ /**
+ * The size requirements of the containers children for the Y direction.
+ */
+ private SizeRequirements[] yChildren;
+
+ /**
+ * The size requirements of the container to be laid out for the X direction.
+ */
+ private SizeRequirements xTotal;
+
+ /**
+ * The size requirements of the container to be laid out for the Y direction.
+ */
+ private SizeRequirements yTotal;
+
+ /**
+ * The offsets of the child components in the X direction.
+ */
+ private int[] offsetsX;
+
+ /**
+ * The offsets of the child components in the Y direction.
+ */
+ private int[] offsetsY;
+
+ /**
+ * The spans of the child components in the X direction.
+ */
+ private int[] spansX;
+
+ /**
+ * The spans of the child components in the Y direction.
+ */
+ private int[] spansY;
/**
* Constructs a <code>BoxLayout</code> object.
@@ -369,6 +155,7 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public void addLayoutComponent(String name, Component component)
{
+ // Nothing to do here.
}
/**
@@ -378,6 +165,7 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public void removeLayoutComponent(Component component)
{
+ // Nothing to do here.
}
private boolean isHorizontalIn(Container parent)
@@ -401,45 +189,16 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public Dimension preferredLayoutSize(Container parent)
{
- if (parent != container)
- throw new AWTError("invalid parent");
-
- Insets insets = parent.getInsets();
- int x = 0;
- int y = 0;
-
- List children = AWTUtilities.getVisibleChildren(parent);
+ synchronized (container.getTreeLock())
+ {
+ if (container != parent)
+ throw new AWTError("BoxLayout can't be shared");
- if (isHorizontalIn(parent))
- {
- x = insets.left + insets.right;
- // sum up preferred widths of components, find maximum of preferred
- // heights
- for (Iterator i = children.iterator(); i.hasNext();)
- {
- Component comp = (Component) i.next();
- Dimension sz = comp.getPreferredSize();
- x += sz.width;
- y = Math.max(y, sz.height);
- }
- y += insets.bottom + insets.top;
- }
- else
- {
- y = insets.top + insets.bottom;
- // sum up preferred heights of components, find maximum of
- // preferred widths
- for (Iterator i = children.iterator(); i.hasNext();)
- {
- Component comp = (Component) i.next();
- Dimension sz = comp.getPreferredSize();
- y += sz.height;
- x = Math.max(x, sz.width);
- }
- x += insets.left + insets.right;
+ checkTotalRequirements();
+ Insets i = container.getInsets();
+ return new Dimension(xTotal.preferred + i.left + i.right,
+ yTotal.preferred + i.top + i.bottom);
}
-
- return new Dimension(x, y);
}
/**
@@ -451,41 +210,14 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public Dimension minimumLayoutSize(Container parent)
{
- if (parent != container)
- throw new AWTError("invalid parent");
-
- Insets insets = parent.getInsets();
- int x = insets.left + insets.right;
- int y = insets.bottom + insets.top;
-
- List children = AWTUtilities.getVisibleChildren(parent);
-
- if (isHorizontalIn(parent))
+ synchronized (container.getTreeLock())
{
- // sum up preferred widths of components, find maximum of preferred
- // heights
- for (Iterator i = children.iterator(); i.hasNext();)
- {
- Component comp = (Component) i.next();
- Dimension sz = comp.getMinimumSize();
- x += sz.width;
- y = Math.max(y, sz.height);
- }
- }
- else
- {
- // sum up preferred heights of components, find maximum of
- // preferred widths
- for (Iterator i = children.iterator(); i.hasNext();)
- {
- Component comp = (Component) i.next();
- Dimension sz = comp.getMinimumSize();
- y += sz.height;
- x = Math.max(x, sz.width);
- }
+ if (container != parent)
+ throw new AWTError("BoxLayout can't be shared");
+
+ checkTotalRequirements();
+ return new Dimension(xTotal.minimum, yTotal.minimum);
}
-
- return new Dimension(x, y);
}
/**
@@ -495,12 +227,20 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public void layoutContainer(Container parent)
{
- if (isHorizontalIn(parent))
- layoutAlgorithm(parent, HORIZONTAL, VERTICAL);
- else
- layoutAlgorithm(parent, VERTICAL, HORIZONTAL);
+ synchronized (container.getTreeLock())
+ {
+ if (container != parent)
+ throw new AWTError("BoxLayout can't be shared");
+
+ checkLayout();
+ Component[] children = container.getComponents();
+ Insets in = container.getInsets();
+ for (int i = 0; i < children.length; i++)
+ children[i].setBounds(offsetsX[i] + in.left, offsetsY[i] + in.top,
+ spansX[i], spansY[i]);
+ }
}
-
+
/**
* Adds a component to the layout. Not used in BoxLayout
*
@@ -509,6 +249,7 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public void addLayoutComponent(Component child, Object constraints)
{
+ // Nothing to do here.
}
/**
@@ -520,10 +261,14 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public float getLayoutAlignmentX(Container parent)
{
- if (parent != container)
- throw new AWTError("invalid parent");
-
- return 0;
+ synchronized (container.getTreeLock())
+ {
+ if (container != parent)
+ throw new AWTError("BoxLayout can't be shared");
+
+ checkTotalRequirements();
+ return xTotal.alignment;
+ }
}
/**
@@ -535,10 +280,14 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public float getLayoutAlignmentY(Container parent)
{
- if (parent != container)
- throw new AWTError("invalid parent");
-
- return 0;
+ synchronized (container.getTreeLock())
+ {
+ if (container != parent)
+ throw new AWTError("BoxLayout can't be shared");
+
+ checkTotalRequirements();
+ return yTotal.alignment;
+ }
}
/**
@@ -548,8 +297,17 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public void invalidateLayout(Container parent)
{
- if (parent != container)
- throw new AWTError("invalid parent");
+ synchronized (container.getTreeLock())
+ {
+ xChildren = null;
+ yChildren = null;
+ xTotal = null;
+ yTotal = null;
+ offsetsX = null;
+ offsetsY = null;
+ spansX = null;
+ spansY = null;
+ }
}
/**
@@ -562,188 +320,115 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public Dimension maximumLayoutSize(Container parent)
{
- if (parent != container)
- throw new AWTError("invalid parent");
-
- Insets insets = parent.getInsets();
- int x = insets.left + insets.right;
- int y = insets.top + insets.bottom;
+ synchronized (container.getTreeLock())
+ {
+ if (container != parent)
+ throw new AWTError("BoxLayout can't be shared");
- List children = AWTUtilities.getVisibleChildren(parent);
+ checkTotalRequirements();
+ return new Dimension(xTotal.maximum, yTotal.maximum);
+ }
+ }
- if (isHorizontalIn(parent))
+ /**
+ * Makes sure that the xTotal and yTotal fields are set up correctly. A call
+ * to {@link #invalidateLayout} sets these fields to null and they have to be
+ * recomputed.
+ */
+ private void checkTotalRequirements()
+ {
+ if (xTotal == null || yTotal == null)
{
-
- // sum up preferred widths of components, find maximum of preferred
- // heights
- for (Iterator i = children.iterator(); i.hasNext();)
+ checkRequirements();
+ if (isHorizontalIn(container))
{
- Component comp = (Component) i.next();
- Dimension sz = comp.getMaximumSize();
- x += sz.width;
- // Check for overflow.
- if (x < 0)
- x = Integer.MAX_VALUE;
- y = Math.max(y, sz.height);
+ xTotal = SizeRequirements.getTiledSizeRequirements(xChildren);
+ yTotal = SizeRequirements.getAlignedSizeRequirements(yChildren);
}
- }
- else
- {
- // sum up preferred heights of components, find maximum of
- // preferred widths
- for (Iterator i = children.iterator(); i.hasNext();)
+ else
{
- Component comp = (Component) i.next();
- Dimension sz = comp.getMaximumSize();
- y += sz.height;
- // Check for overflow
- if (y < 0)
- y = Integer.MAX_VALUE;
- x = Math.max(x, sz.width);
+ xTotal = SizeRequirements.getAlignedSizeRequirements(xChildren);
+ yTotal = SizeRequirements.getTiledSizeRequirements(yChildren);
}
- }
- return new Dimension(x, y);
+ }
}
/**
- * Lays out the Container <code>c</code> in the layout direction
- * <code>layoutDir</code>. The direction that is crossing the layout
- * direction is specified in <code>crossDir</code>.
- *
- * @param parent
- * @param layoutDir
- * @param crossDir
+ * Makes sure that the xChildren and yChildren fields are correctly set up.
+ * A call to {@link #invalidateLayout(Container)} sets these fields to null,
+ * so they have to be set up again.
*/
- void layoutAlgorithm(Container parent, Direction layoutDir, Direction crossDir)
+ private void checkRequirements()
{
- if (parent != container)
- throw new AWTError("invalid parent");
-
- Dimension parentSize = parent.getSize();
- Insets insets = parent.getInsets();
- Dimension innerSize = new Dimension(parentSize.width - insets.left
- - insets.right, parentSize.height
- - insets.bottom - insets.top);
-
- // Set all components to their preferredSizes and sum up the allocated
- // space. Create SizeReqs for each component and store them in
- // sizeReqs. Find the maximum size in the crossing direction.
- List children = AWTUtilities.getVisibleChildren(parent);
- Vector sizeReqs = new Vector();
- int allocated = 0;
- for (Iterator i = children.iterator(); i.hasNext();)
- {
- Component c = (Component) i.next();
- SizeReq sizeReq = new SizeReq(c, layoutDir);
- int preferred = layoutDir.size(c.getPreferredSize());
- sizeReq.size = preferred;
- allocated += preferred;
- sizeReqs.add(sizeReq);
- }
-
- // Distribute remaining space (may be positive or negative) over components
- int remainder = layoutDir.size(innerSize) - allocated;
- distributeSpace(sizeReqs, remainder, layoutDir);
-
- // Resize and relocate components. If the component can be sized to
- // take the full space in the crossing direction, then do so, otherwise
- // align according to its alingnmentX or alignmentY property.
- int loc = 0;
- int offset1 = layoutDir.lower(insets);
- int offset2 = crossDir.lower(insets);
- for (Iterator i = sizeReqs.iterator(); i.hasNext();)
+ if (xChildren == null || yChildren == null)
{
- SizeReq sizeReq = (SizeReq) i.next();
- Component c = sizeReq.comp;
- int availCrossSize = crossDir.size(innerSize);
- int maxCross = crossDir.size(c.getMaximumSize());
- int crossSize = Math.min(availCrossSize, maxCross);
- int crossRemainder = availCrossSize - crossSize;
- int crossLoc = (int) (crossDir.alignment(c) * crossRemainder);
- layoutDir.setSize(c, sizeReq.size, crossSize);
- layoutDir.setLocation(c, offset1 + loc, offset2 + crossLoc);
- loc += sizeReq.size;
+ Component[] children = container.getComponents();
+ xChildren = new SizeRequirements[children.length];
+ yChildren = new SizeRequirements[children.length];
+ for (int i = 0; i < children.length; i++)
+ {
+ if (! children[i].isVisible())
+ {
+ xChildren[i] = new SizeRequirements();
+ yChildren[i] = new SizeRequirements();
+ }
+ else
+ {
+ xChildren[i] =
+ new SizeRequirements(children[i].getMinimumSize().width,
+ children[i].getPreferredSize().width,
+ children[i].getMaximumSize().width,
+ children[i].getAlignmentX());
+ yChildren[i] =
+ new SizeRequirements(children[i].getMinimumSize().height,
+ children[i].getPreferredSize().height,
+ children[i].getMaximumSize().height,
+ children[i].getAlignmentY());
+ }
+ }
}
}
/**
- * Distributes some space over a set of components. This implementation
- * tries to set the components as close as possible to their
- * <code>preferredSize</code>s, and respects the components
- * <code>minimumSize</code> and <code>maximumSize</code>.
- *
- * The algorithm is implemented as follows:
- *
- * <ul>
- * <li>The <code>remainder</code> is divided by the number of components
- * in <code>freeComponents</code>.</li>
- * <li>The result is added to (or substracted from) the size of each
- * component.</li>
- * <li>If the <code>minimumSize</code> or <code>maximumSize</code> of a
- * component is exceeded, then this component is set to its
- * <code>minimumSize</code> or <code>maximumSize</code>, it is removed from
- * <code>freeComponents</code> and the difference is added to a new
- * remainder.</li>
- * <li>Finally, if there is a new remainer != 0 and the
- * <code>freeComponents.size() != 0</code>, then this method is called
- * recursivly to distribute the newly allocated remaining space.</li>
- * </ul>
- *
- * @param freeComponents a SizeReq collection for components that have space
- * left so that they can be moved freely
- * @param remainder the space that should be distributed between the
- * components
- * @param dir the direction in which we operate
+ * Makes sure that the offsetsX, offsetsY, spansX and spansY fields are set
+ * up correctly. A call to {@link #invalidateLayout} sets these fields
+ * to null and they have to be recomputed.
*/
- void distributeSpace(Collection freeComponents, int remainder, Direction dir)
+ private void checkLayout()
{
- // Sum up total available space in components. If the remainder is negative
- // then we sum up the difference between minSize and size. If remainder
- // is positive we sum up the difference between maxSize and size.
- double totalAvailable = 0;
- for (Iterator i = freeComponents.iterator(); i.hasNext();)
- {
- SizeReq sizeReq = (SizeReq) i.next();
- if (remainder >= 0)
- totalAvailable += sizeReq.max - sizeReq.size;
- else
- totalAvailable += sizeReq.min - sizeReq.size;
- }
- if (totalAvailable == 0)
- if (remainder >= 0)
- totalAvailable = 1;
- else
- totalAvailable = -1;
-
- int newRemainder = 0;
- Vector stillFree = new Vector();
- for (Iterator i = freeComponents.iterator(); i.hasNext();)
+ if (offsetsX == null || offsetsY == null || spansX == null
+ || spansY == null)
{
- // Add/substract share to component.
- SizeReq sizeReq = (SizeReq) i.next();
- double available = 0;
- if (remainder >= 0)
- available = sizeReq.max - sizeReq.size;
+ checkRequirements();
+ checkTotalRequirements();
+ int len = container.getComponents().length;
+ offsetsX = new int[len];
+ offsetsY = new int[len];
+ spansX = new int[len];
+ spansY = new int[len];
+
+ Insets in = container.getInsets();
+ int width = container.getWidth() - in.left - in.right;
+ int height = container.getHeight() - in.top -in.bottom;
+
+ if (isHorizontalIn(container))
+ {
+ SizeRequirements.calculateTiledPositions(width,
+ xTotal, xChildren,
+ offsetsX, spansX);
+ SizeRequirements.calculateAlignedPositions(height,
+ yTotal, yChildren,
+ offsetsY, spansY);
+ }
else
- available = sizeReq.min - sizeReq.size;
- int share = (int) ((available / totalAvailable) * remainder);
- sizeReq.size += share;
- // check for min/maximumSize
- if (sizeReq.size < sizeReq.min)
- {
- newRemainder += sizeReq.size - sizeReq.min;
- sizeReq.size = sizeReq.min;
- }
- else if (sizeReq.size > sizeReq.max)
- {
- newRemainder += sizeReq.size - sizeReq.max;
- sizeReq.size = sizeReq.max;
- }
- else
- stillFree.add(sizeReq);
+ {
+ SizeRequirements.calculateAlignedPositions(width,
+ xTotal, xChildren,
+ offsetsX, spansX);
+ SizeRequirements.calculateTiledPositions(height,
+ yTotal, yChildren,
+ offsetsY, spansY);
+ }
}
- // recursivly call this method if necessary
- if (newRemainder != 0 && stillFree.size() > 0)
- distributeSpace(stillFree, newRemainder, dir);
}
}
diff --git a/javax/swing/ButtonGroup.java b/javax/swing/ButtonGroup.java
index 3de1d4b9f..94f0109e6 100644
--- a/javax/swing/ButtonGroup.java
+++ b/javax/swing/ButtonGroup.java
@@ -79,6 +79,7 @@ public class ButtonGroup implements Serializable
*/
public ButtonGroup()
{
+ // Nothing to do here.
}
/**
@@ -89,6 +90,8 @@ public class ButtonGroup implements Serializable
public void add(AbstractButton b)
{
b.getModel().setGroup(this);
+ if (b.isSelected())
+ sel = b.getModel();
buttons.addElement(b);
}
@@ -158,7 +161,7 @@ public class ButtonGroup implements Serializable
{
ButtonModel old = sel;
sel = m;
-
+
if (old != null)
old.setSelected(false);
AbstractButton button = FindButton(old);
diff --git a/javax/swing/CellEditor.java b/javax/swing/CellEditor.java
index bdb166575..3d229b266 100644
--- a/javax/swing/CellEditor.java
+++ b/javax/swing/CellEditor.java
@@ -83,7 +83,7 @@ public interface CellEditor
/**
* addCellEditorListener
- * @param value0 TODO
+ * @param listener TODO
*/
void addCellEditorListener(CellEditorListener listener);
diff --git a/javax/swing/CellRendererPane.java b/javax/swing/CellRendererPane.java
index 886d5c5f2..c59afd318 100644
--- a/javax/swing/CellRendererPane.java
+++ b/javax/swing/CellRendererPane.java
@@ -54,9 +54,7 @@ import javax.accessibility.AccessibleRole;
*
* @author Andrew Selkirk
*/
-public class CellRendererPane
- extends Container
- implements Accessible
+public class CellRendererPane extends Container implements Accessible
{
private static final long serialVersionUID = -7642183829532984273L;
@@ -72,6 +70,7 @@ public class CellRendererPane
*/
protected AccessibleCellRendererPane()
{
+ // Nothing to do here.
}
/**
@@ -89,22 +88,13 @@ public class CellRendererPane
*/
protected AccessibleContext accessibleContext = null;
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
/**
* Constructs a new CellRendererPane.
*/
public CellRendererPane()
{
- } // CellRendererPane()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
+ // Nothing to do here.
+ }
/**
* Should not be called.
@@ -113,7 +103,8 @@ public class CellRendererPane
*/
public void update(Graphics graphics)
{
- } // update()
+ //Nothing to do here.
+ }
/**
* Despite normal behaviour this does <em>not</em> cause the container
@@ -121,7 +112,8 @@ public class CellRendererPane
*/
public void invalidate()
{
- } // invalidate()
+ // Overridden to do nothing.
+ }
/**
* Should not be called.
@@ -130,6 +122,7 @@ public class CellRendererPane
*/
public void paint(Graphics graphics)
{
+ // Overridden to do nothing.
}
/**
@@ -147,7 +140,7 @@ public class CellRendererPane
{
super.addImpl(c, constraints, index);
}
- } // addImpl()
+ }
/**
* Paints the specified component <code>c</code> on the {@link Graphics}
@@ -175,9 +168,10 @@ public class CellRendererPane
// reparent c
addImpl(c, null, 0);
+ Rectangle oldClip = graphics.getClipBounds();
// translate to (x,y)
graphics.translate(x, y);
-
+ graphics.clipRect(0, 0, w, h);
// set bounds of c
c.setBounds(0, 0, w, h);
@@ -192,8 +186,8 @@ public class CellRendererPane
// untranslate g
graphics.translate(-x, -y);
-
- } // paintComponent()
+ graphics.setClip(oldClip);
+ }
/**
* Paints the specified component <code>c</code> on the {@link Graphics}
@@ -215,7 +209,7 @@ public class CellRendererPane
Container p, int x, int y, int w, int h)
{
paintComponent(graphics, c, p, x, y, w, h, false);
- } // paintComponent()
+ }
/**
* Paints the specified component <code>c</code> on the {@link Graphics}
@@ -233,7 +227,7 @@ public class CellRendererPane
Container p, Rectangle r)
{
paintComponent(graphics, c, p, r.x, r.y, r.width, r.height);
- } // paintComponent()
+ }
/**
* getAccessibleContext <em>TODO</em>
diff --git a/javax/swing/ComboBoxEditor.java b/javax/swing/ComboBoxEditor.java
index 4eb5fc562..8e914e4b9 100644
--- a/javax/swing/ComboBoxEditor.java
+++ b/javax/swing/ComboBoxEditor.java
@@ -64,7 +64,7 @@ public interface ComboBoxEditor
* combo box list then this method should be called to change editting item
* to the new selected item.
*
- * @param selectedItem item that is currently selected in the combo box
+ * @param item item that is currently selected in the combo box
*/
void setItem(Object item);
diff --git a/javax/swing/DebugGraphics.java b/javax/swing/DebugGraphics.java
index 137b82337..126309a58 100644
--- a/javax/swing/DebugGraphics.java
+++ b/javax/swing/DebugGraphics.java
@@ -42,6 +42,7 @@ import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.image.ImageObserver;
@@ -84,15 +85,16 @@ public class DebugGraphics extends Graphics
static PrintStream debugLogStream = System.out;
/**
- * graphics
+ * Counts the created DebugGraphics objects. This is used by the
+ * logging facility.
*/
- Graphics graphics;
+ static int counter = 0;
/**
- * color
+ * graphics
*/
- Color color = Color.BLACK;
-
+ Graphics graphics;
+
/**
* buffer
*/
@@ -123,7 +125,7 @@ public class DebugGraphics extends Graphics
*/
public DebugGraphics()
{
- // TODO
+ counter++;
}
/**
@@ -134,7 +136,7 @@ public class DebugGraphics extends Graphics
*/
public DebugGraphics(Graphics graphics, JComponent component)
{
- this.graphics = graphics;
+ this(graphics);
// FIXME: What shall we do with component ?
}
@@ -145,6 +147,7 @@ public class DebugGraphics extends Graphics
*/
public DebugGraphics(Graphics graphics)
{
+ this();
this.graphics = graphics;
}
@@ -155,7 +158,10 @@ public class DebugGraphics extends Graphics
*/
public void setColor(Color color)
{
- this.color = color;
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Setting color: " + color);
+
+ graphics.setColor(color);
}
/**
@@ -166,7 +172,9 @@ public class DebugGraphics extends Graphics
*/
public Graphics create()
{
- return new DebugGraphics(graphics.create());
+ DebugGraphics copy = new DebugGraphics(graphics.create());
+ copy.debugOptions = debugOptions;
+ return copy;
}
/**
@@ -182,7 +190,10 @@ public class DebugGraphics extends Graphics
*/
public Graphics create(int x, int y, int width, int height)
{
- return new DebugGraphics(graphics.create(x, y, width, height));
+ DebugGraphics copy = new DebugGraphics(graphics.create(x, y, width,
+ height));
+ copy.debugOptions = debugOptions;
+ return copy;
}
/**
@@ -282,6 +293,9 @@ public class DebugGraphics extends Graphics
*/
public void setFont(Font font)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Setting font: " + font);
+
graphics.setFont(font);
}
@@ -292,7 +306,7 @@ public class DebugGraphics extends Graphics
*/
public Color getColor()
{
- return color;
+ return graphics.getColor();
}
/**
@@ -325,6 +339,9 @@ public class DebugGraphics extends Graphics
*/
public void translate(int x, int y)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Translating by: " + new Point(x, y));
+
graphics.translate(x, y);
}
@@ -333,6 +350,9 @@ public class DebugGraphics extends Graphics
*/
public void setPaintMode()
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Setting paint mode");
+
graphics.setPaintMode();
}
@@ -343,6 +363,9 @@ public class DebugGraphics extends Graphics
*/
public void setXORMode(Color color)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Setting XOR mode: " + color);
+
graphics.setXORMode(color);
}
@@ -366,7 +389,16 @@ public class DebugGraphics extends Graphics
*/
public void clipRect(int x, int y, int width, int height)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().print(prefix() + " Setting clipRect: "
+ + new Rectangle(x, y, width, height));
+ }
+
graphics.clipRect(x, y, width, height);
+
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(" Netting clipRect: " + graphics.getClipBounds());
}
/**
@@ -379,6 +411,12 @@ public class DebugGraphics extends Graphics
*/
public void setClip(int x, int y, int width, int height)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Setting new clipRect: "
+ + new Rectangle(x, y, width, height));
+ }
+
graphics.setClip(x, y, width, height);
}
@@ -399,6 +437,9 @@ public class DebugGraphics extends Graphics
*/
public void setClip(Shape shape)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Setting new clipRect: " + shape);
+
graphics.setClip(shape);
}
@@ -424,18 +465,27 @@ public class DebugGraphics extends Graphics
*/
public void drawRect(int x, int y, int width, int height)
{
- for (int index = 0; index < (debugFlashCount - 1); ++index)
+ if ((debugOptions & LOG_OPTION) != 0)
{
- graphics.setColor(color);
- graphics.drawRect(x, y, width, height);
- sleep(debugFlashTime);
+ logStream().println(prefix() + " Drawing rect: "
+ + new Rectangle(x, y, width, height));
+ }
- graphics.setColor(debugFlashColor);
- graphics.drawRect(x, y, width, height);
- sleep(debugFlashTime);
+ if ((debugOptions & FLASH_OPTION) != 0)
+ {
+ Color color = graphics.getColor();
+ for (int index = 0; index < (debugFlashCount - 1); ++index)
+ {
+ graphics.setColor(color);
+ graphics.drawRect(x, y, width, height);
+ sleep(debugFlashTime);
+ graphics.setColor(debugFlashColor);
+ graphics.drawRect(x, y, width, height);
+ sleep(debugFlashTime);
+ }
+ graphics.setColor(color);
}
- graphics.setColor(color);
graphics.drawRect(x, y, width, height);
}
@@ -449,18 +499,27 @@ public class DebugGraphics extends Graphics
*/
public void fillRect(int x, int y, int width, int height)
{
- for (int index = 0; index < (debugFlashCount - 1); ++index)
+ if ((debugOptions & LOG_OPTION) != 0)
{
- graphics.setColor(color);
- graphics.fillRect(x, y, width, height);
- sleep(debugFlashTime);
+ logStream().println(prefix() + " Filling rect: "
+ + new Rectangle(x, y, width, height));
+ }
- graphics.setColor(debugFlashColor);
- graphics.fillRect(x, y, width, height);
- sleep(debugFlashTime);
+ if ((debugOptions & FLASH_OPTION) != 0)
+ {
+ Color color = graphics.getColor();
+ for (int index = 0; index < (debugFlashCount - 1); ++index)
+ {
+ graphics.setColor(color);
+ graphics.fillRect(x, y, width, height);
+ sleep(debugFlashTime);
+ graphics.setColor(debugFlashColor);
+ graphics.fillRect(x, y, width, height);
+ sleep(debugFlashTime);
+ }
+ graphics.setColor(color);
}
- graphics.setColor(color);
graphics.fillRect(x, y, width, height);
}
@@ -474,6 +533,12 @@ public class DebugGraphics extends Graphics
*/
public void clearRect(int x, int y, int width, int height)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Clearing rect: "
+ + new Rectangle(x, y, width, height));
+ }
+
graphics.clearRect(x, y, width, height);
}
@@ -490,6 +555,14 @@ public class DebugGraphics extends Graphics
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing round rect: "
+ + new Rectangle(x, y, width, height)
+ + " arcWidth: " + arcWidth
+ + " arcHeight: " + arcHeight);
+ }
+
graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
}
@@ -506,6 +579,14 @@ public class DebugGraphics extends Graphics
public void fillRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Filling round rect: "
+ + new Rectangle(x, y, width, height)
+ + " arcWidth: " + arcWidth
+ + " arcHeight: " + arcHeight);
+ }
+
graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
}
@@ -519,6 +600,12 @@ public class DebugGraphics extends Graphics
*/
public void drawLine(int x1, int y1, int x2, int y2)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing line: from (" + x1 + ", "
+ + y1 + ") to (" + x2 + ", " + y2 + ")");
+ }
+
graphics.drawLine(x1, y1, x2, y2);
}
@@ -533,6 +620,13 @@ public class DebugGraphics extends Graphics
*/
public void draw3DRect(int x, int y, int width, int height, boolean raised)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing 3D rect: "
+ + new Rectangle(x, y, width, height)
+ + "Raised bezel: " + raised);
+ }
+
graphics.draw3DRect(x, y, width, height, raised);
}
@@ -547,6 +641,13 @@ public class DebugGraphics extends Graphics
*/
public void fill3DRect(int x, int y, int width, int height, boolean raised)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Filling 3D rect: "
+ + new Rectangle(x, y, width, height)
+ + "Raised bezel: " + raised);
+ }
+
graphics.fill3DRect(x, y, width, height, raised);
}
@@ -560,6 +661,12 @@ public class DebugGraphics extends Graphics
*/
public void drawOval(int x, int y, int width, int height)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing oval: "
+ + new Rectangle(x, y, width, height));
+ }
+
graphics.drawOval(x, y, width, height);
}
@@ -573,6 +680,12 @@ public class DebugGraphics extends Graphics
*/
public void fillOval(int x, int y, int width, int height)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Filling oval: "
+ + new Rectangle(x, y, width, height));
+ }
+
graphics.fillOval(x, y, width, height);
}
@@ -589,6 +702,14 @@ public class DebugGraphics extends Graphics
public void drawArc(int x, int y, int width, int height,
int startAngle, int arcAngle)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing arc: "
+ + new Rectangle(x, y, width, height)
+ + " startAngle: " + startAngle
+ + " arcAngle: " + arcAngle);
+ }
+
graphics.drawArc(x, y, width, height, startAngle, arcAngle);
}
@@ -605,6 +726,14 @@ public class DebugGraphics extends Graphics
public void fillArc(int x, int y, int width, int height,
int startAngle, int arcAngle)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Filling arc: "
+ + new Rectangle(x, y, width, height)
+ + " startAngle: " + startAngle
+ + " arcAngle: " + arcAngle);
+ }
+
graphics.fillArc(x, y, width, height, startAngle, arcAngle);
}
@@ -617,6 +746,12 @@ public class DebugGraphics extends Graphics
*/
public void drawPolyline(int[] xpoints, int[] ypoints, int npoints)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing polyline: nPoints: " + npoints
+ + " X's: " + xpoints + " Y's: " + ypoints);
+ }
+
graphics.drawPolyline(xpoints, ypoints, npoints);
}
@@ -629,6 +764,12 @@ public class DebugGraphics extends Graphics
*/
public void drawPolygon(int[] xpoints, int[] ypoints, int npoints)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing polygon: nPoints: " + npoints
+ + " X's: " + xpoints + " Y's: " + ypoints);
+ }
+
graphics.drawPolygon(xpoints, ypoints, npoints);
}
@@ -641,6 +782,12 @@ public class DebugGraphics extends Graphics
*/
public void fillPolygon(int[] xpoints, int[] ypoints, int npoints)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing polygon: nPoints: " + npoints
+ + " X's: " + xpoints + " Y's: " + ypoints);
+ }
+
graphics.fillPolygon(xpoints, ypoints, npoints);
}
@@ -653,6 +800,12 @@ public class DebugGraphics extends Graphics
*/
public void drawString(String string, int x, int y)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing string: \"" + string
+ + "\" at: " + new Point(x, y));
+ }
+
graphics.drawString(string, x, y);
}
@@ -666,6 +819,12 @@ public class DebugGraphics extends Graphics
public void drawString(AttributedCharacterIterator iterator,
int x, int y)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing string: \"" + iterator
+ + "\" at: " + new Point(x, y));
+ }
+
graphics.drawString(iterator, x, y);
}
@@ -681,6 +840,9 @@ public class DebugGraphics extends Graphics
public void drawBytes(byte[] data, int offset, int length,
int x, int y)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Drawing bytes at: " + new Point(x, y));
+
graphics.drawBytes(data, offset, length, x, y);
}
@@ -696,18 +858,24 @@ public class DebugGraphics extends Graphics
public void drawChars(char[] data, int offset, int length,
int x, int y)
{
- for (int index = 0; index < (debugFlashCount - 1); ++index)
+ if ((debugOptions & LOG_OPTION) != 0)
+ logStream().println(prefix() + " Drawing chars at: " + new Point(x, y));
+
+ if ((debugOptions & FLASH_OPTION) != 0)
{
+ Color color = graphics.getColor();
+ for (int index = 0; index < (debugFlashCount - 1); ++index)
+ {
+ graphics.setColor(color);
+ graphics.drawChars(data, offset, length, x, y);
+ sleep(debugFlashTime);
+ graphics.setColor(debugFlashColor);
+ graphics.drawChars(data, offset, length, x, y);
+ sleep(debugFlashTime);
+ }
graphics.setColor(color);
- graphics.drawChars(data, offset, length, x, y);
- sleep(debugFlashTime);
-
- graphics.setColor(debugFlashColor);
- graphics.drawChars(data, offset, length, x, y);
- sleep(debugFlashTime);
}
- graphics.setColor(color);
graphics.drawChars(data, offset, length, x, y);
}
@@ -723,6 +891,12 @@ public class DebugGraphics extends Graphics
public boolean drawImage(Image image, int x, int y,
ImageObserver observer)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing image: " + image + " at: "
+ + new Point(x, y));
+ }
+
return graphics.drawImage(image, x, y, observer);
}
@@ -741,6 +915,12 @@ public class DebugGraphics extends Graphics
public boolean drawImage(Image image, int x, int y, int width,
int height, ImageObserver observer)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing image: " + image
+ + " at: " + new Rectangle(x, y, width, height));
+ }
+
return graphics.drawImage(image, x, y, width, height, observer);
}
@@ -759,6 +939,13 @@ public class DebugGraphics extends Graphics
public boolean drawImage(Image image, int x, int y,
Color background, ImageObserver observer)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing image: " + image
+ + " at: " + new Point(x, y)
+ + ", bgcolor: " + background);
+ }
+
return graphics.drawImage(image, x, y, background, observer);
}
@@ -779,6 +966,13 @@ public class DebugGraphics extends Graphics
public boolean drawImage(Image image, int x, int y, int width, int height,
Color background, ImageObserver observer)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing image: " + image
+ + " at: " + new Rectangle(x, y, width, height)
+ + ", bgcolor: " + background);
+ }
+
return graphics.drawImage(image, x, y, width, height, background, observer);
}
@@ -802,6 +996,13 @@ public class DebugGraphics extends Graphics
int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
ImageObserver observer)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing image: " + image
+ + " destination: " + new Rectangle(dx1, dy1, dx2, dy2)
+ + " source: " + new Rectangle(sx1, sy1, sx2, sy2));
+ }
+
return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
}
@@ -827,6 +1028,14 @@ public class DebugGraphics extends Graphics
int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
Color background, ImageObserver observer)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Drawing image: " + image
+ + " destination: " + new Rectangle(dx1, dy1, dx2, dy2)
+ + " source: " + new Rectangle(sx1, sy1, sx2, sy2)
+ + ", bgcolor: " + background);
+ }
+
return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, background, observer);
}
@@ -843,6 +1052,13 @@ public class DebugGraphics extends Graphics
public void copyArea(int x, int y, int width, int height,
int destx, int desty)
{
+ if ((debugOptions & LOG_OPTION) != 0)
+ {
+ logStream().println(prefix() + " Copying area from: "
+ + new Rectangle(x, y, width, height)
+ + " to: " + new Point(destx, desty));
+ }
+
graphics.copyArea(x, y, width, height, destx, desty);
}
@@ -873,6 +1089,11 @@ public class DebugGraphics extends Graphics
public void setDebugOptions(int options)
{
debugOptions = options;
+ if ((debugOptions & LOG_OPTION) != 0)
+ if (options == NONE_OPTION)
+ logStream().println(prefix() + "Disabling debug");
+ else
+ logStream().println(prefix() + "Enabling debug");
}
/**
@@ -884,4 +1105,21 @@ public class DebugGraphics extends Graphics
{
return debugOptions;
}
+
+ /**
+ * Creates and returns the prefix that should be prepended to all logging
+ * messages. The prefix is made up like this:
+ *
+ * <code>Graphics(<counter>-1)</code> where counter is an integer number
+ * saying how many DebugGraphics objects have been created so far. The second
+ * number always seem to be 1 on Sun's JDK, this has to be investigated a
+ * little more.
+ *
+ * @return the prefix that should be prepended to all logging
+ * messages
+ */
+ private String prefix()
+ {
+ return "Graphics(" + counter + "-1)";
+ }
}
diff --git a/javax/swing/DefaultButtonModel.java b/javax/swing/DefaultButtonModel.java
index 13a126461..201ee2a8c 100644
--- a/javax/swing/DefaultButtonModel.java
+++ b/javax/swing/DefaultButtonModel.java
@@ -145,6 +145,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public DefaultButtonModel()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/DefaultCellEditor.java b/javax/swing/DefaultCellEditor.java
index 00e008644..39e48551e 100644
--- a/javax/swing/DefaultCellEditor.java
+++ b/javax/swing/DefaultCellEditor.java
@@ -69,7 +69,7 @@ public class DefaultCellEditor
private static final long serialVersionUID = 3564035141373880027L;
/**
- * Delegates a couple of method calls (such as {@link #isCellEditable)
+ * Delegates a couple of method calls (such as {@link #isCellEditable}
* to the component it contains and listens for events that indicate
* that editing has stopped.
*/
@@ -88,12 +88,13 @@ public class DefaultCellEditor
*/
protected EditorDelegate()
{
+ // Nothing to do here.
}
/**
* setValue
*
- * @param event TODO
+ * @param value TODO
*/
public void setValue(Object value)
{
@@ -387,7 +388,7 @@ public class DefaultCellEditor
/**
* getTableCellEditorComponent
*
- * @param tree TODO
+ * @param table TODO
* @param value TODO
* @param isSelected TODO
* @param row TODO
diff --git a/javax/swing/DefaultComboBoxModel.java b/javax/swing/DefaultComboBoxModel.java
index b48b968d6..ea261a33b 100644
--- a/javax/swing/DefaultComboBoxModel.java
+++ b/javax/swing/DefaultComboBoxModel.java
@@ -1,5 +1,5 @@
/* DefaultComboBoxModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,13 +41,14 @@ import java.io.Serializable;
import java.util.Arrays;
import java.util.Vector;
+import javax.swing.event.ListDataEvent;
+
/**
- * The default implementation of {@link MutableComboBoxModel}.
- * This model keeps track
- * of elements contained in the JComboBox as well as the current combo box
- * selection. Whenever selection in the JComboBox changes, the ComboBoxModel
- * will fire ListDataEvents to ComboBox's ListDataListeners.
+ * A model that stores a list of elements and a selected item (which may be
+ * <code>null</code>). Changes to the model are signalled to listeners using
+ * {@link ListDataEvent}. This model is designed for use by the
+ * {@link JComboBox} component.
*
* @author Andrew Selkirk
* @author Olga Rodimina
@@ -59,17 +60,17 @@ public class DefaultComboBoxModel extends AbstractListModel
private static final long serialVersionUID = 6698657703676921904L;
/**
- * List containing items in the combo box
+ * Storage for the elements in the model's list.
*/
private Vector list;
/**
- * Currently selected item in the combo box list
+ * The selected item (<code>null</code> indicates no selection).
*/
private Object selectedItem = null;
/**
- * Constructor DefaultComboBoxModel. Create empty JComboBox.
+ * Creates a new model, initially empty.
*/
public DefaultComboBoxModel()
{
@@ -77,64 +78,92 @@ public class DefaultComboBoxModel extends AbstractListModel
}
/**
- * Constructs new DefaultComboBoxModel object and initializes its item list
- * to values in the given array.
+ * Creates a new model and initializes its item list to the values in the
+ * given array. The selected item is set to the first item in the array, or
+ * <code>null</code> if the array length is zero.
*
- * @param items array containing items of the combo box.
+ * @param items an array containing items for the model (<code>null</code>
+ * not permitted).
+ *
+ * @throws NullPointerException if <code>items</code> is <code>null</code>.
*/
public DefaultComboBoxModel(Object[] items)
{
list = new Vector(Arrays.asList(items));
+ if (list.size() > 0)
+ selectedItem = list.get(0);
}
/**
- * Consturcts new DefaultComboBoxModel object and initializes its item list
- * to values in the given vector.
+ * Creates a new model and initializes its item list to the values in the
+ * given vector. The selected item is set to the first item in the vector,
+ * or <code>null</code> if the vector length is zero.
*
- * @param vector Vector containing items for this combo box.
+ * @param vector a vector containing items for the model (<code>null</code>
+ * not permitted).
+ *
+ * @throws NullPointerException if <code>vector</code> is <code>null</code>.
*/
public DefaultComboBoxModel(Vector vector)
{
this.list = vector;
+ if (vector.size() > 0)
+ selectedItem = vector.get(0);
}
/**
- * This method adds element to the combo box list. It fires ListDataEvent
- * indicating that component was added to the combo box to all of the
- * JComboBox's registered ListDataListeners.
+ * Adds an element to the model's item list and sends a {@link ListDataEvent}
+ * to all registered listeners. If the new element is the first item added
+ * to the list, it is set as the selected item.
*
- * @param object item to add to the combo box list
+ * @param object item to add to the model's item list.
*/
public void addElement(Object object)
{
list.add(object);
- fireIntervalAdded(this, list.size() - 1, list.size());
+ fireIntervalAdded(this, list.size() - 1, list.size() - 1);
+ if (list.size() == 1)
+ setSelectedItem(object);
}
/**
- * This method removes element at the specified index from the combo box
- * list. It fires ListDataEvent indicating that component was removed from
- * the combo box list to all of the JComboBox's registered
- * ListDataListeners.
+ * Removes the element at the specified index from the model's item list
+ * and sends a {@link ListDataEvent} to all registered listeners. If the
+ * element removed was the selected item, then the preceding element becomes
+ * the new selected item (or the next element, if there is no preceding
+ * element).
*
- * @param index index specifying location of the element to remove in the
- * combo box list.
+ * @param index the index of the item to remove.
+ *
+ * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+ * bounds.
*/
public void removeElementAt(int index)
{
+ int selected = getIndexOf(selectedItem);
list.remove(index);
+ if (selected == index) // choose a new selected item
+ {
+ if (selected > 0)
+ selectedItem = getElementAt(selected - 1);
+ else
+ selectedItem = getElementAt(selected);
+ }
fireIntervalRemoved(this, index, index);
}
/**
- * This method inserts given object to the combo box list at the specified
- * index. It fires ListDataEvent indicating that component was inserted to
- * the combo box list to all of the JComboBox's registered
- * ListDataListeners.
+ * Adds an element at the specified index in the model's item list
+ * and sends a {@link ListDataEvent} to all registered listeners.
*
* @param object element to insert
* @param index index specifing position in the list where given element
* should be inserted.
+ *
+ * @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
+ * bounds.
+ *
+ * @see #addElement(Object)
*/
public void insertElementAt(Object object, int index)
{
@@ -143,11 +172,13 @@ public class DefaultComboBoxModel extends AbstractListModel
}
/**
- * Removes given object from the combo box list. It fires ListDataEvent
- * indicating that component was removed from the combo box list to all of
- * the JComboBox's registered ListDataListeners.
+ * Removes an element from the model's item list and sends a
+ * {@link ListDataEvent} to all registered listeners. If the item to be
+ * removed is the current selected item, a new selected item will be set.
+ * If the element is not found in the model's item list, this method does
+ * nothing.
*
- * @param object Element that will be removed from the combo box list
+ * @param object the element to remove.
*/
public void removeElement(Object object)
{
@@ -157,21 +188,25 @@ public class DefaultComboBoxModel extends AbstractListModel
}
/**
- * Removes all the items from the JComboBox's item list. It fires
- * ListDataEvent indicating that all the elements were removed from the
- * combo box list to all of the JComboBox's registered ListDataListeners.
+ * Removes all the items from the model's item list, resets and selected item
+ * to <code>null</code>, and sends a {@link ListDataEvent} to all registered
+ * listeners.
*/
public void removeAllElements()
{
- list.clear();
- int listSize = getSize();
- fireIntervalAdded(this, 0, listSize);
+ selectedItem = null;
+ int size = getSize();
+ if (size > 0)
+ {
+ list.clear();
+ fireIntervalRemoved(this, 0, size - 1);
+ }
}
/**
- * Returns number of items in the combo box list
+ * Returns the number of items in the model's item list.
*
- * @return number of items in the combo box list
+ * @return The number of items in the model's item list.
*/
public int getSize()
{
@@ -179,32 +214,32 @@ public class DefaultComboBoxModel extends AbstractListModel
}
/**
- * Selects given object in the combo box list. This method fires
- * ListDataEvent to all registered ListDataListeners of the JComboBox. The
- * start and end index of the event is set to -1 to indicate combo box's
- * selection has changed, and not its contents.
- *
- * <p>If the given object is not contained in the combo box list then nothing
- * happens.</p>
+ * Sets the selected item for the model and sends a {@link ListDataEvent} to
+ * all registered listeners. The start and end index of the event is set to
+ * -1 to indicate the model's selection has changed, and not its contents.
*
- * @param object item to select in the JComboBox
+ * @param object the new selected item (<code>null</code> permitted).
*/
public void setSelectedItem(Object object)
{
-
- // Updates the selected item only if the given object
- // is null or in the list (this is how the JDK behaves).
- if(object == null || list.contains(object)) {
- selectedItem = object;
- fireContentsChanged(this, -1, -1);
- }
-
+ if (selectedItem == null)
+ {
+ if (object == null)
+ return;
+ }
+ else
+ {
+ if (selectedItem.equals(object))
+ return;
+ }
+ selectedItem = object;
+ fireContentsChanged(this, -1, -1);
}
/**
- * Returns currently selected item in the combo box list
+ * Returns the selected item.
*
- * @return currently selected item in the combo box list
+ * @return The selected item (possibly <code>null</code>).
*/
public Object getSelectedItem()
{
@@ -212,24 +247,27 @@ public class DefaultComboBoxModel extends AbstractListModel
}
/**
- * Returns element in the combo box list located at the given index
+ * Returns the element at the specified index in the model's item list.
*
- * @param index specifying location of the element in the list
+ * @param index the element index.
*
- * @return return element in the combo box list located at the given index
+ * @return The element at the specified index in the model's item list, or
+ * <code>null</code> if the <code>index</code> is outside the bounds
+ * of the list.
*/
public Object getElementAt(int index)
{
+ if (index < 0 || index >= list.size())
+ return null;
return list.elementAt(index);
}
/**
- * Returns index of the specified object in the combo box list.
+ * Returns the index of the specified element in the model's item list.
*
- * @param object element to look for in the combo box list .
+ * @param object the element.
*
- * @return Index specifying position of the specified element in combo box
- * list.
+ * @return The index of the specified element in the model's item list.
*/
public int getIndexOf(Object object)
{
diff --git a/javax/swing/DefaultDesktopManager.java b/javax/swing/DefaultDesktopManager.java
index 2b8977e9d..7f62c9486 100644
--- a/javax/swing/DefaultDesktopManager.java
+++ b/javax/swing/DefaultDesktopManager.java
@@ -91,6 +91,7 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
*/
public DefaultDesktopManager()
{
+ // Nothing to do here.
}
/**
@@ -223,6 +224,7 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
}
catch (PropertyVetoException e)
{
+ // Do nothing if attempt is vetoed.
}
}
@@ -302,6 +304,7 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
}
catch (PropertyVetoException e)
{
+ // Do nothing if attempt is vetoed.
}
}
@@ -329,6 +332,7 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
}
catch (PropertyVetoException e)
{
+ // Do nothing if attempt is vetoed.
}
}
}
diff --git a/javax/swing/DefaultListCellRenderer.java b/javax/swing/DefaultListCellRenderer.java
index 5a34ba7aa..9a8e07071 100644
--- a/javax/swing/DefaultListCellRenderer.java
+++ b/javax/swing/DefaultListCellRenderer.java
@@ -68,6 +68,7 @@ public class DefaultListCellRenderer extends JLabel
{
public UIResource()
{
+ super();
}
}
@@ -124,62 +125,75 @@ public class DefaultListCellRenderer extends JLabel
public void validate()
{
+ // Overridden to do nothing.
}
public void revalidate()
{
+ // Overridden to do nothing.
}
public void repaint(long tm, int x, int y, int w, int h)
{
+ // Overridden to do nothing.
}
public void repaint(Rectangle rect)
{
+ // Overridden to do nothing.
}
protected void firePropertyChange(String propertyName, Object oldValue,
Object newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, byte oldValue,
byte newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, char oldValue,
char newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, short oldValue,
short newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, int oldValue,
int newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, long oldValue,
long newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, float oldValue,
float newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, double oldValue,
double newValue)
{
+ // Overridden to do nothing.
}
public void firePropertyChange(String propertyName, boolean oldValue,
boolean newValue)
{
+ // Overridden to do nothing.
}
}
diff --git a/javax/swing/DefaultListSelectionModel.java b/javax/swing/DefaultListSelectionModel.java
index 7344b0dca..5729e1837 100644
--- a/javax/swing/DefaultListSelectionModel.java
+++ b/javax/swing/DefaultListSelectionModel.java
@@ -238,14 +238,32 @@ public class DefaultListSelectionModel implements Cloneable,
*/
public void setLeadSelectionIndex(int leadIndex)
{
+ // Only set the lead selection index to < 0 if anchorSelectionIndex < 0.
+ if (leadIndex < 0)
+ {
+ if (anchorSelectionIndex < 0)
+ leadSelectionIndex = -1;
+ else
+ return;
+ }
+
+ // Only touch the lead selection index if the anchor is >= 0.
+ if (anchorSelectionIndex < 0)
+ return;
+
+ if (selectionMode == SINGLE_SELECTION)
+ setSelectionInterval (leadIndex, leadIndex);
+
int oldLeadIndex = leadSelectionIndex;
+ if (oldLeadIndex == -1)
+ oldLeadIndex = leadIndex;
if (setLeadCalledFromAdd == false)
oldSel = sel.clone();
leadSelectionIndex = leadIndex;
if (anchorSelectionIndex == -1)
- return;
-
+ return;
+
int R1 = Math.min(anchorSelectionIndex, oldLeadIndex);
int R2 = Math.max(anchorSelectionIndex, oldLeadIndex);
int S1 = Math.min(anchorSelectionIndex, leadIndex);
@@ -254,8 +272,6 @@ public class DefaultListSelectionModel implements Cloneable,
int lo = Math.min(R1, S1);
int hi = Math.max(R2, S2);
- BitSet oldRange = sel.get(lo, hi+1);
-
if (isSelectedIndex(anchorSelectionIndex))
{
sel.clear(R1, R2+1);
@@ -265,10 +281,7 @@ public class DefaultListSelectionModel implements Cloneable,
{
sel.set(R1, R2+1);
sel.clear(S1, S2+1);
- }
-
- BitSet newRange = sel.get(lo, hi+1);
- newRange.xor(oldRange);
+ }
int beg = sel.nextSetBit(0), end = -1;
for(int i=beg; i >= 0; i=sel.nextSetBit(i+1))
@@ -278,6 +291,27 @@ public class DefaultListSelectionModel implements Cloneable,
}
/**
+ * Moves the lead selection index to <code>leadIndex</code> without
+ * changing the selection values.
+ *
+ * If leadAnchorNotificationEnabled is true, send a notification covering the
+ * old and new lead cells.
+ *
+ * @param leadIndex the new lead selection index
+ * @since 1.5
+ */
+ public void moveLeadSelectionIndex (int leadIndex)
+ {
+ if (leadSelectionIndex == leadIndex)
+ return;
+
+ leadSelectionIndex = leadIndex;
+ if (isLeadAnchorNotificationEnabled())
+ fireValueChanged(Math.min(leadSelectionIndex, leadIndex),
+ Math.max(leadSelectionIndex, leadIndex));
+ }
+
+ /**
* Gets the value of the {@link #leadAnchorNotificationEnabled} property.
*
* @return The current property value
@@ -388,6 +422,9 @@ public class DefaultListSelectionModel implements Cloneable,
*/
public boolean isSelectedIndex(int a)
{
+ // TODO: Probably throw an exception here?
+ if (a >= sel.length() || a < 0)
+ return false;
return sel.get(a);
}
@@ -415,7 +452,7 @@ public class DefaultListSelectionModel implements Cloneable,
oldSel = sel.clone();
if (selectionMode == SINGLE_SELECTION)
- sel.clear();
+ setSelectionInterval(index0, index1);
// COMPAT: Like Sun (but not like IBM), we allow calls to
// addSelectionInterval when selectionMode is
@@ -426,10 +463,7 @@ public class DefaultListSelectionModel implements Cloneable,
isSelectedIndex(index1) ||
isSelectedIndex(Math.max(lo-1,0)) ||
isSelectedIndex(Math.min(hi+1,sel.size()))))
- sel.clear();
-
- if (selectionMode == SINGLE_SELECTION)
- index0 = index1;
+ sel.clear();
// We have to update the anchorSelectionIndex and leadSelectionIndex
// variables
diff --git a/javax/swing/DesktopManager.java b/javax/swing/DesktopManager.java
index 300d66517..620c7ffb8 100644
--- a/javax/swing/DesktopManager.java
+++ b/javax/swing/DesktopManager.java
@@ -95,7 +95,7 @@ public interface DesktopManager
* This method should give focus to the JInternalFrame and its default focus
* owner.
*
- * @param frame The JInternalFrame to activate.
+ * @param vframe The JInternalFrame to activate.
*/
void activateFrame(JInternalFrame vframe);
diff --git a/javax/swing/FocusManager.java b/javax/swing/FocusManager.java
index 179fa6f82..a2109ee06 100644
--- a/javax/swing/FocusManager.java
+++ b/javax/swing/FocusManager.java
@@ -38,10 +38,19 @@ exception statement from your version. */
package javax.swing;
+import java.awt.AWTEvent;
import java.awt.Component;
+import java.awt.Container;
import java.awt.DefaultKeyboardFocusManager;
+import java.awt.FocusTraversalPolicy;
+import java.awt.KeyEventDispatcher;
+import java.awt.KeyEventPostProcessor;
import java.awt.KeyboardFocusManager;
+import java.awt.Window;
import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.VetoableChangeListener;
+import java.util.Set;
/**
* This class has been obsoleted by the new
@@ -54,46 +63,409 @@ public abstract class FocusManager
extends DefaultKeyboardFocusManager
{
/**
- * DisabledFocusManager
+ * A FocusManager that wraps an AWT KeyboardFocusManager and forwards all
+ * method calls to it. This is used for compatibility with the new focus
+ * system.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
*/
- static class DisabledFocusManager
+ private static class WrappingFocusManager
extends FocusManager
{
+ /**
+ * The wrapped KeyboardFocusManager.
+ */
+ private KeyboardFocusManager wrapped;
+
+ /**
+ * Creates a new instance of WrappedFocusManager.
+ *
+ * @param fm the focus manager to wrap
+ */
+ WrappingFocusManager(KeyboardFocusManager fm)
+ {
+ wrapped = fm;
+ }
+
+ /**
+ * Wraps {@link DefaultKeyboardFocusManager#dispatchEvent(AWTEvent)}.
+ *
+ * @param ev the event to dispatch
+ *
+ * @return <code>true</code> if the event has been dispatched,
+ * <code>false</code> otherwise
+ */
+ public boolean dispatchEvent(AWTEvent ev)
+ {
+ return wrapped.dispatchEvent(ev);
+ }
+
+ /**
+ * Wraps {@link DefaultKeyboardFocusManager#dispatchKeyEvent(KeyEvent)}.
+ *
+ * @param ev the event to dispatch
+ *
+ * @return <code>true</code> if the event has been dispatched,
+ * <code>false</code> otherwise
+ */
+ public boolean dispatchKeyEvent(KeyEvent ev)
+ {
+ return wrapped.dispatchKeyEvent(ev);
+ }
+
+ /**
+ * Wraps {@link DefaultKeyboardFocusManager#downFocusCycle(Container)}.
+ *
+ * @param c the container
+ */
+ public void downFocusCycle(Container c)
+ {
+ wrapped.downFocusCycle(c);
+ }
+
+ /**
+ * Wraps {@link DefaultKeyboardFocusManager#upFocusCycle(Container)}.
+ *
+ * @param c the container
+ */
+ public void upFocusCycle(Container c)
+ {
+ wrapped.upFocusCycle(c);
+ }
+
+ /**
+ * Wraps {@link DefaultKeyboardFocusManager#focusNextComponent(Component)}.
+ *
+ * @param c the component
+ */
+ public void focusNextComponent(Component c)
+ {
+ wrapped.focusNextComponent(c);
+ }
+
+ /**
+ * Wraps
+ * {@link DefaultKeyboardFocusManager#focusPreviousComponent(Component)}.
+ *
+ * @param c the component
+ */
+ public void focusPreviousComponent(Component c)
+ {
+ wrapped.focusPreviousComponent(c);
+ }
+
+ /**
+ * Wraps {@link DefaultKeyboardFocusManager#postProcessKeyEvent(KeyEvent)}.
+ *
+ * @param e the key event
+ *
+ * @return a boolead
+ */
+ public boolean postProcessKeyEvent(KeyEvent e)
+ {
+ return wrapped.postProcessKeyEvent(e);
+ }
+
+ /**
+ * Wraps
+ * {@link DefaultKeyboardFocusManager#processKeyEvent(Component, KeyEvent)}.
+ *
+ * @param c the component
+ * @param e the key event
+ */
+ public void processKeyEvent(Component c, KeyEvent e)
+ {
+ wrapped.processKeyEvent(c, e);
+ }
+
+ /**
+ * Wraps
+ * {@link KeyboardFocusManager#addKeyEventDispatcher(KeyEventDispatcher)}.
+ *
+ * @param d the dispatcher
+ */
+ public void addKeyEventDispatcher(KeyEventDispatcher d)
+ {
+ wrapped.addKeyEventDispatcher(d);
+ }
+
+ /**
+ * Wraps
+ * {@link KeyboardFocusManager#addKeyEventPostProcessor(KeyEventPostProcessor)}.
+ *
+ * @param p the post processor
+ */
+ public void addKeyEventPostProcessor(KeyEventPostProcessor p)
+ {
+ wrapped.addKeyEventPostProcessor(p);
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#addPropertyChangeListener(PropertyChangeListener)}.
+ *
+ * @param l the property change listener
+ */
+ public void addPropertyChangeListener(PropertyChangeListener l)
+ {
+ wrapped.addPropertyChangeListener(l);
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#addPropertyChangeListener(String, PropertyChangeListener)}.
+ *
+ * @param p the property name
+ * @param l the property change listener
+ */
+ public void addPropertyChangeListener(String p, PropertyChangeListener l)
+ {
+ wrapped.addPropertyChangeListener(p, l);
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#addVetoableChangeListener(String, VetoableChangeListener)}.
+ *
+ * @param p the property name
+ * @param l the vetoable change listener
+ */
+ public void addVetoableChangeListener(String p, VetoableChangeListener l)
+ {
+ wrapped.addVetoableChangeListener(p, l);
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#addVetoableChangeListener(VetoableChangeListener)}.
+ *
+ * @param l the vetoable change listener
+ */
+ public void addVetoableChangeListener(VetoableChangeListener l)
+ {
+ wrapped.addVetoableChangeListener(l);
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#clearGlobalFocusOwner()}.
+ */
+ public void clearGlobalFocusOwner()
+ {
+ wrapped.clearGlobalFocusOwner();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getActiveWindow()}.
+ *
+ * @return the active window
+ */
+ public Window getActiveWindow()
+ {
+ return wrapped.getActiveWindow();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getCurrentFocusCycleRoot()}.
+ *
+ * @return the focus cycle root
+ */
+ public Container getCurrentFocusCycleRoot()
+ {
+ return wrapped.getCurrentFocusCycleRoot();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getDefaultFocusTraversalKeys(int)}.
+ *
+ * @param i the ID
+ *
+ * @return the focus traversal keys
+ */
+ public Set getDefaultFocusTraversalKeys(int i)
+ {
+ return wrapped.getDefaultFocusTraversalKeys(i);
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getDefaultFocusTraversalPolicy()}.
+ *
+ * @return the focus traversal policy
+ */
+ public FocusTraversalPolicy getDefaultFocusTraversalPolicy()
+ {
+ return wrapped.getDefaultFocusTraversalPolicy();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getFocusedWindow()}.
+ *
+ * @return the focused window
+ */
+ public Window getFocusedWindow()
+ {
+ return wrapped.getFocusedWindow();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getFocusOwner()}.
+ *
+ * @return the focus owner
+ */
+ public Component getFocusOwner()
+ {
+ return wrapped.getFocusOwner();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getPermanentFocusOwner()}.
+ *
+ * @return the focus owner
+ */
+ public Component getPermanentFocusOwner()
+ {
+ return wrapped.getPermanentFocusOwner();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getPropertyChangeListeners()}.
+ *
+ * @return the property change listeners
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners()
+ {
+ return wrapped.getPropertyChangeListeners();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getPropertyChangeListeners(String)}.
+ *
+ * @param n the property name
+ *
+ * @return the property change listeners
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners(String n)
+ {
+ return wrapped.getPropertyChangeListeners(n);
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getVetoableChangeListeners()}.
+ *
+ * @return the vetoable change listeners
+ */
+ public VetoableChangeListener[] getVetoableChangeListeners()
+ {
+ return wrapped.getVetoableChangeListeners();
+ }
+
+ /**
+ * Wraps {@link KeyboardFocusManager#getVetoableChangeListeners(String)}.
+ *
+ * @param n the property name
+ *
+ * @return the vetoable change listeners
+ */
+ public VetoableChangeListener[] getVetoableChangeListeners(String n)
+ {
+ return wrapped.getVetoableChangeListeners(n);
+ }
+
+
+ /**
+ * Wraps
+ * {@link KeyboardFocusManager#removeKeyEventDispatcher(KeyEventDispatcher)}.
+ *
+ * @param d the key event dispatcher to remove
+ */
+ public void removeKeyEventDispatcher(KeyEventDispatcher d)
+ {
+ wrapped.removeKeyEventDispatcher(d);
+ }
+
+ /**
+ * Wraps
+ * {@link KeyboardFocusManager#removeKeyEventPostProcessor(KeyEventPostProcessor)}.
+ *
+ * @param p the post processor
+ */
+ public void removeKeyEventPostProcessor(KeyEventPostProcessor p)
+ {
+ wrapped.removeKeyEventPostProcessor(p);
+ }
+
+ /**
+ * Wraps
+ * {@link KeyboardFocusManager#removePropertyChangeListener(PropertyChangeListener)}.
+ *
+ * @param l the listener
+ */
+ public void removePropertyChangeListener(PropertyChangeListener l)
+ {
+ wrapped.removePropertyChangeListener(l);
+ }
+
+ /**
+ * Wraps
+ * {@link KeyboardFocusManager#removePropertyChangeListener(String, PropertyChangeListener)}.
+ *
+ * @param n the property name
+ * @param l the listener
+ */
+ public void removePropertyChangeListener(String n, PropertyChangeListener l)
+ {
+ wrapped.removePropertyChangeListener(n, l);
+ }
+
+ /**
+ * Wraps
+ * {@link KeyboardFocusManager#removeVetoableChangeListener(VetoableChangeListener)}.
+ *
+ * @param l the listener
+ */
+ public void removeVetoableChangeListener(VetoableChangeListener l)
+ {
+ wrapped.removeVetoableChangeListener(l);
+ }
/**
- * Constructor DisabledFocusManager
+ * Wraps
+ * {@link KeyboardFocusManager#removeVetoableChangeListener(String, VetoableChangeListener)}.
+ *
+ * @param n the property name
+ * @param l the listener
*/
- DisabledFocusManager()
+ public void removeVetoableChangeListener(String n, VetoableChangeListener l)
{
- // TODO
+ wrapped.removeVetoableChangeListener(n, l);
}
/**
- * processKeyEvent
- * @param component TODO
- * @param event TODO
+ * Wraps
+ * {@link KeyboardFocusManager#setDefaultFocusTraversalKeys(int, Set)}.
+ *
+ * @param id the ID
+ * @param k the keystrokes
*/
- public void processKeyEvent(Component component, KeyEvent event)
+ public void setDefaultFocusTraversalKeys(int id, Set k)
{
- // TODO
+ wrapped.setDefaultFocusTraversalKeys(id, k);
}
/**
- * focusNextComponent
- * @param component TODO
+ * Wraps {@link KeyboardFocusManager#setDefaultFocusTraversalPolicy(FocusTraversalPolicy)}.
+ *
+ * @param p the focus traversal policy
*/
- public void focusNextComponent(Component component)
+ public void setDefaultFocusTraversalPolicy(FocusTraversalPolicy p)
{
- // TODO
+ wrapped.setDefaultFocusTraversalPolicy(p);
}
/**
- * focusPreviousComponent
- * @param value0 TODO
+ * Wraps
+ * {@link KeyboardFocusManager#setGlobalCurrentFocusCycleRoot(Container)}.
+ *
+ * @param r the focus cycle root
*/
- public void focusPreviousComponent(Component value0)
+ public void setGlobalCurrentFocusCycleRoot(Container r)
{
- // TODO
+ wrapped.setGlobalCurrentFocusCycleRoot(r);
}
}
@@ -117,20 +489,9 @@ public abstract class FocusManager
*/
public static FocusManager getCurrentManager()
{
- KeyboardFocusManager fm =
- KeyboardFocusManager.getCurrentKeyboardFocusManager();
- if (fm instanceof FocusManager)
- return (FocusManager) fm;
- else
- {
- System.err.println("The Swing FocusManager API has been obsoleted by");
- System.err.println("the new KeyboardFocusManager system.");
- System.err.println("You should either not use the Swing FocusManager");
- System.err.println("API or set the system property");
- System.err.println
- ("gnu.java.awt.FocusManager=javax.swing.FocusManager");
- }
- return null;
+ KeyboardFocusManager m =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ return new WrappingFocusManager(m);
}
/**
diff --git a/javax/swing/ImageIcon.java b/javax/swing/ImageIcon.java
index b650cd81f..b6ed949d8 100644
--- a/javax/swing/ImageIcon.java
+++ b/javax/swing/ImageIcon.java
@@ -73,6 +73,7 @@ public class ImageIcon
*/
protected AccessibleImageIcon()
{
+ // Nothing to do here.
}
/**
@@ -204,7 +205,10 @@ public class ImageIcon
private static final long serialVersionUID = 532615968316031794L;
/** A dummy Component that is used in the MediaTracker. */
- protected static Component component = new Component(){};
+ protected static Component component = new Component()
+ {
+ // No need to implement this.
+ };
/** The MediaTracker used to monitor the loading of images. */
protected static MediaTracker tracker = new MediaTracker(component);
@@ -227,6 +231,7 @@ public class ImageIcon
*/
public ImageIcon()
{
+ // Nothing to do here.
}
/**
@@ -417,7 +422,7 @@ public class ImageIcon
}
catch (InterruptedException ex)
{
- ; // ignore this for now
+ // Ignore this for now.
}
finally
{
diff --git a/javax/swing/InputVerifier.java b/javax/swing/InputVerifier.java
index 8e02ab813..eeb81b5d5 100644
--- a/javax/swing/InputVerifier.java
+++ b/javax/swing/InputVerifier.java
@@ -53,6 +53,7 @@ public abstract class InputVerifier
*/
public InputVerifier()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JApplet.java b/javax/swing/JApplet.java
index aa3fcf4e2..22bbe92bf 100644
--- a/javax/swing/JApplet.java
+++ b/javax/swing/JApplet.java
@@ -73,6 +73,11 @@ public class JApplet extends Applet
}
}
+ /**
+ * The accessible context for this <code>JApplet</code>.
+ */
+ protected AccessibleContext accessibleContext;
+
private static final long serialVersionUID = 7269359214497372587L;
protected JRootPane rootPane;
@@ -89,11 +94,6 @@ public class JApplet extends Applet
*/
private boolean initStageDone = false;
- /**
- * The accessible context for this <code>JApplet</code>.
- */
- AccessibleContext accessibleContext;
-
public JApplet()
{
super.setLayout(new BorderLayout(1, 1));
diff --git a/javax/swing/JButton.java b/javax/swing/JButton.java
index 5653fbf42..ff0ecfccf 100644
--- a/javax/swing/JButton.java
+++ b/javax/swing/JButton.java
@@ -75,9 +75,6 @@ public class JButton extends AbstractButton
boolean def;
boolean is_def;
- /** The AccessibleContext for this JButton. */
- AccessibleJButton accessibleContext;
-
public JButton()
{
this(null, null);
@@ -166,6 +163,10 @@ public class JButton extends AbstractButton
*/
public void removeNotify()
{
+ JRootPane root = SwingUtilities.getRootPane(this);
+ if (root != null && root.getDefaultButton() == this)
+ root.setDefaultButton(null);
+ super.removeNotify();
}
public void setDefaultCapable(boolean defaultCapable)
diff --git a/javax/swing/JCheckBox.java b/javax/swing/JCheckBox.java
index f493782b2..74fda8f6d 100644
--- a/javax/swing/JCheckBox.java
+++ b/javax/swing/JCheckBox.java
@@ -97,50 +97,44 @@ public class JCheckBox extends JToggleButton implements Accessible
public JCheckBox()
{
- super();
- init();
+ this(null, null, false);
}
public JCheckBox(Action action)
{
super(action);
- init();
}
public JCheckBox(Icon icon)
{
- super(icon);
- init();
+ this(null, icon, false);
}
public JCheckBox(Icon icon, boolean selected)
{
- super(icon, selected);
- init();
+ this(null, icon, selected);
}
public JCheckBox(String text)
{
- super(text);
- init();
+ this(text, null, false);
}
public JCheckBox(String text, boolean selected)
{
- super(text, selected);
- init();
+ this(text, null, selected);
}
public JCheckBox(String text, Icon icon)
{
- super(text, icon);
- init();
+ this(text, icon, false);
}
public JCheckBox(String text, Icon icon, boolean selected)
{
super(text, icon, selected);
- init();
+ setHorizontalAlignment(LEADING);
+ setBorderPainted(false);
}
/**
diff --git a/javax/swing/JCheckBoxMenuItem.java b/javax/swing/JCheckBoxMenuItem.java
index f9dd56500..815244259 100644
--- a/javax/swing/JCheckBoxMenuItem.java
+++ b/javax/swing/JCheckBoxMenuItem.java
@@ -38,9 +38,6 @@ exception statement from your version. */
package javax.swing;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@@ -48,8 +45,9 @@ import javax.accessibility.AccessibleRole;
/**
* A menu item that displays a checkbox. Its behaviour is very similar
* to {@link JCheckBox}. Just like the <code>JCheckBox</code>, user can check
- * and uncheck this menu item by clicking on it. Also {@link #setSelected()}
- * and {@link #setState()} can be use used for the same purpose.
+ * and uncheck this menu item by clicking on it. Also
+ * {@link AbstractButton#setSelected} and {@link #setState} can be use used
+ * for the same purpose.
* <code>JCheckBoxMenuItem</code> uses
* <code>ToggleButtonModel</code> to keep track of its selection.
*
@@ -152,10 +150,6 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
this.setVisible(true);
}
- private void writeObject(ObjectOutputStream stream) throws IOException
- {
- }
-
/**
* This method returns a name to identify which look and feel class will be
* the UI delegate for the menuItem.
@@ -248,6 +242,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
*/
protected AccessibleJCheckBoxMenuItem()
{
+ // Nothing to do here.
}
public AccessibleRole getAccessibleRole()
diff --git a/javax/swing/JColorChooser.java b/javax/swing/JColorChooser.java
index 4016b82f3..a9650ffb7 100644
--- a/javax/swing/JColorChooser.java
+++ b/javax/swing/JColorChooser.java
@@ -87,6 +87,7 @@ public class JColorChooser extends JComponent implements Accessible
*/
protected AccessibleJColorChooser()
{
+ // Nothing to do here.
}
/**
@@ -247,6 +248,7 @@ public class JColorChooser extends JComponent implements Accessible
}
catch (InterruptedException e)
{
+ // TODO: Should this be handled?
}
}
diff --git a/javax/swing/JComboBox.java b/javax/swing/JComboBox.java
index 07e149e7e..cd30840a6 100644
--- a/javax/swing/JComboBox.java
+++ b/javax/swing/JComboBox.java
@@ -46,8 +46,6 @@ import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
import java.util.Vector;
import javax.accessibility.Accessible;
@@ -58,6 +56,7 @@ import javax.accessibility.AccessibleSelection;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import javax.swing.event.PopupMenuListener;
+import javax.swing.event.PopupMenuEvent;
import javax.swing.plaf.ComboBoxUI;
/**
@@ -212,10 +211,6 @@ public class JComboBox extends JComponent implements ItemSelectable,
this(new DefaultComboBoxModel());
}
- private void writeObject(ObjectOutputStream stream) throws IOException
- {
- }
-
/**
* This method returns true JComboBox is editable and false otherwise
*
@@ -310,7 +305,8 @@ public class JComboBox extends JComponent implements ItemSelectable,
// Stores old data model for event notification.
ComboBoxModel oldDataModel = dataModel;
dataModel = newDataModel;
-
+ selectedItemReminder = newDataModel.getSelectedItem();
+
// Notifies the listeners of the model change.
firePropertyChange("model", oldDataModel, dataModel);
}
@@ -843,6 +839,47 @@ public class JComboBox extends JComponent implements ItemSelectable,
}
/**
+ * Fires a popupMenuCanceled() event to all <code>PopupMenuListeners</code>.
+ *
+ * Note: This method is intended for use by plaf classes only.
+ */
+ public void firePopupMenuCanceled()
+ {
+ PopupMenuListener[] listeners = getPopupMenuListeners();
+ PopupMenuEvent e = new PopupMenuEvent(this);
+ for(int i = 0; i < listeners.length; i++)
+ listeners[i].popupMenuCanceled(e);
+ }
+
+ /**
+ * Fires a popupMenuWillBecomeInvisible() event to all
+ * <code>PopupMenuListeners</code>.
+ *
+ * Note: This method is intended for use by plaf classes only.
+ */
+ public void firePopupMenuWillBecomeInvisible()
+ {
+ PopupMenuListener[] listeners = getPopupMenuListeners();
+ PopupMenuEvent e = new PopupMenuEvent(this);
+ for(int i = 0; i < listeners.length; i++)
+ listeners[i].popupMenuWillBecomeInvisible(e);
+ }
+
+ /**
+ * Fires a popupMenuWillBecomeVisible() event to all
+ * <code>PopupMenuListeners</code>.
+ *
+ * Note: This method is intended for use by plaf classes only.
+ */
+ public void firePopupMenuWillBecomeVisible()
+ {
+ PopupMenuListener[] listeners = getPopupMenuListeners();
+ PopupMenuEvent e = new PopupMenuEvent(this);
+ for(int i = 0; i < listeners.length; i++)
+ listeners[i].popupMenuWillBecomeVisible(e);
+ }
+
+ /**
* This method is invoked whenever selected item changes in the combo box's
* data model. It fires ItemEvent and ActionEvent to all registered
* ComboBox's ItemListeners and ActionListeners respectively, indicating
@@ -859,8 +896,9 @@ public class JComboBox extends JComponent implements ItemSelectable,
// Fire ItemEvent to indicate that new item is selected
Object newSelection = getSelectedItem();
- fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
- newSelection, ItemEvent.SELECTED));
+ if (newSelection != null)
+ fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
+ newSelection, ItemEvent.SELECTED));
// Fire Action Event to JComboBox's registered listeners
fireActionEvent();
@@ -984,19 +1022,19 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void processKeyEvent(KeyEvent e)
{
- }
-
- /**
- * This method always returns false to indicate that JComboBox itself is
- * not focus traversable.
- *
- * @return false to indicate that JComboBox itself is not focus traversable.
- *
- * @deprecated
- */
- public boolean isFocusTraversable()
- {
- return false;
+ if (e.getKeyCode() == KeyEvent.VK_TAB)
+ setPopupVisible(false);
+ else if (keySelectionManager != null)
+ {
+ int i = keySelectionManager.selectionForKey(e.getKeyChar(),
+ getModel());
+ if (i >= 0)
+ setSelectedIndex(i);
+ else
+ super.processKeyEvent(e);
+ }
+ else
+ super.processKeyEvent(e);
}
/**
@@ -1006,6 +1044,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void setKeySelectionManager(KeySelectionManager aManager)
{
+ keySelectionManager = aManager;
}
/**
@@ -1170,6 +1209,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
protected AccessibleJComboBox()
{
+ // Nothing to do here.
}
public int getAccessibleChildrenCount()
@@ -1229,18 +1269,22 @@ public class JComboBox extends JComponent implements ItemSelectable,
public void addAccessibleSelection(int value0)
{
+ // TODO: Implement this properly.
}
public void removeAccessibleSelection(int value0)
{
+ // TODO: Implement this properly.
}
public void clearAccessibleSelection()
{
+ // TODO: Implement this properly.
}
public void selectAllAccessibleSelection()
{
+ // TODO: Implement this properly.
}
}
}
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index b13f2d14c..80cfc5b32 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -44,6 +44,7 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.FocusTraversalPolicy;
import java.awt.Font;
@@ -53,6 +54,7 @@ import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.Shape;
import java.awt.Window;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
@@ -64,7 +66,6 @@ import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
-import java.awt.image.ImageObserver;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -121,9 +122,18 @@ public abstract class JComponent extends Container implements Serializable
protected class AccessibleFocusHandler
implements FocusListener
{
- protected AccessibleFocusHandler(){}
- public void focusGained(FocusEvent event){}
- public void focusLost(FocusEvent valevent){}
+ protected AccessibleFocusHandler()
+ {
+ // TODO: Implement this properly.
+ }
+ public void focusGained(FocusEvent event)
+ {
+ // TODO: Implement this properly.
+ }
+ public void focusLost(FocusEvent valevent)
+ {
+ // TODO: Implement this properly.
+ }
}
/**
@@ -132,9 +142,18 @@ public abstract class JComponent extends Container implements Serializable
protected class AccessibleContainerHandler
implements ContainerListener
{
- protected AccessibleContainerHandler() {}
- public void componentAdded(ContainerEvent event) {}
- public void componentRemoved(ContainerEvent valevent) {}
+ protected AccessibleContainerHandler()
+ {
+ // TODO: Implement this properly.
+ }
+ public void componentAdded(ContainerEvent event)
+ {
+ // TODO: Implement this properly.
+ }
+ public void componentRemoved(ContainerEvent valevent)
+ {
+ // TODO: Implement this properly.
+ }
}
private static final long serialVersionUID = -7047089700479897799L;
@@ -142,12 +161,41 @@ public abstract class JComponent extends Container implements Serializable
protected ContainerListener accessibleContainerHandler;
protected FocusListener accessibleFocusHandler;
- protected AccessibleJComponent() {}
- public void addPropertyChangeListener(PropertyChangeListener listener) {}
- public void removePropertyChangeListener(PropertyChangeListener listener) {}
+ protected AccessibleJComponent()
+ {
+ // TODO: Implement this properly.
+ }
+
+ /**
+ * Adds a property change listener to the list of registered listeners.
+ *
+ * @param listener the listener to add
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener)
+ {
+ // TODO: Why is this overridden?
+ super.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener)
+ {
+ // TODO: Implement this properly.
+ }
public int getAccessibleChildrenCount() { return 0; }
public Accessible getAccessibleChild(int value0) { return null; }
- public AccessibleStateSet getAccessibleStateSet() { return null; }
+
+ /**
+ * Returns the accessible state set of this component.
+ *
+ * @return the accessible state set of this component
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ // FIXME: Figure out which states should be set here, and which are
+ // inherited from the super class.
+ return super.getAccessibleStateSet();
+ }
+
public String getAccessibleName() { return null; }
public String getAccessibleDescription() { return null; }
public AccessibleRole getAccessibleRole() { return null; }
@@ -160,21 +208,21 @@ public abstract class JComponent extends Container implements Serializable
/**
* An explicit value for the component's preferred size; if not set by a
* user, this is calculated on the fly by delegating to the {@link
- * ComponentUI.getPreferredSize} method on the {@link #ui} property.
+ * ComponentUI#getPreferredSize} method on the {@link #ui} property.
*/
Dimension preferredSize;
/**
* An explicit value for the component's minimum size; if not set by a
* user, this is calculated on the fly by delegating to the {@link
- * ComponentUI.getMinimumSize} method on the {@link #ui} property.
+ * ComponentUI#getMinimumSize} method on the {@link #ui} property.
*/
Dimension minimumSize;
/**
* An explicit value for the component's maximum size; if not set by a
* user, this is calculated on the fly by delegating to the {@link
- * ComponentUI.getMaximumSize} method on the {@link #ui} property.
+ * ComponentUI#getMaximumSize} method on the {@link #ui} property.
*/
Dimension maximumSize;
@@ -219,14 +267,14 @@ public abstract class JComponent extends Container implements Serializable
* The text to show in the tooltip associated with this component.
*
* @see #setToolTipText
- * @see #getToolTipText
+ * @see #getToolTipText()
*/
String toolTipText;
/**
* <p>Whether to double buffer this component when painting. This flag
- * should generally be <code>false</code>, except for top level
- * components such as {@link JFrame} or {@link JApplet}.</p>
+ * should generally be <code>true</code>, to ensure good painting
+ * performance.</p>
*
* <p>All children of a double buffered component are painted into the
* double buffer automatically, so only the top widget in a window needs
@@ -234,22 +282,21 @@ public abstract class JComponent extends Container implements Serializable
*
* @see #setDoubleBuffered
* @see #isDoubleBuffered
- * @see #paintLock
* @see #paint
*/
- boolean doubleBuffered = false;
+ boolean doubleBuffered = true;
/**
* A set of flags indicating which debugging graphics facilities should
* be enabled on this component. The values should be a combination of
- * {@link DebugGraphics.NONE_OPTION}, {@link DebugGraphics.LOG_OPTION},
- * {@link DebugGraphics.FLASH_OPTION}, or {@link
- * DebugGraphics.BUFFERED_OPTION}.
+ * {@link DebugGraphics#NONE_OPTION}, {@link DebugGraphics#LOG_OPTION},
+ * {@link DebugGraphics#FLASH_OPTION}, or {@link
+ * DebugGraphics#BUFFERED_OPTION}.
*
- * @see setDebugGraphicsOptions
- * @see getDebugGraphicsOptions
+ * @see #setDebugGraphicsOptions
+ * @see #getDebugGraphicsOptions
* @see DebugGraphics
- * @see getComponentGraphics
+ * @see #getComponentGraphics
*/
int debugGraphicsOptions;
@@ -299,7 +346,7 @@ public abstract class JComponent extends Container implements Serializable
* try to request focus, but the request might fail. Thus it is only
* a hint guiding swing's behavior.
*
- * @see #requestFocus
+ * @see #requestFocus()
* @see #isRequestFocusEnabled
* @see #setRequestFocusEnabled
*/
@@ -312,12 +359,18 @@ public abstract class JComponent extends Container implements Serializable
* timed intervals, continuing off in the direction the mouse exited the
* component, until the mouse is released or re-enters the component.
*
- * @see setAutoscrolls
- * @see getAutoscrolls
+ * @see #setAutoscrolls
+ * @see #getAutoscrolls
*/
boolean autoscrolls = false;
/**
+ * Indicates whether the current paint call is already double buffered or
+ * not.
+ */
+ static boolean isPaintingDoubleBuffered = false;
+
+ /**
* Listeners for events other than {@link PropertyChangeEvent} are
* handled by this listener list. PropertyChangeEvents are handled in
* {@link #changeSupport}.
@@ -350,16 +403,12 @@ public abstract class JComponent extends Container implements Serializable
private TransferHandler transferHandler;
- /**
- * A lock held during recursive painting; this is used to serialize
- * access to the double buffer, and also to select the "top level"
- * object which should acquire the double buffer in a given widget
- * tree (which may have multiple double buffered children).
- *
- * @see #doubleBuffered
- * @see #paint
+ /**
+ * A cached Rectangle object to be reused. Be careful when you use that,
+ * so that it doesn't get modified in another context within the same
+ * method call chain.
*/
- private static final Object paintLock = new Object();
+ private static transient Rectangle rectCache;
/**
* The default locale of the component.
@@ -404,6 +453,13 @@ public abstract class JComponent extends Container implements Serializable
public static final int WHEN_IN_FOCUSED_WINDOW = 2;
/**
+ * Indicates if this component is completely dirty or not. This is used
+ * by the RepaintManager's
+ * {@link RepaintManager#isCompletelyDirty(JComponent)} method.
+ */
+ boolean isCompletelyDirty = false;
+
+ /**
* Creates a new <code>JComponent</code> instance.
*/
public JComponent()
@@ -837,9 +893,13 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setBorder(Border newBorder)
{
- Border oldBorder = border;
+ Border oldBorder = getBorder();
+ if (oldBorder == newBorder)
+ return;
+
border = newBorder;
firePropertyChange("border", oldBorder, newBorder);
+ repaint();
}
/**
@@ -890,10 +950,19 @@ public abstract class JComponent extends Container implements Serializable
* @see #paint
*/
protected Graphics getComponentGraphics(Graphics g)
- {
- g.setFont (this.getFont());
- g.setColor (this.getForeground());
- return g;
+ {
+ Graphics g2 = g;
+ int options = getDebugGraphicsOptions();
+ if (options != DebugGraphics.NONE_OPTION)
+ {
+ if (!(g2 instanceof DebugGraphics))
+ g2 = new DebugGraphics(g);
+ DebugGraphics dg = (DebugGraphics) g2;
+ dg.setDebugOptions(dg.getDebugOptions() | options);
+ }
+ g2.setFont(this.getFont());
+ g2.setColor(this.getForeground());
+ return g2;
}
/**
@@ -906,7 +975,19 @@ public abstract class JComponent extends Container implements Serializable
*/
public int getDebugGraphicsOptions()
{
- return 0;
+ String option = System.getProperty("gnu.javax.swing.DebugGraphics");
+ int options = debugGraphicsOptions;
+ if (option != null && option.length() != 0)
+ {
+ if (options < 0)
+ options = 0;
+
+ if (option.equals("LOG"))
+ options |= DebugGraphics.LOG_OPTION;
+ else if (option.equals("FLASH"))
+ options |= DebugGraphics.FLASH_OPTION;
+ }
+ return options;
}
/**
@@ -1303,6 +1384,7 @@ public abstract class JComponent extends Container implements Serializable
*/
public void grabFocus()
{
+ // TODO: Implement this properly.
}
/**
@@ -1411,16 +1493,6 @@ public abstract class JComponent extends Container implements Serializable
* RepaintManager}. Client code should usually call {@link #repaint()} to
* trigger painting.</p>
*
- * <p>This method will acquire a double buffer from the {@link
- * RepaintManager} if the component's {@link #doubleBuffered} property is
- * <code>true</code> and the <code>paint</code> call is the
- * <em>first</em> recursive <code>paint</code> call inside swing.</p>
- *
- * <p>The method will also modify the provided {@link Graphics} context
- * via the {@link #getComponentGraphics} method. If you want to customize
- * the graphics object used for painting, you should override that method
- * rather than <code>paint</code>.</p>
- *
* <p>The body of the <code>paint</code> call involves calling {@link
* #paintComponent}, {@link #paintBorder}, and {@link #paintChildren} in
* order. If you want to customize painting behavior, you should override
@@ -1436,32 +1508,29 @@ public abstract class JComponent extends Container implements Serializable
*/
public void paint(Graphics g)
{
- Graphics g2 = g;
- Image doubleBuffer = null;
RepaintManager rm = RepaintManager.currentManager(this);
-
- if (isDoubleBuffered()
- && (rm.isDoubleBufferingEnabled())
- && (! Thread.holdsLock(paintLock)))
- {
- doubleBuffer = rm.getOffscreenBuffer(this, getWidth(), getHeight());
- }
-
- synchronized (paintLock)
+ // We do a little stunt act here to switch on double buffering if it's
+ // not already on. If we are not already doublebuffered, then we jump
+ // into the method paintDoubleBuffered, which turns on the double buffer
+ // and then calls paint(g) again. In the second call we go into the else
+ // branch of this if statement and actually paint things to the double
+ // buffer. When this method completes, the call stack unwinds back to
+ // paintDoubleBuffered, where the buffer contents is finally drawn to the
+ // screen.
+ if (!isPaintingDoubleBuffered && isDoubleBuffered()
+ && rm.isDoubleBufferingEnabled())
+ paintDoubleBuffered(g);
+ else
{
- if (doubleBuffer != null)
- {
- g2 = doubleBuffer.getGraphics();
- g2.setClip(g.getClipBounds());
- }
-
- g2 = getComponentGraphics(g2);
- paintComponent(g2);
- paintBorder(g2);
- paintChildren(g2);
-
- if (doubleBuffer != null)
- g.drawImage(doubleBuffer, 0, 0, (ImageObserver) null);
+ if (g.getClip() == null)
+ g.setClip(0, 0, getWidth(), getHeight());
+ paintComponent(g);
+ paintBorder(g);
+ paintChildren(g);
+ Rectangle clip = g.getClipBounds();
+ if (clip.x == 0 && clip.y == 0 && clip.width == getWidth()
+ && clip.height == getHeight())
+ RepaintManager.currentManager(this).markCompletelyClean(this);
}
}
@@ -1500,7 +1569,39 @@ public abstract class JComponent extends Container implements Serializable
*/
protected void paintChildren(Graphics g)
{
- super.paint(g);
+ Shape originalClip = g.getClip();
+ Rectangle inner = SwingUtilities.calculateInnerArea(this, rectCache);
+ g.clipRect(inner.x, inner.y, inner.width, inner.height);
+ Component[] children = getComponents();
+ for (int i = children.length - 1; i >= 0; --i)
+ {
+ if (!children[i].isVisible())
+ continue;
+
+ Rectangle bounds = children[i].getBounds(rectCache);
+ Rectangle oldClip = g.getClipBounds();
+ if (oldClip == null)
+ oldClip = bounds;
+
+ if (!g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height))
+ continue;
+
+ boolean translated = false;
+ try
+ {
+ g.clipRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ g.translate(bounds.x, bounds.y);
+ translated = true;
+ children[i].paint(g);
+ }
+ finally
+ {
+ if (translated)
+ g.translate(-bounds.x, -bounds.y);
+ g.setClip(oldClip);
+ }
+ }
+ g.setClip(originalClip);
}
/**
@@ -1549,24 +1650,93 @@ public abstract class JComponent extends Container implements Serializable
* that root pane. This method is called from the {@link RepaintManager}
* and should always be called within the painting thread.
*
+ * <p>This method will acquire a double buffer from the {@link
+ * RepaintManager} if the component's {@link #doubleBuffered} property is
+ * <code>true</code> and the <code>paint</code> call is the
+ * <em>first</em> recursive <code>paint</code> call inside swing.</p>
+ *
+ * <p>The method will also modify the provided {@link Graphics} context
+ * via the {@link #getComponentGraphics} method. If you want to customize
+ * the graphics object used for painting, you should override that method
+ * rather than <code>paint</code>.</p>
+ *
* @param r The dirty rectangle to paint
*/
public void paintImmediately(Rectangle r)
{
- Component root = SwingUtilities.getRoot(this);
- if (root == null || ! root.isShowing())
+ // Try to find a root pane for this component.
+ //Component root = findPaintRoot(r);
+ Component root = findPaintRoot(r);
+ // If no paint root is found, then this component is completely overlapped
+ // by another component and we don't need repainting.
+ if (root == null)
return;
- Graphics g = root.getGraphics();
- if (g == null)
+ if (root == null || !root.isShowing())
return;
- Rectangle clip = SwingUtilities.convertRectangle(this, r, root);
- g.setClip(clip);
- root.paint(g);
+ Rectangle rootClip = SwingUtilities.convertRectangle(this, r, root);
+ if (root instanceof JComponent)
+ ((JComponent) root).paintImmediately2(rootClip);
+ else
+ root.repaint(rootClip.x, rootClip.y, rootClip.width, rootClip.height);
+ }
+
+ /**
+ * Performs the actual work of paintImmediatly on the repaint root.
+ *
+ * @param r the area to be repainted
+ */
+ void paintImmediately2(Rectangle r)
+ {
+ RepaintManager rm = RepaintManager.currentManager(this);
+ Graphics g = getGraphics();
+ g.setClip(r.x, r.y, r.width, r.height);
+ if (rm.isDoubleBufferingEnabled() && isDoubleBuffered())
+ paintDoubleBuffered(g);
+ else
+ paintSimple(g);
g.dispose();
}
/**
+ * Performs double buffered repainting.
+ *
+ * @param g the graphics context to paint to
+ */
+ void paintDoubleBuffered(Graphics g)
+ {
+
+ Rectangle r = g.getClipBounds();
+ if (r == null)
+ r = new Rectangle(0, 0, getWidth(), getHeight());
+ RepaintManager rm = RepaintManager.currentManager(this);
+
+ // Paint on the offscreen buffer.
+ Image buffer = rm.getOffscreenBuffer(this, getWidth(), getHeight());
+ Graphics g2 = buffer.getGraphics();
+ g2 = getComponentGraphics(g2);
+ g2.setClip(r.x, r.y, r.width, r.height);
+ isPaintingDoubleBuffered = true;
+ paint(g2);
+ isPaintingDoubleBuffered = false;
+ g2.dispose();
+
+ // Paint the buffer contents on screen.
+ g.drawImage(buffer, 0, 0, this);
+ }
+
+ /**
+ * Performs normal painting without double buffering.
+ *
+ * @param g the graphics context to use
+ */
+ void paintSimple(Graphics g)
+ {
+ Graphics g2 = getComponentGraphics(g);
+ paint(g2);
+ }
+
+ /**
* Return a string representation for this component, for use in
* debugging.
*
@@ -1802,6 +1972,7 @@ public abstract class JComponent extends Container implements Serializable
*/
protected void processComponentKeyEvent(KeyEvent e)
{
+ // This method does nothing, it is meant to be overridden by subclasses.
}
/**
@@ -1980,8 +2151,19 @@ public abstract class JComponent extends Container implements Serializable
*/
public void revalidate()
{
- invalidate();
- RepaintManager.currentManager(this).addInvalidComponent(this);
+ if (! EventQueue.isDispatchThread())
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ revalidate();
+ }
+ });
+ else
+ {
+ invalidate();
+ RepaintManager.currentManager(this).addInvalidComponent(this);
+ }
}
/**
@@ -2054,9 +2236,11 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setEnabled(boolean enable)
{
- boolean oldEnabled = isEnabled();
+ if (enable == isEnabled())
+ return;
super.setEnabled(enable);
- firePropertyChange("enabled", oldEnabled, enable);
+ firePropertyChange("enabled", !enable, enable);
+ repaint();
}
/**
@@ -2066,7 +2250,11 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setFont(Font f)
{
+ if (f == getFont())
+ return;
super.setFont(f);
+ revalidate();
+ repaint();
}
/**
@@ -2076,7 +2264,10 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setBackground(Color bg)
{
+ if (bg == getBackground())
+ return;
super.setBackground(bg);
+ repaint();
}
/**
@@ -2086,7 +2277,10 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setForeground(Color fg)
{
+ if (fg == getForeground())
+ return;
super.setForeground(fg);
+ repaint();
}
/**
@@ -2136,6 +2330,7 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setNextFocusableComponent(Component aComponent)
{
+ // TODO: Implement this properly.
}
/**
@@ -2196,11 +2391,29 @@ public abstract class JComponent extends Container implements Serializable
/**
* Set the value of the visible property.
*
+ * If the value is changed, then the AncestorListeners of this component
+ * and all its children (recursivly) are notified.
+ *
* @param v The new value of the property
*/
public void setVisible(boolean v)
{
+ // No need to do anything if the actual value doesn't change.
+ if (isVisible() == v)
+ return;
+
super.setVisible(v);
+
+ // Notify AncestorListeners.
+ if (v == true)
+ fireAncestorEvent(this, AncestorEvent.ANCESTOR_ADDED);
+ else
+ fireAncestorEvent(this, AncestorEvent.ANCESTOR_REMOVED);
+
+ Container parent = getParent();
+ if (parent != null)
+ parent.repaint(getX(), getY(), getWidth(), getHeight());
+ revalidate();
}
/**
@@ -2253,7 +2466,8 @@ public abstract class JComponent extends Container implements Serializable
ui.installUI(this);
firePropertyChange("UI", oldUI, newUI);
-
+ revalidate();
+ repaint();
}
/**
@@ -2461,15 +2675,9 @@ public abstract class JComponent extends Container implements Serializable
parent = jParent.getParent();
}
-
- // notify ancestor listeners
- AncestorListener[] ls = getAncestorListeners();
- AncestorEvent ev = new AncestorEvent(this, AncestorEvent.ANCESTOR_ADDED,
- this, parent);
- for (int i = 0; i < ls.length; i++)
- {
- ls[i].ancestorAdded(ev);
- }
+
+ // Notify AncestorListeners.
+ fireAncestorEvent(this, AncestorEvent.ANCESTOR_ADDED);
// fire property change event for 'ancestor'
firePropertyChange("ancestor", null, parent);
@@ -2521,14 +2729,8 @@ public abstract class JComponent extends Container implements Serializable
parent = jParent.getParent();
}
- // notify ancestor listeners
- AncestorListener[] ls = getAncestorListeners();
- AncestorEvent ev = new AncestorEvent(this, AncestorEvent.ANCESTOR_ADDED,
- this, parent);
- for (int i = 0; i < ls.length; i++)
- {
- ls[i].ancestorAdded(ev);
- }
+ // Notify ancestor listeners.
+ fireAncestorEvent(this, AncestorEvent.ANCESTOR_REMOVED);
// fire property change event for 'ancestor'
firePropertyChange("ancestor", parent, null);
@@ -2738,6 +2940,184 @@ public abstract class JComponent extends Container implements Serializable
*/
public void reshape(int x, int y, int w, int h)
{
+ int oldX = getX();
+ int oldY = getY();
super.reshape(x, y, w, h);
+ // Notify AncestorListeners.
+ if (oldX != getX() || oldY != getY())
+ fireAncestorEvent(this, AncestorEvent.ANCESTOR_MOVED);
+ }
+
+ /**
+ * Fires an AncestorEvent to this component's and all of its child
+ * component's AncestorListeners.
+ *
+ * @param ancestor the component that triggered the event
+ * @param id the kind of ancestor event that should be fired
+ */
+ void fireAncestorEvent(JComponent ancestor, int id)
+ {
+ // Fire event for registered ancestor listeners of this component.
+ AncestorListener[] listeners = getAncestorListeners();
+ if (listeners.length > 0)
+ {
+ AncestorEvent ev = new AncestorEvent(this, id,
+ ancestor, ancestor.getParent());
+ for (int i = 0; i < listeners.length; i++)
+ {
+ switch (id)
+ {
+ case AncestorEvent.ANCESTOR_MOVED:
+ listeners[i].ancestorMoved(ev);
+ break;
+ case AncestorEvent.ANCESTOR_ADDED:
+ listeners[i].ancestorAdded(ev);
+ break;
+ case AncestorEvent.ANCESTOR_REMOVED:
+ listeners[i].ancestorRemoved(ev);
+ break;
+ }
+ }
+ }
+ // Dispatch event to all children.
+ Component[] children = getComponents();
+ for (int i = 0; i < children.length; i++)
+ {
+ if (!(children[i] instanceof JComponent))
+ continue;
+ JComponent jc = (JComponent) children[i];
+ jc.fireAncestorEvent(ancestor, id);
+ }
+ }
+
+ /**
+ * Finds a suitable paint root for painting this component. This method first
+ * checks if this component is overlapped using
+ * {@link #findOverlapFreeParent(Rectangle)}. The returned paint root is then
+ * feeded to {@link #findOpaqueParent(Component)} to find the nearest opaque
+ * component for this paint root. If no paint is necessary, then we return
+ * <code>null</code>.
+ *
+ * @param c the clip of this component
+ *
+ * @return the paint root or <code>null</code> if no painting is necessary
+ */
+ private Component findPaintRoot(Rectangle c)
+ {
+ Component p = findOverlapFreeParent(c);
+ if (p == null)
+ return null;
+ Component root = findOpaqueParent(p);
+ return root;
+ }
+
+ /**
+ * Scans the containment hierarchy upwards for components that overlap the
+ * this component in the specified clip. This method returns
+ * <code>this</code>, if no component overlaps this component. It returns
+ * <code>null</code> if another component completely covers this component
+ * in the specified clip (no repaint necessary). If another component partly
+ * overlaps this component in the specified clip, then the parent of this
+ * component is returned (this is the component that must be used as repaint
+ * root). For efficient lookup, the method
+ * {@link #isOptimizedDrawingEnabled()} is used.
+ *
+ * @param clip the clip of this component
+ *
+ * @return the paint root, or <code>null</code> if no paint is necessary
+ */
+ private Component findOverlapFreeParent(Rectangle clip)
+ {
+ Rectangle currentClip = clip;
+ Component found = this;
+ Container parent = this;
+ while (parent != null)
+ {
+ Container newParent = parent.getParent();
+ if (newParent == null)
+ break;
+ // If the parent is optimizedDrawingEnabled, then its children are
+ // tiled and cannot have an overlapping child. Go directly to next
+ // parent.
+ if (newParent instanceof JComponent
+ && ((JComponent) newParent).isOptimizedDrawingEnabled())
+ {
+ parent = newParent;
+ continue;
+ }
+
+ // First we must check if the new parent itself somehow clips the
+ // target rectangle. This can happen in JViewports.
+ Rectangle parRect = new Rectangle(0, 0, newParent.getWidth(),
+ newParent.getHeight());
+ Rectangle target = SwingUtilities.convertRectangle(found,
+ currentClip,
+ newParent);
+ if (target.contains(parRect) || target.intersects(parRect))
+ {
+ found = newParent;
+ currentClip = target;
+ parent = newParent;
+ continue;
+ }
+
+ // Otherwise we must check if one of the children of this parent
+ // overlaps with the current component.
+ Component[] children = newParent.getComponents();
+ // This flag is used to skip components that are 'below' the component
+ // in question.
+ boolean skip = true;
+ for (int i = children.length - 1; i >= 0; i--)
+ {
+ if (children[i] == parent)
+ skip = false;
+ if (skip)
+ continue;
+ Component c = children[i];
+ Rectangle compBounds = c.getBounds();
+ // If the component completely overlaps the clip in question, we
+ // don't need to repaint. Return null.
+ if (compBounds.contains(target))
+ return null;
+ if (compBounds.intersects(target))
+ {
+ // We found a parent whose children overlap with our current
+ // component. Make this the current component.
+ found = newParent;
+ currentClip = target;
+ break;
+ }
+ }
+ parent = newParent;
+ }
+ return found;
+ }
+
+ /**
+ * Finds the nearest component to <code>c</code> (upwards in the containment
+ * hierarchy), that is opaque. If <code>c</code> itself is opaque,
+ * this returns <code>c</code> itself.
+ *
+ * @param c the start component for the search
+ * @return the nearest component to <code>c</code> (upwards in the containment
+ * hierarchy), that is opaque; If <code>c</code> itself is opaque,
+ * this returns <code>c</code> itself
+ */
+ private Component findOpaqueParent(Component c)
+ {
+ Component found = c;
+ while (true)
+ {
+ if ((found instanceof JComponent) && ((JComponent) found).isOpaque())
+ break;
+ else if (!(found instanceof JComponent))
+ break;
+ Container p = found.getParent();
+ if (p == null)
+ break;
+ else
+ found = p;
+ }
+ return found;
}
}
diff --git a/javax/swing/JDesktopPane.java b/javax/swing/JDesktopPane.java
index f4c80eca7..43ab71e7e 100644
--- a/javax/swing/JDesktopPane.java
+++ b/javax/swing/JDesktopPane.java
@@ -97,6 +97,7 @@ public class JDesktopPane extends JLayeredPane implements Accessible
*/
protected AccessibleJDesktopPane()
{
+ // Nothing to do here.
}
/**
@@ -246,6 +247,7 @@ public class JDesktopPane extends JLayeredPane implements Accessible
}
catch (PropertyVetoException e)
{
+ // We do nothing when the attempt is vetoed.
}
}
selectedFrame = null;
@@ -259,6 +261,7 @@ public class JDesktopPane extends JLayeredPane implements Accessible
}
catch (PropertyVetoException e)
{
+ // We do nothing when the attempt is vetoed.
}
}
diff --git a/javax/swing/JEditorPane.java b/javax/swing/JEditorPane.java
index e2f1319a2..9ddf970de 100644
--- a/javax/swing/JEditorPane.java
+++ b/javax/swing/JEditorPane.java
@@ -41,15 +41,27 @@ package javax.swing;
import java.awt.Dimension;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.MalformedURLException;
import java.net.URL;
import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleHyperlink;
+import javax.accessibility.AccessibleHypertext;
+import javax.accessibility.AccessibleStateSet;
+import javax.accessibility.AccessibleText;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultEditorKit;
+import javax.swing.text.Document;
import javax.swing.text.EditorKit;
+import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLEditorKit;
/**
* A powerful text editor component that can handle different types of
@@ -76,6 +88,384 @@ import javax.swing.text.JTextComponent;
*/
public class JEditorPane extends JTextComponent
{
+ /**
+ * Provides accessibility support for <code>JEditorPane</code>.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class AccessibleJEditorPane extends AccessibleJTextComponent
+ {
+
+ /**
+ * Creates a new <code>AccessibleJEditorPane</code> object.
+ */
+ protected AccessibleJEditorPane()
+ {
+ super();
+ }
+
+ /**
+ * Returns a description of this <code>AccessibleJEditorPane</code>. If
+ * this property is not set, then this returns the content-type of the
+ * editor pane.
+ *
+ * @return a description of this AccessibleJEditorPane
+ */
+ public String getAccessibleDescription()
+ {
+ String descr = super.getAccessibleDescription();
+ if (descr == null)
+ return getContentType();
+ else
+ return descr;
+ }
+
+ /**
+ * Returns the accessible state of this <code>AccessibleJEditorPane</code>.
+ *
+ * @return the accessible state of this <code>AccessibleJEditorPane</code>
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet state = super.getAccessibleStateSet();
+ // TODO: Figure out what state must be added here to the super's state.
+ return state;
+ }
+ }
+
+ /**
+ * Provides accessibility support for <code>JEditorPane</code>s, when the
+ * editor kit is an instance of {@link HTMLEditorKit}.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class AccessibleJEditorPaneHTML extends AccessibleJEditorPane
+ {
+ /**
+ * Returns the accessible text of the <code>JEditorPane</code>. This will
+ * be an instance of
+ * {@link JEditorPaneAccessibleHypertextSupport}.
+ *
+ * @return the accessible text of the <code>JEditorPane</code>
+ */
+ public AccessibleText getAccessibleText()
+ {
+ return new JEditorPaneAccessibleHypertextSupport();
+ }
+ }
+
+ /**
+ * This is the accessible text that is returned by
+ * {@link AccessibleJEditorPaneHTML#getAccessibleText()}.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class JEditorPaneAccessibleHypertextSupport
+ extends AccessibleJEditorPane implements AccessibleHypertext
+ {
+
+ /**
+ * The accessible representation of a HTML link.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ public class HTMLLink extends AccessibleHyperlink
+ {
+
+ /**
+ * The element in the document that represents the link.
+ */
+ Element element;
+
+ /**
+ * Creates a new <code>HTMLLink</code>.
+ *
+ * @param el the link element
+ */
+ public HTMLLink(Element el)
+ {
+ this.element = el;
+ }
+
+ /**
+ * Returns <code>true</code> if this <code>HTMLLink</code> is still
+ * valid. A <code>HTMLLink</code> can become invalid when the document
+ * changes.
+ *
+ * @return <code>true</code> if this <code>HTMLLink</code> is still
+ * valid
+ */
+ public boolean isValid()
+ {
+ // I test here if the element at our element's start offset is the
+ // same as the element in the document at this offset. If this is true,
+ // I consider the link valid, if not, then this link no longer
+ // represented by this HTMLLink and therefor invalid.
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ return doc.getCharacterElement(element.getStartOffset()) == element;
+ }
+
+ /**
+ * Returns the number of AccessibleActions in this link object. In
+ * general, link have 1 AccessibleAction associated with them. There are
+ * special cases where links can have multiple actions associated, like
+ * in image maps.
+ *
+ * @return the number of AccessibleActions in this link object
+ */
+ public int getAccessibleActionCount()
+ {
+ // TODO: Implement the special cases.
+ return 1;
+ }
+
+ /**
+ * Performs the specified action on the link object. This ususally means
+ * activating the link.
+ *
+ * @return <code>true</code> if the action has been performed
+ * successfully, <code>false</code> otherwise
+ */
+ public boolean doAccessibleAction(int i)
+ {
+ String href = (String) element.getAttributes().getAttribute("href");
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ try
+ {
+ URL url = new URL(doc.getBase(), href);
+ setPage(url);
+ String desc = doc.getText(element.getStartOffset(),
+ element.getEndOffset() - element.getStartOffset());
+ HyperlinkEvent ev =
+ new HyperlinkEvent(JEditorPane.this,
+ HyperlinkEvent.EventType.ACTIVATED, url, desc,
+ element);
+ fireHyperlinkUpdate(ev);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the description of the action at action index <code>i</code>.
+ * This method returns the text within the element associated with this
+ * link.
+ *
+ * @param i the action index
+ *
+ * @return the description of the action at action index <code>i</code>
+ */
+ public String getAccessibleActionDescription(int i)
+ {
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ try
+ {
+ return doc.getText(element.getStartOffset(),
+ element.getEndOffset() - element.getStartOffset());
+ }
+ catch (BadLocationException ex)
+ {
+ throw (AssertionError)
+ new AssertionError("BadLocationException must not be thrown "
+ + "here.")
+ .initCause(ex);
+ }
+ }
+
+ /**
+ * Returns an {@link URL} object, that represents the action at action
+ * index <code>i</code>.
+ *
+ * @param i the action index
+ *
+ * @return an {@link URL} object, that represents the action at action
+ * index <code>i</code>
+ */
+ public Object getAccessibleActionObject(int i)
+ {
+ String href = (String) element.getAttributes().getAttribute("href");
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ try
+ {
+ URL url = new URL(doc.getBase(), href);
+ return url;
+ }
+ catch (MalformedURLException ex)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns an object that represents the link anchor. For examples, if
+ * the link encloses a string, then a <code>String</code> object is
+ * returned, if the link encloses an &lt;img&gt; tag, then an
+ * <code>ImageIcon</code> object is returned.
+ *
+ * @return an object that represents the link anchor
+ */
+ public Object getAccessibleActionAnchor(int i)
+ {
+ // TODO: This is only the String case. Implement all cases.
+ return getAccessibleActionDescription(i);
+ }
+
+ /**
+ * Returns the start index of the hyperlink element.
+ *
+ * @return the start index of the hyperlink element
+ */
+ public int getStartIndex()
+ {
+ return element.getStartOffset();
+ }
+
+ /**
+ * Returns the end index of the hyperlink element.
+ *
+ * @return the end index of the hyperlink element
+ */
+ public int getEndIndex()
+ {
+ return element.getEndOffset();
+ }
+
+ }
+
+ /**
+ * Returns the number of hyperlinks in the document.
+ *
+ * @return the number of hyperlinks in the document
+ */
+ public int getLinkCount()
+ {
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ HTMLDocument.Iterator linkIter = doc.getIterator(HTML.Tag.A);
+ int count = 0;
+ while (linkIter.isValid())
+ {
+ count++;
+ linkIter.next();
+ }
+ return count;
+ }
+
+ /**
+ * Returns the <code>i</code>-th hyperlink in the document or
+ * <code>null</code> if there is no hyperlink with the specified index.
+ *
+ * @param i the index of the hyperlink to return
+ *
+ * @return the <code>i</code>-th hyperlink in the document or
+ * <code>null</code> if there is no hyperlink with the specified
+ * index
+ */
+ public AccessibleHyperlink getLink(int i)
+ {
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ HTMLDocument.Iterator linkIter = doc.getIterator(HTML.Tag.A);
+ int count = 0;
+ while (linkIter.isValid())
+ {
+ count++;
+ if (count == i)
+ break;
+ linkIter.next();
+ }
+ if (linkIter.isValid())
+ {
+ int offset = linkIter.getStartOffset();
+ // TODO: I fetch the element for the link via getCharacterElement().
+ // I am not sure that this is correct, maybe we must use
+ // getParagraphElement()?
+ Element el = doc.getCharacterElement(offset);
+ HTMLLink link = new HTMLLink(el);
+ return link;
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Returns the index of the link element at the character position
+ * <code>c</code> within the document, or <code>-1</code> if there is no
+ * link at the specified position.
+ *
+ * @param c the character index from which to fetch the link index
+ *
+ * @return the index of the link element at the character position
+ * <code>c</code> within the document, or <code>-1</code> if there
+ * is no link at the specified position
+ */
+ public int getLinkIndex(int c)
+ {
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ HTMLDocument.Iterator linkIter = doc.getIterator(HTML.Tag.A);
+ int count = 0;
+ while (linkIter.isValid())
+ {
+ if (linkIter.getStartOffset() <= c && linkIter.getEndOffset() > c)
+ break;
+ count++;
+ linkIter.next();
+ }
+ if (linkIter.isValid())
+ return count;
+ else
+ return -1;
+ }
+
+ /**
+ * Returns the link text of the link at index <code>i</code>, or
+ * <code>null</code>, if there is no link at the specified position.
+ *
+ * @param i the index of the link
+ *
+ * @return the link text of the link at index <code>i</code>, or
+ * <code>null</code>, if there is no link at the specified
+ * position
+ */
+ public String getLinkText(int i)
+ {
+ HTMLDocument doc = (HTMLDocument) getDocument();
+ HTMLDocument.Iterator linkIter = doc.getIterator(HTML.Tag.A);
+ int count = 0;
+ while (linkIter.isValid())
+ {
+ count++;
+ if (count == i)
+ break;
+ linkIter.next();
+ }
+ if (linkIter.isValid())
+ {
+ int offset = linkIter.getStartOffset();
+ // TODO: I fetch the element for the link via getCharacterElement().
+ // I am not sure that this is correct, maybe we must use
+ // getParagraphElement()?
+ Element el = doc.getCharacterElement(offset);
+ try
+ {
+ String text = doc.getText(el.getStartOffset(),
+ el.getEndOffset() - el.getStartOffset());
+ return text;
+ }
+ catch (BadLocationException ex)
+ {
+ throw (AssertionError)
+ new AssertionError("BadLocationException must not be thrown "
+ + "here.")
+ .initCause(ex);
+ }
+ }
+ else
+ return null;
+ }
+ }
+
private static final long serialVersionUID = 3140472492599046285L;
private URL page;
@@ -128,9 +518,21 @@ public class JEditorPane extends JTextComponent
listeners[index].hyperlinkUpdate(event);
}
+ /**
+ * Returns the accessible context associated with this editor pane.
+ *
+ * @return the accessible context associated with this editor pane
+ */
public AccessibleContext getAccessibleContext()
{
- return null;
+ if (accessibleContext == null)
+ {
+ if (getEditorKit() instanceof HTMLEditorKit)
+ accessibleContext = new AccessibleJEditorPaneHTML();
+ else
+ accessibleContext = new AccessibleJEditorPane();
+ }
+ return accessibleContext;
}
public final String getContentType()
@@ -169,12 +571,18 @@ public class JEditorPane extends JTextComponent
public boolean getScrollableTracksViewportHeight()
{
- return false;
+ /* Container parent = getParent();
+ return (parent instanceof JViewport &&
+ parent.isValid());*/
+ return isValid();
}
public boolean getScrollableTracksViewportWidth()
{
- return false;
+ /*Container parent = getParent();
+ return (parent instanceof JViewport &&
+ parent.isValid());*/
+ return isValid();
}
public URL getPage()
@@ -211,9 +619,26 @@ public class JEditorPane extends JTextComponent
/**
* This method initializes from a stream.
*/
- public void read(InputStream in, Object desc)
- throws IOException
+ public void read(InputStream in, Object desc) throws IOException
{
+ EditorKit kit = getEditorKit();
+ if (kit instanceof HTMLEditorKit && desc instanceof HTMLDocument)
+ {
+ Document doc = (Document) desc;
+ try
+ {
+ kit.read(in, doc, 0);
+ }
+ catch (BadLocationException ex)
+ {
+ assert false : "BadLocationException must not be thrown here.";
+ }
+ }
+ else
+ {
+ Reader inRead = new InputStreamReader(in);
+ super.read(inRead, desc);
+ }
}
/**
@@ -222,6 +647,7 @@ public class JEditorPane extends JTextComponent
public static void registerEditorKitForContentType(String type,
String classname)
{
+ // TODO: Implement this properly.
}
/**
@@ -231,6 +657,7 @@ public class JEditorPane extends JTextComponent
String classname,
ClassLoader loader)
{
+ // TODO: Implement this properly.
}
/**
@@ -239,6 +666,7 @@ public class JEditorPane extends JTextComponent
*/
public void replaceSelection(String content)
{
+ // TODO: Implement this properly.
}
/**
@@ -247,6 +675,7 @@ public class JEditorPane extends JTextComponent
*/
public void scrollToReference(String reference)
{
+ // TODO: Implement this properly.
}
public final void setContentType(String type)
@@ -281,6 +710,8 @@ public class JEditorPane extends JTextComponent
firePropertyChange("editorKit", oldValue, newValue);
invalidate();
repaint();
+ // Reset the accessibleContext since this depends on the editorKit.
+ accessibleContext = null;
}
public void setEditorKitForContentType(String type, EditorKit k)
diff --git a/javax/swing/JFileChooser.java b/javax/swing/JFileChooser.java
index 0eb832848..1598641f1 100644
--- a/javax/swing/JFileChooser.java
+++ b/javax/swing/JFileChooser.java
@@ -42,10 +42,13 @@ import java.awt.Frame;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
import java.io.File;
import java.util.ArrayList;
+
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
import javax.swing.JDialog;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileSystemView;
@@ -70,171 +73,324 @@ public class JFileChooser extends JComponent implements Accessible
{
private static final long serialVersionUID = 3162921138695327837L;
- /** DOCUMENT ME! */
+ /**
+ * A dialog type for selecting a file to open.
+ * @see #setDialogType(int)
+ */
public static final int OPEN_DIALOG = 0;
- /** DOCUMENT ME! */
+ /**
+ * A dialog type for selecting a file to save.
+ * @see #setDialogType(int)
+ */
public static final int SAVE_DIALOG = 1;
- /** DOCUMENT ME! */
+ /**
+ * A dialog type for some custom purpose.
+ * @see #setDialogType(int)
+ */
public static final int CUSTOM_DIALOG = 2;
- /** DOCUMENT ME! */
+ /**
+ * A return value indicating the file chooser has been closed by cancelling.
+ *
+ * @see #showOpenDialog(Component)
+ * @see #showSaveDialog(Component)
+ */
public static final int CANCEL_OPTION = 1;
- /** DOCUMENT ME! */
+ /**
+ * A return value indicating the file chooser has been closed by approving
+ * the selection.
+ * @see #showOpenDialog(Component)
+ * @see #showSaveDialog(Component)
+ */
public static final int APPROVE_OPTION = 0;
- /** DOCUMENT ME! */
+ /**
+ * A return value indicating the file chooser has been closed by some error.
+ * @see #showOpenDialog(Component)
+ * @see #showSaveDialog(Component)
+ */
public static final int ERROR_OPTION = -1;
- /** DOCUMENT ME! */
+ /**
+ * A selection mode constant indicating acceptance of files only.
+ * @see #setFileSelectionMode(int)
+ */
public static final int FILES_ONLY = 0;
- /** DOCUMENT ME! */
+ /**
+ * A selection mode constant indicating acceptance of directories only.
+ * @see #setFileSelectionMode(int)
+ */
public static final int DIRECTORIES_ONLY = 1;
- /** DOCUMENT ME! */
+ /**
+ * A selection mode constant indicating acceptance of files and directories.
+ * @see #setFileSelectionMode(int)
+ */
public static final int FILES_AND_DIRECTORIES = 2;
- /** DOCUMENT ME! */
+ /**
+ * Action command string for cancelling the current selection.
+ * @see #cancelSelection()
+ */
public static final String CANCEL_SELECTION = "CancelSelection";
- /** DOCUMENT ME! */
+ /**
+ * Action command string for approving the current selection.
+ * @see #cancelSelection()
+ */
public static final String APPROVE_SELECTION = "ApproveSelection";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for the approve button text.
+ * @see #setApproveButtonText(String)
+ */
public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY =
"ApproveButtonTextChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for the approve button tool tip text.
+ * @see #setApproveButtonToolTipText(String)
+ */
public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY =
"ApproveButtonToolTipTextChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for the approve button mnemonic.
+ * @see #setApproveButtonMnemonic(int)
+ */
public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY =
"ApproveButtonMnemonicChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for control button visibility.
+ * @see #setControlButtonsAreShown(boolean)
+ */
public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY =
"ControlButtonsAreShownChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for the current directory.
+ * @see #setCurrentDirectory(File)
+ */
public static final String DIRECTORY_CHANGED_PROPERTY = "directoryChanged";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for the selected file.
+ * @see #setSelectedFile(File)
+ */
public static final String SELECTED_FILE_CHANGED_PROPERTY =
"SelectedFileChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for the selected files.
+ * @see #setSelectedFiles(File[])
+ */
public static final String SELECTED_FILES_CHANGED_PROPERTY =
"SelectedFilesChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the property for multi-selection.
+ * @see #setMultiSelectionEnabled(boolean)
+ */
public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY =
"MultiSelectionEnabledChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'file system view' property.
+ * @see #setFileSystemView(FileSystemView)
+ */
public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY =
"FileSystemViewChanged";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'file view' property.
+ * @see #setFileView(FileView)
+ */
public static final String FILE_VIEW_CHANGED_PROPERTY = "fileViewChanged";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'file hiding enabled' property.
+ * @see #setFileHidingEnabled(boolean)
+ */
public static final String FILE_HIDING_CHANGED_PROPERTY =
"FileHidingChanged";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'file filter' property.
+ * @see #setFileFilter(FileFilter)
+ */
public static final String FILE_FILTER_CHANGED_PROPERTY =
"fileFilterChanged";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'file selection mode' property.
+ * @see #setFileSelectionMode(int)
+ */
public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY =
"fileSelectionChanged";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'accessory' property.
+ * @see #setAccessory(JComponent)
+ */
public static final String ACCESSORY_CHANGED_PROPERTY =
"AccessoryChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'accept all file filter used' property.
+ * @see #setAcceptAllFileFilterUsed(boolean)
+ */
public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY =
"acceptAllFileFilterUsedChanged";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'dialog title' property.
+ * @see #setDialogTitle(String)
+ */
public static final String DIALOG_TITLE_CHANGED_PROPERTY =
"DialogTitleChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'dialog type' property.
+ * @see #setDialogType(int)
+ */
public static final String DIALOG_TYPE_CHANGED_PROPERTY =
"DialogTypeChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The name of the 'choosable file filters' property.
+ * @see #addChoosableFileFilter(FileFilter)
+ */
public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY =
"ChoosableFileFilterChangedProperty";
- /** DOCUMENT ME! */
+ /**
+ * The accessible context.
+ * @see #getAccessibleContext()
+ */
protected AccessibleContext accessibleContext;
- /** DOCUMENT ME! */
+ /**
+ * The file system view.
+ * @see #setFileSystemView(FileSystemView)
+ */
private FileSystemView fsv;
- /** DOCUMENT ME! */
+ /**
+ * The accessory component.
+ * @see #setAccessory(JComponent)
+ */
private JComponent accessory;
- /** DOCUMENT ME! */
+ /**
+ * The approve button mnemonic.
+ * @see #setApproveButtonMnemonic(int)
+ */
private int approveButtonMnemonic = 0;
- /** DOCUMENT ME! */
+ /**
+ * The approve button text.
+ * @see #setApproveButtonText(String)
+ */
private String approveButtonText;
- /** DOCUMENT ME! */
+ /**
+ * The approve button tool tip text.
+ * @see #setApproveButtonToolTipText(String)
+ */
private String approveButtonToolTipText;
- /** DOCUMENT ME! */
+ /**
+ * The choosable file filters.
+ * @see #addChoosableFileFilter(FileFilter)
+ */
private ArrayList choosableFilters = new ArrayList();
- /** DOCUMENT ME! */
+ /**
+ * A flag controlling whether the accept all file filter is used.
+ * @see #setAcceptAllFileFilterUsed(boolean)
+ */
private boolean isAcceptAll = true;
- /** DOCUMENT ME! */
+ /**
+ * The dialog title.
+ * @see #setDialogTitle(String)
+ */
private String dialogTitle;
- /** DOCUMENT ME! */
+ /**
+ * The dialog type.
+ * @see #setDialogType(int)
+ */
private int dialogType = OPEN_DIALOG;
- /** DOCUMENT ME! */
+ /**
+ * The return value for the dialog.
+ * @see #showOpenDialog(Component)
+ * @see #showSaveDialog(Component)
+ */
private int retval = ERROR_OPTION;
- /** DOCUMENT ME! */
+ /**
+ * A flag indicating whether the file chooser allows multiple selection.
+ * @see #isMultiSelectionEnabled()
+ */
private boolean multiSelection = false;
- /** DOCUMENT ME! */
+ /**
+ * A flag indicating whether file hiding is enabled.
+ * @see #isFileHidingEnabled()
+ */
private boolean fileHiding = true;
- /** DOCUMENT ME! */
+ /**
+ * The file selection mode.
+ * @see #setFileSelectionMode(int)
+ */
private int fileSelectionMode = FILES_AND_DIRECTORIES;
- /** DOCUMENT ME! */
+ /**
+ * The file view.
+ * @see #setFileView(FileView)
+ */
private FileView fv = null;
- /** DOCUMENT ME! */
+ /**
+ * A flag controlling whether or not the control buttons are visible.
+ * @see #setControlButtonsAreShown(boolean)
+ */
private boolean controlButtonsShown = true;
- /** DOCUMENT ME! */
+ /**
+ * The current directory.
+ * @see #setCurrentDirectory(File)
+ */
private File currentDir = null;
- /** DOCUMENT ME! */
+ /**
+ * The current file filter.
+ * @see #setFileFilter(FileFilter)
+ */
private FileFilter currentFilter = null;
- /** DOCUMENT ME! */
+ /**
+ * An array of selected files.
+ * @see #setSelectedFiles(File[])
+ */
private File[] selectedFiles;
- /** DOCUMENT ME! */
+ /**
+ * The selected file.
+ * @see #setSelectedFile(File)
+ */
private File selectedFile;
/**
- * Creates a new JFileChooser object.
+ * Creates a new <code>JFileChooser</code> object.
*/
public JFileChooser()
{
@@ -243,9 +399,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * Creates a new JFileChooser object.
+ * Creates a new <code>JFileChooser</code> object.
*
- * @param currentDirectoryPath DOCUMENT ME!
+ * @param currentDirectoryPath the directory that should initially be
+ * shown in the filechooser (if <code>null</code>, the user's home
+ * directory is used).
*/
public JFileChooser(String currentDirectoryPath)
{
@@ -254,12 +412,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * Creates a new JFileChooser object with the specified directory and
- * FileSystemView.
+ * Creates a new <code>JFileChooser</code> object with the specified
+ * directory and {@link FileSystemView}.
*
- * @param currentDirectoryPath the directory that should initially be
- * shown the filechooser
- * @param fsv the FileSystemView object to use
+ * @param currentDirectoryPath the directory that should initially be
+ * shown in the filechooser (if <code>null</code>, the user's home
+ * directory is used).
+ * @param fsv the file system view (if <code>null</code>, the default file
+ * system view is used).
*/
public JFileChooser(String currentDirectoryPath, FileSystemView fsv)
{
@@ -268,9 +428,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * Creates a new JFileChooser object.
+ * Creates a new <code>JFileChooser</code> object.
*
- * @param currentDirectory DOCUMENT ME!
+ * @param currentDirectory the directory that should initially be
+ * shown in the filechooser (if <code>null</code>, the user's home
+ * directory is used).
*/
public JFileChooser(File currentDirectory)
{
@@ -279,9 +441,10 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * Creates a new JFileChooser object.
+ * Creates a new <code>JFileChooser</code> object.
*
- * @param fsv DOCUMENT ME!
+ * @param fsv the file system view (if <code>null</code>, the default file
+ * system view is used).
*/
public JFileChooser(FileSystemView fsv)
{
@@ -290,10 +453,13 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * Creates a new JFileChooser object.
+ * Creates a new <code>JFileChooser</code> object.
*
- * @param currentDirectory DOCUMENT ME!
- * @param fsv DOCUMENT ME!
+ * @param currentDirectory the directory that should initially be
+ * shown in the filechooser (if <code>null</code>, the user's home
+ * directory is used).
+ * @param fsv the file system view (if <code>null</code>, the default file
+ * system view is used).
*/
public JFileChooser(File currentDirectory, FileSystemView fsv)
{
@@ -302,9 +468,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets up the file chooser. This method is called by all the constructors.
*
- * @param view DOCUMENT ME!
+ * @param view the file system view (if <code>null</code>, the default file
+ * system view is used).
+ *
+ * @see FileSystemView#getFileSystemView()
*/
protected void setup(FileSystemView view)
{
@@ -336,9 +505,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the selected file, if there is one.
*
- * @return DOCUMENT ME!
+ * @return The selected file (possibly <code>null</code>).
+ *
+ * @see #setSelectedFile(File)
*/
public File getSelectedFile()
{
@@ -346,9 +517,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the selected file and sends a {@link PropertyChangeEvent} to all
+ * registered listeners. The property name is
+ * {@link #SELECTED_FILE_CHANGED_PROPERTY}.
*
- * @param file DOCUMENT ME!
+ * @param file the file (<code>null</code> permitted).
*/
public void setSelectedFile(File file)
{
@@ -361,9 +534,10 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the selected file or files.
*
- * @return DOCUMENT ME!
+ * @return An array of the selected files, or <code>null</code> if there are
+ * no selected files.
*/
public File[] getSelectedFiles()
{
@@ -375,9 +549,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the selected files and sends a {@link PropertyChangeEvent} (with the
+ * name {@link #SELECTED_FILES_CHANGED_PROPERTY}) to all registered
+ * listeners.
*
- * @param selectedFiles DOCUMENT ME!
+ * @param selectedFiles the selected files (<code>null</code> permitted).
*/
public void setSelectedFiles(File[] selectedFiles)
{
@@ -393,9 +569,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the current directory.
*
- * @return DOCUMENT ME!
+ * @return The current directory.
*/
public File getCurrentDirectory()
{
@@ -403,9 +579,15 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the current directory and fires a {@link PropertyChangeEvent} (with
+ * the property name {@link #DIRECTORY_CHANGED_PROPERTY}) to all registered
+ * listeners. If <code>dir</code> is <code>null</code>, the current
+ * directory is set to the default directory returned by the file system
+ * view.
*
- * @param dir DOCUMENT ME!
+ * @param dir the new directory (<code>null</code> permitted).
+ *
+ * @see FileSystemView#getDefaultDirectory()
*/
public void setCurrentDirectory(File dir)
{
@@ -421,7 +603,7 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Called by the UI delegate when the parent directory is changed.
*/
public void changeToParentDirectory()
{
@@ -430,7 +612,7 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Rescans the current directory (this is handled by the UI delegate).
*/
public void rescanCurrentDirectory()
{
@@ -438,9 +620,10 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Ensures the the specified file is visible (this is handled by the
+ * UI delegate).
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*/
public void ensureFileIsVisible(File f)
{
@@ -448,11 +631,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Displays the file chooser in a modal dialog using the
+ * {@link #OPEN_DIALOG} type.
*
- * @param parent DOCUMENT ME!
+ * @param parent the parent component.
*
- * @return DOCUMENT ME!
+ * @return A return value indicating how the dialog was closed (one of
+ * {@link #APPROVE_OPTION}, {@link #CANCEL_OPTION} and
+ * {@link #ERROR_OPTION}).
*
* @throws HeadlessException DOCUMENT ME!
*/
@@ -472,11 +658,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Displays the file chooser in a modal dialog using the
+ * {@link #SAVE_DIALOG} type.
*
- * @param parent DOCUMENT ME!
+ * @param parent the parent component.
*
- * @return DOCUMENT ME!
+ * @return A return value indicating how the dialog was closed (one of
+ * {@link #APPROVE_OPTION}, {@link #CANCEL_OPTION} and
+ * {@link #ERROR_OPTION}).
*
* @throws HeadlessException DOCUMENT ME!
*/
@@ -493,12 +682,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Displays the file chooser in a modal dialog using the
+ * {@link #CUSTOM_DIALOG} type.
*
- * @param parent DOCUMENT ME!
- * @param approveButtonText DOCUMENT ME!
+ * @param parent the parent component.
*
- * @return DOCUMENT ME!
+ * @return A return value indicating how the dialog was closed (one of
+ * {@link #APPROVE_OPTION}, {@link #CANCEL_OPTION} and
+ * {@link #ERROR_OPTION}).
*
* @throws HeadlessException DOCUMENT ME!
*/
@@ -517,11 +708,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Creates a modal dialog in which to display the file chooser.
*
- * @param parent DOCUMENT ME!
+ * @param parent the parent component.
*
- * @return DOCUMENT ME!
+ * @return The dialog.
*
* @throws HeadlessException DOCUMENT ME!
*/
@@ -542,9 +733,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the flag that controls whether or not the control buttons are
+ * shown on the file chooser.
*
- * @return DOCUMENT ME!
+ * @return A boolean.
+ *
+ * @see #setControlButtonsAreShown(boolean)
*/
public boolean getControlButtonsAreShown()
{
@@ -552,9 +746,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the flag that controls whether or not the control buttons are
+ * shown and, if it changes, sends a {@link PropertyChangeEvent} (with the
+ * property name {@link #CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY}) to
+ * all registered listeners.
*
- * @param b DOCUMENT ME!
+ * @param b the new value for the flag.
*/
public void setControlButtonsAreShown(boolean b)
{
@@ -567,9 +764,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the type of file chooser.
*
- * @return DOCUMENT ME!
+ * @return {@link #OPEN_DIALOG}, {@link #SAVE_DIALOG} or
+ * {@link #CUSTOM_DIALOG}.
+ *
+ * @see #setDialogType(int)
*/
public int getDialogType()
{
@@ -577,9 +777,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the dialog type and fires a {@link PropertyChangeEvent} (with the
+ * property name {@link #DIALOG_TYPE_CHANGED_PROPERTY}) to all
+ * registered listeners.
*
- * @param dialogType DOCUMENT ME!
+ * @param dialogType the dialog type (one of: {@link #OPEN_DIALOG},
+ * {@link #SAVE_DIALOG}, {@link #CUSTOM_DIALOG}).
+ *
+ * @throws IllegalArgumentException if <code>dialogType</code> is not valid.
*/
public void setDialogType(int dialogType)
{
@@ -596,9 +801,13 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the dialog title and sends a {@link PropertyChangeEvent} (with the
+ * property name {@link #DIALOG_TITLE_CHANGED_PROPERTY}) to all
+ * registered listeners.
*
- * @param dialogTitle DOCUMENT ME!
+ * @param dialogTitle the dialog title (<code>null</code> permitted).
+ *
+ * @see #getDialogTitle()
*/
public void setDialogTitle(String dialogTitle)
{
@@ -611,9 +820,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the dialog title.
*
- * @return DOCUMENT ME!
+ * @return The dialog title (possibly <code>null</code>).
+ *
+ * @see #setDialogTitle(String)
*/
public String getDialogTitle()
{
@@ -621,9 +832,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the tool tip text for the approve button and sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * {@link #APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY}) to all
+ * registered listeners.
*
- * @param toolTipText DOCUMENT ME!
+ * @param toolTipText the text.
*/
public void setApproveButtonToolTipText(String toolTipText)
{
@@ -637,9 +851,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the tool tip text for the approve button.
*
- * @return DOCUMENT ME!
+ * @return The tool tip text for the approve button.
+ *
+ * @see #setApproveButtonToolTipText(String)
*/
public String getApproveButtonToolTipText()
{
@@ -647,9 +863,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the approve button mnemonic, or zero if no mnemonic has been set.
*
- * @return DOCUMENT ME!
+ * @return The approve button mnemonic.
+ *
+ * @see #setApproveButtonMnemonic(int)
*/
public int getApproveButtonMnemonic()
{
@@ -657,9 +875,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the mnemonic for the approve button and sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * {@link #APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY}) to all registered
+ * listeners.
*
- * @param mnemonic DOCUMENT ME!
+ * @param mnemonic the mnemonic.
+ *
+ * @see #setApproveButtonMnemonic(char)
*/
public void setApproveButtonMnemonic(int mnemonic)
{
@@ -673,9 +896,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the mnemonic for the approve button and sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * {@link #APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY}) to all registered
+ * listeners.
*
- * @param mnemonic DOCUMENT ME!
+ * @param mnemonic the mnemonic.
+ *
+ * @see #setApproveButtonMnemonic(int)
*/
public void setApproveButtonMnemonic(char mnemonic)
{
@@ -683,9 +911,13 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the approve button text and fires a {@link PropertyChangeEvent}
+ * (with the property name {@link #APPROVE_BUTTON_TEXT_CHANGED_PROPERTY}) to
+ * all registered listeners.
*
- * @param approveButtonText DOCUMENT ME!
+ * @param approveButtonText the text (<code>null</code> permitted).
+ *
+ * @see #getApproveButtonText()
*/
public void setApproveButtonText(String approveButtonText)
{
@@ -699,9 +931,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the approve button text.
*
- * @return DOCUMENT ME!
+ * @return The approve button text (possibly <code>null</code>).
+ *
+ * @see #setApproveButtonText(String)
*/
public String getApproveButtonText()
{
@@ -709,9 +943,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the available file filters for this file chooser.
*
- * @return DOCUMENT ME!
+ * @return The available file filters.
*/
public FileFilter[] getChoosableFileFilters()
{
@@ -719,9 +953,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Adds a file filter to the list of available filters and sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * {@link #CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY}) to all registered
+ * listeners.
*
- * @param filter DOCUMENT ME!
+ * @param filter the filter.
*/
public void addChoosableFileFilter(FileFilter filter)
{
@@ -732,11 +969,15 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Removes a file filter from the list of available filters and sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * {@link #CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY}) to all registered
+ * listeners.
*
- * @param f DOCUMENT ME!
+ * @param f the file filter.
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the filter was removed and
+ * <code>false</code> otherwise.
*/
public boolean removeChoosableFileFilter(FileFilter f)
{
@@ -749,7 +990,8 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Clears the list of choosable file filters and installs the 'accept all'
+ * filter from the UI delegate.
*/
public void resetChoosableFileFilters()
{
@@ -759,9 +1001,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the 'accept all' file filter from the UI delegate.
*
- * @return DOCUMENT ME!
+ * @return The 'accept all' file filter.
*/
public FileFilter getAcceptAllFileFilter()
{
@@ -769,9 +1011,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the flag that controls whether or not the 'accept all' file
+ * filter is included in the list of filters.
*
- * @return DOCUMENT ME!
+ * @return A boolean.
+ *
+ * @see #setAcceptAllFileFilterUsed(boolean)
*/
public boolean isAcceptAllFileFilterUsed()
{
@@ -779,9 +1024,13 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the flag that controls whether or not the 'accept all' file filter
+ * is included in the list of filters, and sends a
+ * {@link PropertyChangeEvent} (with the property name
+ * {@link #ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY}) to all registered
+ * listeners.
*
- * @param b DOCUMENT ME!
+ * @param b the new value of the flag.
*/
public void setAcceptAllFileFilterUsed(boolean b)
{
@@ -794,9 +1043,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the accessory component for the file chooser. The default
+ * value is <code>null</code>.
*
- * @return DOCUMENT ME!
+ * @return The accessory component (possibly <code>null</code>).
+ *
+ * @see #setAccessory(JComponent)
*/
public JComponent getAccessory()
{
@@ -804,9 +1056,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the accessory component for the file chooser and sends a
+ * {@link PropertyChangeEvent} to all registered listeners. The property
+ * name is {@link #ACCESSORY_CHANGED_PROPERTY}.
*
- * @param newAccessory DOCUMENT ME!
+ * @param newAccessory the accessory component.
*/
public void setAccessory(JComponent newAccessory)
{
@@ -819,9 +1073,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the file selection mode and sends a {@link PropertyChangeEvent}
+ * to all registered listeners. The property name is
+ * {@link #FILE_SELECTION_MODE_CHANGED_PROPERTY}.
*
- * @param mode DOCUMENT ME!
+ * @param mode the mode ({@link #FILES_ONLY}, {@link #DIRECTORIES_ONLY} or
+ * {@link #FILES_AND_DIRECTORIES}).
+ *
+ * @throws IllegalArgumentException if the mode is invalid.
*/
public void setFileSelectionMode(int mode)
{
@@ -838,9 +1097,13 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the file selection mode, one of: {@link #FILES_ONLY},
+ * {@link #DIRECTORIES_ONLY} or {@link #FILES_AND_DIRECTORIES}. The
+ * default is {@link #FILES_ONLY}.
*
- * @return DOCUMENT ME!
+ * @return The file selection mode.
+ *
+ * @see #setFileSelectionMode(int)
*/
public int getFileSelectionMode()
{
@@ -848,9 +1111,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if file selection is enabled, and
+ * <code>false</code> otherwise. File selection is enabled when the
+ * file selection mode is {@link #FILES_ONLY} or
+ * {@link #FILES_AND_DIRECTORIES}.
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if file selection is enabled.
+ *
+ * @see #getFileSelectionMode()
*/
public boolean isFileSelectionEnabled()
{
@@ -859,9 +1127,14 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if directory selection is enabled, and
+ * <code>false</code> otherwise. Directory selection is enabled when the
+ * file selection mode is {@link #DIRECTORIES_ONLY} or
+ * {@link #FILES_AND_DIRECTORIES}.
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if file selection is enabled.
+ *
+ * @see #getFileSelectionMode()
*/
public boolean isDirectorySelectionEnabled()
{
@@ -870,9 +1143,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the flag that controls whether multiple selections are allowed in
+ * this filechooser and sends a {@link PropertyChangeEvent} (with the
+ * property name {@link #MULTI_SELECTION_ENABLED_CHANGED_PROPERTY}) to all
+ * registered listeners.
*
- * @param b DOCUMENT ME!
+ * @param b the new value of the flag.
*/
public void setMultiSelectionEnabled(boolean b)
{
@@ -885,9 +1161,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if multiple selections are allowed within this
+ * file chooser, and <code>false</code> otherwise.
*
- * @return DOCUMENT ME!
+ * @return A boolean.
+ *
+ * @see #setMultiSelectionEnabled(boolean)
*/
public boolean isMultiSelectionEnabled()
{
@@ -895,9 +1174,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if hidden files are to be hidden, and
+ * <code>false</code> otherwise.
*
- * @return DOCUMENT ME!
+ * @return A boolean.
+ *
+ * @see #setFileHidingEnabled(boolean)
*/
public boolean isFileHidingEnabled()
{
@@ -905,9 +1187,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the flag that controls whether or not hidden files are displayed,
+ * and sends a {@link PropertyChangeEvent} (with the property name
+ * {@link #FILE_HIDING_CHANGED_PROPERTY}) to all registered listeners.
*
- * @param b DOCUMENT ME!
+ * @param b the new value of the flag.
*/
public void setFileHidingEnabled(boolean b)
{
@@ -920,9 +1204,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the file filter and sends a {@link PropertyChangeEvent} (with the
+ * property name {@link #FILE_FILTER_CHANGED_PROPERTY}) to all registered
+ * listeners.
*
- * @param filter DOCUMENT ME!
+ * @param filter the filter.
*/
public void setFileFilter(FileFilter filter)
{
@@ -935,9 +1221,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the file filter.
*
- * @return DOCUMENT ME!
+ * @return The file filter.
+ *
+ * @see #setFileFilter(FileFilter)
*/
public FileFilter getFileFilter()
{
@@ -945,9 +1233,13 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets a custom {@link FileView} for the file chooser and sends a
+ * {@link PropertyChangeEvent} to all registered listeners. The property
+ * name is {@link #FILE_VIEW_CHANGED_PROPERTY}.
+ *
+ * @param fileView the file view (<code>null</code> permitted).
*
- * @param fileView DOCUMENT ME!
+ * @see #getFileView()
*/
public void setFileView(FileView fileView)
{
@@ -960,9 +1252,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the custom {@link FileView} for the file chooser.
*
- * @return DOCUMENT ME!
+ * @return The file view (possibly <code>null</code>).
*/
public FileView getFileView()
{
@@ -970,71 +1262,83 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the name of the file, generated by the current (or default)
+ * {@link FileView}.
*
- * @return DOCUMENT ME!
- */
- private FileView getInternalFileView()
- {
- if (fv == null)
- return getUI().getFileView(this);
- return fv;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return The file name.
*/
public String getName(File f)
{
- return getInternalFileView().getName(f);
+ String name = null;
+ if (fv != null)
+ name = fv.getName(f);
+ if (name == null)
+ name = getUI().getFileView(this).getName(f);
+ return name;
}
/**
- * DOCUMENT ME!
+ * Returns the description of the file, generated by the current (or default)
+ * {@link FileView}.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return The file description.
*/
public String getDescription(File f)
{
- return getInternalFileView().getDescription(f);
+ String result = null;
+ if (fv != null)
+ result = fv.getDescription(f);
+ if (result == null)
+ result = getUI().getFileView(this).getDescription(f);
+ return result;
}
/**
- * DOCUMENT ME!
+ * Returns the type description for the file, generated by the current (or
+ * default) {@link FileView}.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return The file type description.
*/
public String getTypeDescription(File f)
{
- return getInternalFileView().getTypeDescription(f);
+ String result = null;
+ if (fv != null)
+ result = getFileView().getTypeDescription(f);
+ if (result == null)
+ result = getUI().getFileView(this).getTypeDescription(f);
+ return result;
}
/**
- * DOCUMENT ME!
+ * Returns the icon provided by the current (or default) {@link FileView}.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return An icon representing the file.
*/
public Icon getIcon(File f)
{
- return getInternalFileView().getIcon(f);
+ Icon result = null;
+ if (fv != null)
+ result = fv.getIcon(f);
+ if (result == null)
+ result = getUI().getFileView(this).getIcon(f);
+ return result;
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if the file is traversable, and
+ * <code>false</code> otherwise.
*
- * @param f DOCUMENT ME!
+ * @param f the file or directory.
*
- * @return DOCUMENT ME!
+ * @return A boolean.
*/
public boolean isTraversable(File f)
{
@@ -1042,11 +1346,12 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if the file is accepted by the current
+ * file filter.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return A boolean.
*/
public boolean accept(File f)
{
@@ -1056,9 +1361,10 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sets the file system view for the file chooser and sends a
+ * {@link PropertyChangeEvent} to all registered listeners.
*
- * @param fsv DOCUMENT ME!
+ * @param fsv the file system view.
*/
public void setFileSystemView(FileSystemView fsv)
{
@@ -1071,9 +1377,11 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the file system view being used by this file chooser.
*
- * @return DOCUMENT ME!
+ * @return The file system view.
+ *
+ * @see #setFileSystemView(FileSystemView)
*/
public FileSystemView getFileSystemView()
{
@@ -1081,7 +1389,8 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Approves the selection. An {@link ActionEvent} is sent to all registered
+ * listeners.
*/
public void approveSelection()
{
@@ -1090,7 +1399,8 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Cancels the selection. An {@link ActionEvent} is sent to all registered
+ * listeners.
*/
public void cancelSelection()
{
@@ -1099,9 +1409,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Adds an {@link ActionListener} to the file chooser.
*
- * @param l DOCUMENT ME!
+ * @param l the listener.
*/
public void addActionListener(ActionListener l)
{
@@ -1109,9 +1419,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Removes an {@link ActionListener} from this file chooser.
*
- * @param l DOCUMENT ME!
+ * @param l the listener.
*/
public void removeActionListener(ActionListener l)
{
@@ -1126,9 +1436,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the action listeners registered with this file chooser.
*
- * @return DOCUMENT ME!
+ * @return An array of listeners.
*/
public ActionListener[] getActionListeners()
{
@@ -1136,9 +1446,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Sends an @link {ActionEvent} to all registered listeners.
*
- * @param command DOCUMENT ME!
+ * @param command the action command.
*/
protected void fireActionPerformed(String command)
{
@@ -1151,7 +1461,7 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Installs the UI delegate for the current look and feel.
*/
public void updateUI()
{
@@ -1160,9 +1470,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the UI delegate class identifier.
*
- * @return DOCUMENT ME!
+ * @return <code>FileChooserUI</code>.
*/
public String getUIClassID()
{
@@ -1170,9 +1480,9 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the UI delegate for the component.
*
- * @return DOCUMENT ME!
+ * @return The UI delegate.
*/
public FileChooserUI getUI()
{
@@ -1190,12 +1500,29 @@ public class JFileChooser extends JComponent implements Accessible
}
/**
- * DOCUMENT ME!
+ * Returns the accessible context.
*
- * @return DOCUMENT ME!
+ * @return The accessible context.
*/
public AccessibleContext getAccessibleContext()
{
- return null;
+ return new AccessibleJFileChooser();
+ }
+
+ /**
+ * Accessibility support for JFileChooser
+ */
+ protected class AccessibleJFileChooser
+ extends JComponent.AccessibleJComponent
+ {
+ protected AccessibleJFileChooser()
+ {
+ // Nothing to do here.
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.FILE_CHOOSER;
+ }
}
}
diff --git a/javax/swing/JFrame.java b/javax/swing/JFrame.java
index ce422ef3f..d8c3d9654 100644
--- a/javax/swing/JFrame.java
+++ b/javax/swing/JFrame.java
@@ -83,6 +83,14 @@ public class JFrame extends Frame
}
}
+ /**
+ * A flag for {@link #setDefaultCloseOperation(int)}, indicating that the
+ * application should be exited, when this <code>JFrame</code> is closed.
+ *
+ * @since 1.3
+ */
+ public static final int EXIT_ON_CLOSE = 3;
+
private static final long serialVersionUID = -3362141868504252139L;
private static boolean defaultLookAndFeelDecorated;
private int close_action = HIDE_ON_CLOSE;
diff --git a/javax/swing/JLabel.java b/javax/swing/JLabel.java
index 2e7ad98dd..a9adc96b2 100644
--- a/javax/swing/JLabel.java
+++ b/javax/swing/JLabel.java
@@ -331,9 +331,6 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
/** The gap between the icon and the text. */
private transient int iconTextGap = 4;
- /** The accessible context for this JLabel. */
- private AccessibleJLabel accessibleContext;
-
/**
* Creates a new vertically centered, horizontally on the leading edge
* JLabel object with text and no icon.
@@ -403,6 +400,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
this.text = text;
this.icon = icon;
this.horizontalAlignment = horizontalAlignment;
+ setAlignmentX(0.0F);
updateUI();
}
@@ -477,12 +475,14 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
{
if (text != newText)
{
- String oldText = text;
- text = newText;
- firePropertyChange("text", oldText, newText);
-
- if (text != null && text.length() <= displayedMnemonicIndex)
- setDisplayedMnemonicIndex(text.length() - 1);
+ String oldText = text;
+ text = newText;
+ firePropertyChange("text", oldText, newText);
+
+ if (text != null && text.length() <= displayedMnemonicIndex)
+ setDisplayedMnemonicIndex(text.length() - 1);
+ revalidate();
+ repaint();
}
}
diff --git a/javax/swing/JLayeredPane.java b/javax/swing/JLayeredPane.java
index e86910395..2617bc408 100644
--- a/javax/swing/JLayeredPane.java
+++ b/javax/swing/JLayeredPane.java
@@ -40,6 +40,7 @@ package javax.swing;
import java.awt.Component;
import java.awt.Container;
+import java.awt.Graphics;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -164,7 +165,6 @@ public class JLayeredPane extends JComponent implements Accessible
setLayout(null);
}
-
/**
* Looks up the layer a child component is currently assigned to.
*
@@ -272,7 +272,7 @@ public class JLayeredPane extends JComponent implements Accessible
* Increments the recorded size of a given layer.
*
* @param layer the layer number to increment.
- * @see #incrLayer()
+ * @see #incrLayer
*/
private void incrLayer(Integer layer)
{
@@ -286,7 +286,7 @@ public class JLayeredPane extends JComponent implements Accessible
* Decrements the recorded size of a given layer.
*
* @param layer the layer number to decrement.
- * @see #decrLayer()
+ * @see #incrLayer
*/
private void decrLayer(Integer layer)
{
@@ -573,26 +573,15 @@ public class JLayeredPane extends JComponent implements Accessible
*
* @param index the index of the child component to remove.
*/
- public void remove (int index)
+ public void remove(int index)
{
- Component c = getComponent (index);
- int layer = getLayer (c);
- decrLayer (new Integer(layer));
- componentToLayer.remove (c);
- super.remove (index);
+ Component c = getComponent(index);
+ int layer = getLayer(c);
+ decrLayer(new Integer(layer));
+ componentToLayer.remove(c);
+ super.remove(index);
+ // FIXME: Figure out if this call is correct.
revalidate();
- repaint();
- }
-
- /**
- * Removes a child from this container. The child is specified directly.
- * After removal, the child no longer occupies a layer.
- *
- * @param comp the child to remove.
- */
- public void remove (Component comp)
- {
- remove (getIndexOf (comp));
}
/**
@@ -655,8 +644,6 @@ public class JLayeredPane extends JComponent implements Accessible
incrLayer (layer);
super.addImpl(comp, null, newIdx);
- revalidate();
- repaint();
}
/**
@@ -681,4 +668,32 @@ public class JLayeredPane extends JComponent implements Accessible
accessibleContext = new AccessibleJLayeredPane();
return accessibleContext;
}
+
+ /**
+ * This method is overridden order to provide a reasonable painting
+ * mechanism for <code>JLayeredPane</code>. This is necessary since
+ * <code>JLayeredPane</code>'s do not have an own UI delegate.
+ *
+ * Basically this method clears the background for the
+ * <code>JLayeredPane</code> and then calls <code>super.paint(g)</code>.
+ *
+ * @param g the graphics context to use
+ */
+ public void paint(Graphics g)
+ {
+ g.setColor(getBackground());
+ g.fillRect(0, 0, getWidth(), getHeight());
+ super.paint(g);
+ }
+
+ /**
+ * Overridden to return <code>false</code>, since <code>JLayeredPane</code>
+ * cannot guarantee that its children don't overlap.
+ *
+ * @return <code>false</code>
+ */
+ public boolean isOptimizedDrawingEnabled()
+ {
+ return false;
+ }
}
diff --git a/javax/swing/JList.java b/javax/swing/JList.java
index 0aedee2ab..d77bc41d6 100644
--- a/javax/swing/JList.java
+++ b/javax/swing/JList.java
@@ -614,6 +614,14 @@ public class JList extends JComponent implements Accessible, Scrollable
// TODO: Implement the remaining methods of this class.
}
+
+ /**
+ * Create a new AccessibleJList.
+ */
+ public AccessibleJList()
+ {
+ // Nothing to do here.
+ }
/**
* Returns the number of selected accessible children.
@@ -915,7 +923,7 @@ public class JList extends JComponent implements Accessible, Scrollable
/**
* This property specifies a foreground color for the selected cells in
- * the list. When {@link ListCellRenderer.getListCellRendererComponent}
+ * the list. When {@link ListCellRenderer#getListCellRendererComponent}
* is called with a selected cell object, the component returned will
* have its "foreground" set to this color.
*/
@@ -923,7 +931,7 @@ public class JList extends JComponent implements Accessible, Scrollable
/**
* This property specifies a background color for the selected cells in
- * the list. When {@link ListCellRenderer.getListCellRendererComponent}
+ * the list. When {@link ListCellRenderer#getListCellRendererComponent}
* is called with a selected cell object, the component returned will
* have its "background" property set to this color.
*/
@@ -950,9 +958,9 @@ public class JList extends JComponent implements Accessible, Scrollable
/**
* This property indicates a <em>preference</em> for the number of rows
* displayed in the list, and will scale the
- * {@link #preferredScrollableViewportSize} property accordingly. The actual
+ * {@link #getPreferredScrollableViewportSize} property accordingly. The actual
* number of displayed rows, when the list is placed in a real {@link
- * Viewport} or other component, may be greater or less than this number.
+ * JViewport} or other component, may be greater or less than this number.
*/
int visibleRowCount;
@@ -1004,7 +1012,7 @@ public class JList extends JComponent implements Accessible, Scrollable
event.getValueIsAdjusting());
JList.this.repaint();
}
- };
+ }
/**
* Shared ListListener instance, subscribed to both the current {@link
@@ -1171,7 +1179,7 @@ public class JList extends JComponent implements Accessible, Scrollable
/**
* Sets the value of the {@link #visibleRowCount} property.
*
- * @param visibleRowCount The new property value
+ * @param vc The new property value
*/
public void setVisibleRowCount(int vc)
{
@@ -1297,8 +1305,8 @@ public class JList extends JComponent implements Accessible, Scrollable
/**
* Returns the list index of the upper left or upper right corner of the
- * {@link #visibleRect} property, depending on the {@link
- * #componentOrientation} property.
+ * visible rectangle of this list, depending on the {@link
+ * Component#getComponentOrientation} property.
*
* @return The index of the first visible list cell, or <code>-1</code>
* if none is visible.
@@ -1319,7 +1327,8 @@ public class JList extends JComponent implements Accessible, Scrollable
*
* @return index of the cell to which specified location is closest to.
*/
- public int locationToIndex(Point location) {
+ public int locationToIndex(Point location)
+ {
return getUI().locationToIndex(this, location);
}
@@ -1329,14 +1338,15 @@ public class JList extends JComponent implements Accessible, Scrollable
*
* @return location of the cell located at the specified index in the list.
*/
- public Point indexToLocation(int index){
- return getCellBounds(index, index).getLocation();
+ public Point indexToLocation(int index)
+ {
+ return getUI().indexToLocation(this, index);
}
/**
* Returns the list index of the lower right or lower left corner of the
- * {@link #visibleRect} property, depending on the {@link
- * #componentOrientation} property.
+ * visible rectangle of this list, depending on the {@link
+ * Component#getComponentOrientation} property.
*
* @return The index of the last visible list cell, or <code>-1</code>
* if none is visible.
@@ -1359,7 +1369,7 @@ public class JList extends JComponent implements Accessible, Scrollable
* selected.
*
* @return An array of model indices, each of which is selected according
- * to the {@link #selection} property
+ * to the {@link #getSelectedValues} property
*/
public int[] getSelectedIndices()
{
@@ -1374,7 +1384,7 @@ public class JList extends JComponent implements Accessible, Scrollable
n++;
int [] v = new int[n];
j = 0;
- for (i = lo; i < hi; ++i)
+ for (i = lo; i <= hi; ++i)
if (selectionModel.isSelectedIndex(i))
v[j++] = i;
return v;
@@ -1404,7 +1414,7 @@ public class JList extends JComponent implements Accessible, Scrollable
* @return The first selected element, or <code>null</code> if no element
* is selected.
*
- * @see getSelectedValues
+ * @see #getSelectedValues
*/
public Object getSelectedValue()
{
@@ -1420,7 +1430,7 @@ public class JList extends JComponent implements Accessible, Scrollable
*
* @return An array containing all the selected values
*
- * @see getSelectedValue
+ * @see #setSelectedValue
*/
public Object[] getSelectedValues()
{
@@ -1579,7 +1589,7 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Sets the value of the {@link #celLRenderer} property.
+ * Sets the value of the {@link #getCellRenderer} property.
*
* @param renderer The new property value
*/
@@ -1753,14 +1763,14 @@ public class JList extends JComponent implements Accessible, Scrollable
public AccessibleContext getAccessibleContext()
{
- return null;
+ return new AccessibleJList();
}
/**
* Returns a size indicating how much space this list would like to
* consume, when contained in a scrollable viewport. This is part of the
* {@link Scrollable} interface, which interacts with {@link
- * ScrollPaneLayout} and {@link Viewport} to define scrollable objects.
+ * ScrollPaneLayout} and {@link JViewport} to define scrollable objects.
*
* @return The preferred size
*/
@@ -1770,36 +1780,43 @@ public class JList extends JComponent implements Accessible, Scrollable
//return the value from getPreferredSize. The current ListUI is
//expected to override getPreferredSize to return an appropriate value.
if (getLayoutOrientation() != VERTICAL)
- return getPreferredSize();
+ return getPreferredSize();
+
+ int size = getModel().getSize();
+ // Trivial case: if fixedCellWidth and fixedCellHeight were set
+ // just use them
if (fixedCellHeight != -1 && fixedCellWidth != -1)
- return new Dimension(fixedCellWidth, getModel().getSize() *
- fixedCellHeight);
+ return new Dimension(fixedCellWidth, size * fixedCellHeight);
+
+ // If the model is empty we use 16 * the number of visible rows
+ // for the height and either fixedCellWidth (if set) or 256
+ // for the width
+ if (size == 0)
+ {
+ if (fixedCellWidth == -1)
+ return new Dimension(256, 16 * getVisibleRowCount());
+ else
+ return new Dimension(fixedCellWidth, 16 * getVisibleRowCount());
+ }
- int prefWidth, prefHeight;
+ // Calculate the width: if fixedCellWidth was set use that, otherwise
+ // use the preferredWidth
+ int prefWidth;
if (fixedCellWidth != -1)
prefWidth = fixedCellWidth;
else
- {
- prefWidth = 0;
- int size = getModel().getSize();
- for (int i = 0; i < size; i++)
- if (getCellBounds(i, i).width > prefWidth)
- prefWidth = getCellBounds(i, i).width;
- }
-
- if (getModel().getSize() == 0 && fixedCellWidth == -1)
- return new Dimension(256, 16 * getVisibleRowCount());
- else if (getModel().getSize() == 0)
- return new Dimension (fixedCellWidth, 16 * getVisibleRowCount());
-
+ prefWidth = getPreferredSize().width;
+
+ // Calculate the height: if fixedCellHeight was set use that, otherwise
+ // use the height of the first row multiplied by the number of visible
+ // rows
+ int prefHeight;
if (fixedCellHeight != -1)
prefHeight = fixedCellHeight;
else
- {
- prefHeight = getVisibleRowCount() * getCellBounds
- (getFirstVisibleIndex(), getFirstVisibleIndex()).height;
- }
+ prefHeight = getVisibleRowCount() * getCellBounds(0, 0).height;
+
return new Dimension (prefWidth, prefHeight);
}
@@ -1930,7 +1947,7 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Gets the value of the {@link #scrollableTracksViewportWidth} property.
+ * Gets the value of the <code>scrollableTracksViewportWidth</code> property.
*
* @return <code>true</code> if the viewport is larger (horizontally)
* than the list and the list should be expanded to fit the viewport;
@@ -1955,7 +1972,7 @@ public class JList extends JComponent implements Accessible, Scrollable
}
/**
- * Gets the value of the {@link #scrollableTracksViewportWidth} property.
+ * Gets the value of the </code>scrollableTracksViewportWidth</code> property.
*
* @return <code>true</code> if the viewport is larger (vertically)
* than the list and the list should be expanded to fit the viewport;
@@ -2107,7 +2124,7 @@ public class JList extends JComponent implements Accessible, Scrollable
*/
public Rectangle getCellBounds(int index0, int index1)
{
- return ((ListUI) ui).getCellBounds(this, index0, index1);
+ return getUI().getCellBounds(this, index0, index1);
}
/**
@@ -2117,8 +2134,8 @@ public class JList extends JComponent implements Accessible, Scrollable
*
* @param prefix the prefix to search for in the cell values
* @param startIndex the index where to start searching from
- * @param bias the search direction, either {@link Position.Bias.Forward}
- * or {@link Position.Bias.Backward}
+ * @param bias the search direction, either {@link Position.Bias#Forward}
+ * or {@link Position.Bias#Backward}
*
* @return the index of the found element or -1 if no such element has
* been found
diff --git a/javax/swing/JMenu.java b/javax/swing/JMenu.java
index 8dcad8b77..9734eb873 100644
--- a/javax/swing/JMenu.java
+++ b/javax/swing/JMenu.java
@@ -45,8 +45,6 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.EventListener;
@@ -137,10 +135,6 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
this(text);
}
- private void writeObject(ObjectOutputStream stream) throws IOException
- {
- }
-
/**
* Adds specified menu item to this menu
*
@@ -768,6 +762,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
protected void processKeyEvent(KeyEvent event)
{
+ // TODO: Implement this properly.
}
/**
@@ -812,6 +807,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
return accessibleContext;
}
+ // FIXME: This inner class is a complete stub and needs to be implemented.
protected class AccessibleJMenu extends AccessibleJMenuItem
implements AccessibleSelection
{
@@ -819,6 +815,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
protected AccessibleJMenu()
{
+ // Nothing to do here.
}
public int getAccessibleChildrenCount()
@@ -858,32 +855,48 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
public void addAccessibleSelection(int value0)
{
+ // TODO: Implement this properly.
}
public void removeAccessibleSelection(int value0)
{
+ // TODO: Implement this properly.
}
public void clearAccessibleSelection()
{
+ // TODO: Implement this properly.
}
public void selectAllAccessibleSelection()
{
+ // TODO: Implement this properly.
}
}
protected class WinListener extends WindowAdapter implements Serializable
{
- JPopupMenu popupMenu;
private static final long serialVersionUID = -6415815570638474823L;
+ /**
+ * Creates a new <code>WinListener</code>.
+ *
+ * @param popup the popup menu which is observed
+ */
public WinListener(JPopupMenu popup)
{
+ // TODO: What should we do with the popup argument?
}
+ /**
+ * Receives notification when the popup menu is closing and deselects
+ * the menu.
+ *
+ * @param event the window event
+ */
public void windowClosing(WindowEvent event)
{
+ setSelected(false);
}
}
diff --git a/javax/swing/JMenuBar.java b/javax/swing/JMenuBar.java
index 25d4b0cfa..829d671ec 100644
--- a/javax/swing/JMenuBar.java
+++ b/javax/swing/JMenuBar.java
@@ -46,6 +46,9 @@ import java.awt.event.MouseEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleStateSet;
import javax.swing.plaf.MenuBarUI;
/**
@@ -59,6 +62,137 @@ import javax.swing.plaf.MenuBarUI;
*/
public class JMenuBar extends JComponent implements Accessible, MenuElement
{
+ /**
+ * Provides accessibility support for <code>JMenuBar</code>.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class AccessibleJMenuBar extends AccessibleJComponent
+ implements AccessibleSelection
+ {
+
+ /**
+ * Returns the number of selected items in the menu bar. Possible values
+ * are <code>0</code> if nothing is selected, or <code>1</code> if one
+ * item is selected.
+ *
+ * @return the number of selected items in the menu bar
+ */
+ public int getAccessibleSelectionCount()
+ {
+ int count = 0;
+ if (getSelectionModel().getSelectedIndex() != -1)
+ count = 1;
+ return count;
+ }
+
+ /**
+ * Returns the selected with index <code>i</code> menu, or
+ * <code>null</code> if the specified menu is not selected.
+ *
+ * @param i the index of the menu to return
+ *
+ * @return the selected with index <code>i</code> menu, or
+ * <code>null</code> if the specified menu is not selected
+ */
+ public Accessible getAccessibleSelection(int i)
+ {
+ if (getSelectionModel().getSelectedIndex() != i)
+ return null;
+ return getMenu(i);
+ }
+
+ /**
+ * Returns <code>true</code> if the specified menu is selected,
+ * <code>false</code> otherwise.
+ *
+ * @param i the index of the menu to check
+ *
+ *@return <code>true</code> if the specified menu is selected,
+ * <code>false</code> otherwise
+ */
+ public boolean isAccessibleChildSelected(int i)
+ {
+ return getSelectionModel().getSelectedIndex() == i;
+ }
+
+ /**
+ * Selects the menu with index <code>i</code>. If another menu is already
+ * selected, this will be deselected.
+ *
+ * @param i the menu to be selected
+ */
+ public void addAccessibleSelection(int i)
+ {
+ getSelectionModel().setSelectedIndex(i);
+ }
+
+ /**
+ * Deselects the menu with index <code>i</code>.
+ *
+ * @param i the menu index to be deselected
+ */
+ public void removeAccessibleSelection(int i)
+ {
+ if (getSelectionModel().getSelectedIndex() == i)
+ getSelectionModel().clearSelection();
+ }
+
+ /**
+ * Deselects all possibly selected menus.
+ */
+ public void clearAccessibleSelection()
+ {
+ getSelectionModel().clearSelection();
+ }
+
+ /**
+ * In menu bars it is not possible to select all items, so this method
+ * does nothing.
+ */
+ public void selectAllAccessibleSelection()
+ {
+ // In menu bars it is not possible to select all items, so this method
+ // does nothing.
+ }
+
+ /**
+ * Returns the accessible role of <code>JMenuBar</code>, which is
+ * {@link AccessibleRole#MENU_BAR}.
+ *
+ * @return the accessible role of <code>JMenuBar</code>, which is
+ * {@link AccessibleRole#MENU_BAR}
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.MENU_BAR;
+ }
+
+ /**
+ * Returns the <code>AccessibleSelection</code> for this object. This
+ * method returns <code>this</code>, since the
+ * <code>AccessibleJMenuBar</code> manages its selection itself.
+ *
+ * @return the <code>AccessibleSelection</code> for this object
+ */
+ public AccessibleSelection getAccessibleSelection()
+ {
+ return this;
+ }
+
+ /**
+ * Returns the state of this <code>AccessibleJMenuBar</code>.
+ *
+ * @return the state of this <code>AccessibleJMenuBar</code>.
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet stateSet = super.getAccessibleStateSet();
+ // TODO: Figure out what state must be added to the super state set.
+ return stateSet;
+ }
+ }
+
private static final long serialVersionUID = -8191026883931977036L;
/** JMenuBar's model. It keeps track of selected menu's index */
@@ -106,7 +240,9 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
public AccessibleContext getAccessibleContext()
{
- return null;
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJMenuBar();
+ return accessibleContext;
}
/**
@@ -384,9 +520,14 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
* Sets help menu for this menu bar
*
* @param menu help menu
+ *
+ * @specnote The specification states that this method is not yet implemented
+ * and should throw an exception.
*/
public void setHelpMenu(JMenu menu)
{
+ // We throw an Error here, just as Sun's JDK does.
+ throw new Error("setHelpMenu() not yet implemented.");
}
/**
diff --git a/javax/swing/JMenuItem.java b/javax/swing/JMenuItem.java
index 069b7bc86..9799017f6 100644
--- a/javax/swing/JMenuItem.java
+++ b/javax/swing/JMenuItem.java
@@ -44,9 +44,6 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.util.EventListener;
import javax.accessibility.Accessible;
@@ -84,6 +81,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
public JMenuItem()
{
super();
+ init(null, null);
}
/**
@@ -118,6 +116,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
{
super();
super.setAction(action);
+ init(null, null);
}
/**
@@ -147,15 +146,6 @@ public class JMenuItem extends AbstractButton implements Accessible,
setMnemonic(mnemonic);
}
- private void readObject(ObjectInputStream stream)
- throws IOException, ClassNotFoundException
- {
- }
-
- private void writeObject(ObjectOutputStream stream) throws IOException
- {
- }
-
/**
* Initializes this menu item
*
@@ -176,7 +166,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
//borderPainted = false;
focusPainted = false;
horizontalAlignment = JButton.LEFT;
- horizontalTextPosition = JButton.LEFT;
+ horizontalTextPosition = JButton.TRAILING;
}
/**
@@ -189,7 +179,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
{
super.setUI(ui);
}
-
+
/**
* This method sets this menuItem's UI to the UIManager's default for the
* current look and feel.
@@ -255,8 +245,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
- * Sets accelerator for this menu item.
- *
+ * Sets the key combination which invokes the menu item's action
+ * listeners without navigating the menu hierarchy. Note that when the
+ * keyboard accelerator is typed, it will work whether or not the
+ * menu is currently displayed.
+ *
* @param keystroke accelerator for this menu item.
*/
public void setAccelerator(KeyStroke keystroke)
@@ -276,7 +269,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
super.configurePropertiesFromAction(action);
if (! (this instanceof JMenu) && action != null)
- setAccelerator((KeyStroke) (action.getValue(Action.ACCELERATOR_KEY)));
+ {
+ setAccelerator((KeyStroke) (action.getValue(Action.ACCELERATOR_KEY)));
+ super.registerKeyboardAction(action, accelerator,
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ }
}
/**
@@ -667,6 +664,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
public void stateChanged(ChangeEvent event)
{
+ // TODO: What should be done here, if anything?
}
public AccessibleRole getAccessibleRole()
diff --git a/javax/swing/JOptionPane.java b/javax/swing/JOptionPane.java
index 54e6abc0e..2f28ccc91 100644
--- a/javax/swing/JOptionPane.java
+++ b/javax/swing/JOptionPane.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
-import java.awt.Dimension;
import java.awt.Frame;
import javax.accessibility.Accessible;
@@ -60,16 +59,19 @@ public class JOptionPane extends JComponent implements Accessible
/**
* DOCUMENT ME!
*/
+ // FIXME: This inner class is a complete stub and needs to be implemented
+ // properly.
protected class AccessibleJOptionPane extends JComponent.AccessibleJComponent
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 686071432213084821L;
-
+
/**
* Creates a new AccessibleJOptionPane object.
*/
protected AccessibleJOptionPane()
{
+ // Nothing to do here.
}
/**
@@ -343,8 +345,6 @@ public class JOptionPane extends JComponent implements Accessible
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
updateUI();
- invalidate();
- repaint();
}
/**
@@ -377,8 +377,6 @@ public class JOptionPane extends JComponent implements Accessible
dialog.getContentPane().add(this);
dialog.setModal(true);
dialog.setResizable(false);
- dialog.invalidate();
- dialog.repaint();
return dialog;
}
@@ -513,6 +511,8 @@ public class JOptionPane extends JComponent implements Accessible
*/
public Object getInputValue()
{
+ if (getValue().equals(new Integer(CANCEL_OPTION)))
+ setInputValue(null);
return inputValue;
}
@@ -974,7 +974,7 @@ public class JOptionPane extends JComponent implements Accessible
JDialog dialog = pane.createDialog(parentComponent, null);
dialog.pack();
dialog.show();
-
+
return (String) pane.getInputValue();
}
@@ -1001,7 +1001,7 @@ public class JOptionPane extends JComponent implements Accessible
JDialog dialog = pane.createDialog(parentComponent, null);
dialog.pack();
dialog.show();
-
+
return (String) pane.getInputValue();
}
@@ -1027,7 +1027,7 @@ public class JOptionPane extends JComponent implements Accessible
JDialog dialog = pane.createDialog(parentComponent, title);
dialog.pack();
dialog.show();
-
+
return (String) pane.getInputValue();
}
@@ -1060,8 +1060,8 @@ public class JOptionPane extends JComponent implements Accessible
JDialog dialog = pane.createDialog(parentComponent, title);
dialog.pack();
dialog.show();
-
- return (String) pane.getInputValue();
+
+ return pane.getInputValue();
}
/**
@@ -1081,7 +1081,7 @@ public class JOptionPane extends JComponent implements Accessible
JDialog dialog = pane.createDialog(null, null);
dialog.pack();
dialog.show();
-
+
return (String) pane.getInputValue();
}
@@ -1106,7 +1106,7 @@ public class JOptionPane extends JComponent implements Accessible
JDialog dialog = pane.createDialog(null, null);
dialog.pack();
dialog.show();
-
+
return (String) pane.getInputValue();
}
@@ -1128,8 +1128,10 @@ public class JOptionPane extends JComponent implements Accessible
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
startModal(frame);
-
- return ((Integer) pane.getValue()).intValue();
+
+ if (pane.getValue() instanceof Integer)
+ return ((Integer) pane.getValue()).intValue();
+ return -1;
}
/**
@@ -1154,7 +1156,9 @@ public class JOptionPane extends JComponent implements Accessible
startModal(frame);
- return ((Integer) pane.getValue()).intValue();
+ if (pane.getValue() instanceof Integer)
+ return ((Integer) pane.getValue()).intValue();
+ return -1;
}
/**
@@ -1180,7 +1184,9 @@ public class JOptionPane extends JComponent implements Accessible
startModal(frame);
- return ((Integer) pane.getValue()).intValue();
+ if (pane.getValue() instanceof Integer)
+ return ((Integer) pane.getValue()).intValue();
+ return -1;
}
/**
@@ -1208,7 +1214,9 @@ public class JOptionPane extends JComponent implements Accessible
startModal(frame);
- return ((Integer) pane.getValue()).intValue();
+ if (pane.getValue() instanceof Integer)
+ return ((Integer) pane.getValue()).intValue();
+ return -1;
}
/**
@@ -1230,7 +1238,7 @@ public class JOptionPane extends JComponent implements Accessible
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
startModal(frame);
-
+
return (String) pane.getInputValue();
}
@@ -1256,7 +1264,7 @@ public class JOptionPane extends JComponent implements Accessible
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame);
-
+
return (String) pane.getInputValue();
}
@@ -1291,8 +1299,8 @@ public class JOptionPane extends JComponent implements Accessible
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame);
-
- return (String) pane.getInputValue();
+
+ return pane.getInputValue();
}
/**
@@ -1384,8 +1392,10 @@ public class JOptionPane extends JComponent implements Accessible
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame);
-
- return ((Integer) pane.getValue()).intValue();
+
+ if (pane.getValue() instanceof Integer)
+ return ((Integer) pane.getValue()).intValue();
+ return -1;
}
/**
@@ -1400,7 +1410,7 @@ public class JOptionPane extends JComponent implements Accessible
JOptionPane pane = new JOptionPane(message, INFORMATION_MESSAGE);
JDialog dialog = pane.createDialog(parentComponent, null);
dialog.pack();
- dialog.show();
+ dialog.show();
}
/**
@@ -1472,7 +1482,9 @@ public class JOptionPane extends JComponent implements Accessible
dialog.pack();
dialog.show();
- return ((Integer) pane.getValue()).intValue();
+ if (pane.getValue() instanceof Integer)
+ return ((Integer) pane.getValue()).intValue();
+ return -1;
}
/**
@@ -1532,34 +1544,34 @@ public class JOptionPane extends JComponent implements Accessible
* JInternalFrame's preferred size.
*
* @param f The JInternalFrame to make modal.
- * @param pane The JOptionPane to add to the JInternalFrame.
*/
private static void startModal(JInternalFrame f)
{
synchronized (f)
- {
- final JInternalFrame tmp = f;
- tmp.toFront();
-
- f.addInternalFrameListener(new InternalFrameAdapter()
- {
- public void internalFrameClosed(InternalFrameEvent e)
- {
- synchronized (tmp)
- {
- tmp.removeInternalFrameListener(this);
- tmp.notifyAll();
- }
- }
- });
- try
- {
- while (! f.isClosed())
- f.wait();
- }
- catch (InterruptedException ignored)
- {
- }
- }
+ {
+ final JInternalFrame tmp = f;
+ tmp.toFront();
+
+ f.addInternalFrameListener(new InternalFrameAdapter()
+ {
+ public void internalFrameClosed(InternalFrameEvent e)
+ {
+ synchronized (tmp)
+ {
+ tmp.removeInternalFrameListener(this);
+ tmp.notifyAll();
+ }
+ }
+ });
+ try
+ {
+ while (! f.isClosed())
+ f.wait();
+ }
+ catch (InterruptedException ignored)
+ {
+ // Ignore this Exception.
+ }
+ }
}
}
diff --git a/javax/swing/JPanel.java b/javax/swing/JPanel.java
index daf3ce61e..7805e92b6 100644
--- a/javax/swing/JPanel.java
+++ b/javax/swing/JPanel.java
@@ -80,11 +80,6 @@ public class JPanel extends JComponent implements Accessible
}
}
- /**
- * The accessible context for this <code>JPanel</code>.
- */
- AccessibleContext accessibleContext;
-
public JPanel()
{
this(new FlowLayout(), true);
diff --git a/javax/swing/JPasswordField.java b/javax/swing/JPasswordField.java
index 151d2484a..11e45e8a5 100644
--- a/javax/swing/JPasswordField.java
+++ b/javax/swing/JPasswordField.java
@@ -67,6 +67,7 @@ public class JPasswordField extends JTextField
*/
protected AccessibleJPasswordField()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JPopupMenu.java b/javax/swing/JPopupMenu.java
index 18da20afa..1f2282e23 100644
--- a/javax/swing/JPopupMenu.java
+++ b/javax/swing/JPopupMenu.java
@@ -39,19 +39,13 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
-import java.awt.Container;
import java.awt.Dimension;
-import java.awt.GridBagConstraints;
import java.awt.Insets;
-import java.awt.Panel;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.EventListener;
@@ -102,11 +96,11 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
1. if DefaultLightWeightPopupEnabled true
(i) use lightweight container if popup feets inside top-level window
- (ii) only use heavyweight container (JWindow) if popup doesn't fit.
+ (ii) only use heavyweight container (JDialog) if popup doesn't fit.
2. if DefaultLightWeightPopupEnabled false
(i) if popup fits, use awt.Panel (mediumWeight)
- (ii) if popup doesn't fit, use JWindow (heavyWeight)
+ (ii) if popup doesn't fit, use JDialog (heavyWeight)
*/
private static boolean DefaultLightWeightPopupEnabled = true;
@@ -130,8 +124,15 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
/* Popup that is used to display JPopupMenu */
private transient Popup popup;
- /* Location of the popup */
- private Point popupLocation;
+ /**
+ * Location of the popup, X coordinate.
+ */
+ private int popupLocationX;
+
+ /**
+ * Location of the popup, Y coordinate.
+ */
+ private int popupLocationY;
/* Field indicating if popup menu is visible or not */
private boolean visible = false;
@@ -158,15 +159,6 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
updateUI();
}
- private void readObject(ObjectInputStream stream)
- throws IOException, ClassNotFoundException
- {
- }
-
- private void writeObject(ObjectOutputStream stream) throws IOException
- {
- }
-
/**
* Adds given menu item to the popup menu
*
@@ -220,19 +212,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
public void remove(int index)
{
super.remove(index);
-
- GridBagConstraints constraints = new GridBagConstraints();
- constraints.fill = GridBagConstraints.BOTH;
- constraints.weightx = 100.0;
- constraints.weighty = 100.0;
-
- Component[] items = getComponents();
- for (int i = index; i < items.length; i++)
- {
- constraints.gridy = i;
- super.add(items[i], constraints, i);
- }
- this.setSize(this.getPreferredSize());
+ revalidate();
}
/**
@@ -257,27 +237,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public void insert(Component component, int index)
{
- GridBagConstraints constraints = new GridBagConstraints();
- constraints.fill = GridBagConstraints.BOTH;
- constraints.weightx = 100.0;
- constraints.weighty = 100.0;
-
- constraints.gridy = index;
- super.add(component, constraints, index);
-
- // need to change constraints for the components that were moved by 1
- // due to the insertion
- if (index != -1)
- {
- Component[] items = getComponents();
-
- for (int i = index + 1; i < items.length; i++)
- {
- constraints.gridy = i;
- super.add(items[i], constraints, i);
- }
- }
- this.setSize(this.getPreferredSize());
+ super.add(component, index);
}
/**
@@ -527,7 +487,20 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public void pack()
{
- super.setSize(null);
+ // Hook up this call so that it gets executed on the event thread in order
+ // to avoid synchronization problems when calling the layout manager.
+ if (! SwingUtilities.isEventDispatchThread())
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ show();
+ }
+ });
+ }
+
+ setSize(getPreferredSize());
}
/**
@@ -547,8 +520,21 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*
* @param visible true if popup menu will become visible and false otherwise.
*/
- public void setVisible(boolean visible)
+ public void setVisible(final boolean visible)
{
+ // Hook up this call so that it gets executed on the event thread in order
+ // to avoid synchronization problems when calling the layout manager.
+ if (! SwingUtilities.isEventDispatchThread())
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ setVisible(visible);
+ }
+ });
+ }
+
if (visible == isVisible())
return;
@@ -560,62 +546,11 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
if (visible)
{
firePopupMenuWillBecomeVisible();
- Container rootContainer = (Container) SwingUtilities.getRoot(invoker);
- Dimension screenSize = getToolkit().getScreenSize();
-
- boolean fit = true;
- Dimension size;
-
- // Determine the size of the popup menu
- if (this.getSize().width == 0 && this.getSize().width == 0)
- size = this.getPreferredSize();
- else
- size = this.getSize();
-
- if ((size.width > (rootContainer.getWidth() - popupLocation.x))
- || (size.height > (rootContainer.getHeight() - popupLocation.y)))
- fit = false;
- if (lightWeightPopupEnabled && fit)
- popup = new LightWeightPopup(this);
- else
- {
- if (fit)
- popup = new MediumWeightPopup(this);
- else
- popup = new HeavyWeightPopup(this);
- }
- if (popup instanceof LightWeightPopup
- || popup instanceof MediumWeightPopup)
- {
- JLayeredPane layeredPane;
- layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
- Point p = new Point(popupLocation.x, popupLocation.y);
-
- if (layeredPane.isShowing())
- SwingUtilities.convertPointFromScreen(p, layeredPane);
-
- if (size.width + popupLocation.x > screenSize.width)
- popupLocation.x -= size.width;
- if (size.height + popupLocation.y > screenSize.height)
- popupLocation.y -= size.height;
-
- popup.show(p.x, p.y, size.width, size.height);
- }
- else
- {
- // Subtract insets of the top-level container if popup menu's
- // top-left corner is inside it.
- Insets insets = rootContainer.getInsets();
-
- if (size.width + popupLocation.x > screenSize.width)
- popupLocation.x -= size.width;
- if (size.height + popupLocation.y > screenSize.height)
- popupLocation.y -= size.height;
-
- popup.show(popupLocation.x - insets.left,
- popupLocation.y - insets.top,
- size.width, size.height);
- }
+
+ PopupFactory pf = PopupFactory.getSharedInstance();
+ pack();
+ popup = pf.getPopup(invoker, this, popupLocationX, popupLocationY);
+ popup.show();
}
else
{
@@ -633,11 +568,11 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public void setLocation(int x, int y)
{
- if (popupLocation == null)
- popupLocation = new Point();
-
- popupLocation.x = x;
- popupLocation.y = y;
+ popupLocationX = x;
+ popupLocationY = y;
+ // Handle the case when the popup is already showing. In this case we need
+ // to fetch a new popup from PopupFactory and use this. See the general
+ // contract of the PopupFactory.
}
/**
@@ -899,164 +834,13 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
}
/**
- * This interface is used to display menu items of the JPopupMenu
- */
- private interface Popup
- {
- /**
- * Displays container on the screen
- *
- * @param x x-coordinate of popup menu's location on the screen
- * @param y y-coordinate of popup menu's location on the screen
- * @param width width of the container that is used to display menu
- * item's for popup menu
- * @param height height of the container that is used to display menu
- * item's for popup menu
- */
- void show(int x, int y, int width, int height);
-
- /**
- * Hides container used to display popup menu item's from the screen
- */
- void hide();
- }
-
- /**
- * This class represents Popup menu that uses light weight container
- * to display its contents.
- */
- private class LightWeightPopup extends Container implements Popup
- {
- private Component c;
-
- /**
- * Creates a new LightWeightPopup menu
- *
- * @param c Container containing menu items
- */
- public LightWeightPopup(Container c)
- {
- this.c = c;
- }
-
- /**
- * Displayes lightweight container with menu items to the screen
- *
- * @param x x-coordinate of lightweight container on the screen
- * @param y y-coordinate of lightweight container on the screen
- * @param width width of the lightweight container
- * @param height height of the lightweight container
- */
- public void show(int x, int y, int width, int height)
- {
- JLayeredPane layeredPane;
- layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
- c.setBounds(x, y, width, height);
- layeredPane.add(c, JLayeredPane.POPUP_LAYER, 0);
- }
-
- /**
- * Hides lightweight container from the screen
- */
- public void hide()
- {
- // FIXME: Right now the lightweight container is removed from JLayered
- // pane. It is probably would be better in order to improve performance
- // to make the container invisible instead of removing it everytime.
- JLayeredPane layeredPane;
- layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
- int index = layeredPane.getIndexOf(c);
- layeredPane.remove(index);
- }
- }
-
- /**
- * MediumWeightPopup is an AWT Panel with JPopupMenu's menu items.
- * It is used to display JPopupMenu's menu items on the screen
- */
- private class MediumWeightPopup extends Panel implements Popup
- {
- /**
- * Creates a new MediumWeightPopup object.
- *
- * @param c Container with JPopupMenu's menu items
- */
- public MediumWeightPopup(Container c)
- {
- this.add(c);
- }
-
- /**
- * Displays AWT Panel with its components on the screen
- *
- * @param x x-coordinate of the upper-left corner of the panel's
- * @param y y-coordinate of the upper-left corner of the panel's
- * @param width width of the panel
- * @param height height of the panel
- */
- public void show(int x, int y, int width, int height)
- {
- JLayeredPane layeredPane;
- layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
- layeredPane.add(this, JLayeredPane.POPUP_LAYER, 0);
- this.setBounds(x, y, width, height);
- }
-
- /**
- * Hides This panel from the screen
- */
- public void hide()
- {
- // FIXME: Right now the lightweight container is removed from JLayered
- // pane. It is probably would be better in order to improve performance
- // to make the container invisible instead of removing it everytime.
- JLayeredPane layeredPane;
- layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
- int index = layeredPane.getIndexOf(this);
- layeredPane.remove(index);
- }
- }
-
- /**
- * HeavyWeightPopup is JWindow that is used to display JPopupMenu menu item's
- * on the screen
- */
- private class HeavyWeightPopup extends JDialog implements Popup
- {
- /**
- * Creates a new HeavyWeightPopup object.
- *
- * @param c Container containing menu items
- */
- public HeavyWeightPopup(Container c)
- {
- this.setContentPane(c);
- this.setUndecorated(true);
- this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
- }
-
- /**
- * Displays JWindow container JPopupMenu's menu items to the screen
- *
- * @param x x-coordinate of JWindow containing menu items
- * @param y y-coordinate of JWindow containing menu items
- * @param width width of the JWindow
- * @param height height of the JWindow
- */
- public void show(int x, int y, int width, int height)
- {
- this.setBounds(x, y, width, height);
- this.show();
- }
- }
-
- /**
* This is the separator that can be used in popup menu.
*/
public static class Separator extends JSeparator
{
public Separator()
{
+ super();
}
public String getUIClassID()
@@ -1071,6 +855,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
protected AccessibleJPopupMenu()
{
+ // Nothing to do here.
}
public AccessibleRole getAccessibleRole()
@@ -1085,8 +870,9 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
{
public void propertyChange(PropertyChangeEvent evt)
{
- JPopupMenu.this.revalidate();
- JPopupMenu.this.repaint();
+ // We used to have a revalidate() and repaint() call here. However I think
+ // this is not needed. Instead, a new Popup has to be fetched from the
+ // PopupFactory and used here.
}
}
}
diff --git a/javax/swing/JProgressBar.java b/javax/swing/JProgressBar.java
index 19815dbfd..0de9115dc 100644
--- a/javax/swing/JProgressBar.java
+++ b/javax/swing/JProgressBar.java
@@ -81,6 +81,8 @@ public class JProgressBar extends JComponent implements SwingConstants,
/**
* AccessibleJProgressBar
*/
+ // FIXME: This inner class is a complete stub and needs to be implemented
+ // properly.
protected class AccessibleJProgressBar extends AccessibleJComponent
implements AccessibleValue
{
@@ -91,6 +93,7 @@ public class JProgressBar extends JComponent implements SwingConstants,
*/
protected AccessibleJProgressBar()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JRadioButton.java b/javax/swing/JRadioButton.java
index 66f5902e8..e0593f3a5 100644
--- a/javax/swing/JRadioButton.java
+++ b/javax/swing/JRadioButton.java
@@ -192,8 +192,8 @@ public class JRadioButton extends JToggleButton
public JRadioButton(String text, Icon icon, boolean selected)
{
super(text, icon, selected);
- borderPainted = false;
- contentAreaFilled = false;
+ setBorderPainted(false);
+ setHorizontalAlignment(LEADING);
}
/**
diff --git a/javax/swing/JRadioButtonMenuItem.java b/javax/swing/JRadioButtonMenuItem.java
index 76a8fef64..61a8dbab3 100644
--- a/javax/swing/JRadioButtonMenuItem.java
+++ b/javax/swing/JRadioButtonMenuItem.java
@@ -38,9 +38,6 @@ exception statement from your version. */
package javax.swing;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@@ -149,10 +146,6 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
model.setSelected(selected);
}
- private void writeObject(ObjectOutputStream stream) throws IOException
- {
- }
-
/**
* This method returns a name to identify which look and feel class will be
* the UI delegate for the menuItem.
@@ -202,6 +195,7 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
*/
protected AccessibleJRadioButtonMenuItem()
{
+ // Nothing to do here.
}
public AccessibleRole getAccessibleRole()
diff --git a/javax/swing/JRootPane.java b/javax/swing/JRootPane.java
index 500083612..b5d436d7e 100644
--- a/javax/swing/JRootPane.java
+++ b/javax/swing/JRootPane.java
@@ -76,6 +76,7 @@ public class JRootPane extends JComponent implements Accessible
*/
protected AccessibleJRootPane()
{
+ // Nothing to do here.
}
/**
@@ -101,6 +102,7 @@ public class JRootPane extends JComponent implements Accessible
*/
protected RootLayout()
{
+ // Nothing to do here.
}
/**
@@ -111,6 +113,7 @@ public class JRootPane extends JComponent implements Accessible
*/
public void addLayoutComponent(Component comp, Object constraints)
{
+ // Nothing to do here.
}
/**
@@ -121,6 +124,7 @@ public class JRootPane extends JComponent implements Accessible
*/
public void addLayoutComponent(String name, Component comp)
{
+ // Nothing to do here.
}
/**
@@ -154,6 +158,7 @@ public class JRootPane extends JComponent implements Accessible
*/
public void invalidateLayout(Container target)
{
+ // Nothing to do here.
}
/**
@@ -309,6 +314,7 @@ public class JRootPane extends JComponent implements Accessible
*/
public void removeLayoutComponent(Component comp)
{
+ // Nothing to do here.
}
}
@@ -340,6 +346,32 @@ public class JRootPane extends JComponent implements Accessible
protected JButton defaultButton;
/**
+ * This field is unused since JDK1.3. To override the default action you
+ * should modify the JRootPane's ActionMap.
+ *
+ * @deprecated since JDK1.3
+ *
+ * @specnote the specs indicate that the type of this field is
+ * a package private inner class
+ * javax.swing.JRootPane.DefaultAction. I assume that the closest
+ * public superclass is javax.swing.Action.
+ */
+ protected Action defaultPressAction;
+
+ /**
+ * This field is unused since JDK1.3. To override the default action you
+ * should modify the JRootPane's ActionMap.
+ *
+ * @deprecated since JDK1.3
+ *
+ * @specnote the specs indicate that the type of this field is
+ * a package private inner class
+ * javax.swing.JRootPane.DefaultAction. I assume that the closest
+ * public superclass is javax.swing.Action.
+ */
+ protected Action defaultReleaseAction;
+
+ /**
* @since 1.4
*/
private int windowDecorationStyle = NONE;
@@ -504,7 +536,6 @@ public class JRootPane extends JComponent implements Accessible
getGlassPane();
getLayeredPane();
getContentPane();
- setDoubleBuffered(true);
updateUI();
}
diff --git a/javax/swing/JScrollPane.java b/javax/swing/JScrollPane.java
index 42d8ea76f..45dfbf506 100644
--- a/javax/swing/JScrollPane.java
+++ b/javax/swing/JScrollPane.java
@@ -40,13 +40,14 @@ package javax.swing;
import java.awt.Component;
import java.awt.ComponentOrientation;
-import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
-import java.awt.Point;
import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -77,10 +78,73 @@ import javax.swing.plaf.UIResource;
* <tr><td>wheelScrollingEnabled </td><td>scrollPane </td><td>yes </td></tr>
* </table>
*/
-public class JScrollPane
- extends JComponent
+public class JScrollPane extends JComponent
implements Accessible, ScrollPaneConstants
{
+ /**
+ * Provides accessibility support for the <code>JScrollPane</code>.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class AccessibleJScrollPane extends AccessibleJComponent
+ implements ChangeListener, PropertyChangeListener
+ {
+
+ /**
+ * The viewport of the underlying scrollpane.
+ */
+ protected JViewport viewPort;
+
+ /**
+ * Creates a new <code>AccessibleJScrollPane</code> object. This
+ * initializes the <code>viewport</code> field with the current viewport
+ * from the scrollpane associated with this
+ * <code>AccessibleJScrollPane</code>.
+ */
+ public AccessibleJScrollPane()
+ {
+ viewPort = getViewport();
+ viewPort.addChangeListener(this);
+ viewPort.addPropertyChangeListener(this);
+ }
+
+ /**
+ * Receives notification when the state of the viewport changes.
+ *
+ * @param event the change event
+ */
+ public void stateChanged(ChangeEvent event)
+ {
+ // TODO: Figure out what should be done here, if anything.
+ }
+
+ /**
+ * Receives notification if any of the viewport's bound properties changes.
+ *
+ * @param e the propery change event
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ // TODO: Figure out what should be done here, if anything.
+ }
+
+ /**
+ * Resets the <code>viewPort</code> field when the scrollpane's viewport
+ * changes. This method is called by
+ * {@link JScrollPane#setViewport(JViewport)} in order to update the
+ * <code>viewPort</code> field and set up the listeners on this viewport
+ * correctly.
+ */
+ public void resetViewPort()
+ {
+ viewPort.removeChangeListener(this);
+ viewPort.removePropertyChangeListener(this);
+ viewPort = getViewport();
+ viewPort.addChangeListener(this);
+ viewPort.addPropertyChangeListener(this);
+ }
+ }
+
private static final long serialVersionUID = 5203525440012340014L;
protected JViewport columnHeader;
@@ -100,7 +164,6 @@ public class JScrollPane
Border viewportBorder;
boolean wheelScrollingEnabled;
- ChangeListener scrollListener;
public JViewport getColumnHeader()
{
@@ -331,18 +394,6 @@ public class JScrollPane
firePropertyChange("horizontalScrollBar", old, h);
sync();
- if (old != null)
- {
- BoundedRangeModel model = old.getModel();
- if (model != null)
- model.removeChangeListener(scrollListener);
- }
- if (h != null)
- {
- BoundedRangeModel model = h.getModel();
- if (model != null)
- model.addChangeListener(scrollListener);
- }
}
public void setHorizontalScrollBarPolicy(int h)
@@ -359,6 +410,7 @@ public class JScrollPane
horizontalScrollBarPolicy = h;
firePropertyChange("horizontalScrollBarPolicy", old, h);
sync();
+ revalidate();
}
public void setLayout(LayoutManager l)
@@ -403,19 +455,6 @@ public class JScrollPane
addNonNull(v, JScrollPane.VERTICAL_SCROLLBAR);
firePropertyChange("verticalScrollBar", old, v);
sync();
-
- if (old != null)
- {
- BoundedRangeModel model = old.getModel();
- if (model != null)
- model.removeChangeListener(scrollListener);
- }
- if (v != null)
- {
- BoundedRangeModel model = v.getModel();
- if (model != null)
- model.addChangeListener(scrollListener);
- }
}
public void setVerticalScrollBarPolicy(int v)
@@ -432,6 +471,7 @@ public class JScrollPane
verticalScrollBarPolicy = v;
firePropertyChange("verticalScrollBarPolicy", old, v);
sync();
+ revalidate();
}
public void setWheelScrollingEnabled(boolean b)
@@ -452,16 +492,17 @@ public class JScrollPane
JViewport old = viewport;
removeNonNull(old);
- if (old != null)
- old.removeChangeListener(scrollListener);
viewport = v;
- if (v != null)
- v.addChangeListener(scrollListener);
addNonNull(v, JScrollPane.VIEWPORT);
revalidate();
repaint();
firePropertyChange("viewport", old, v);
sync();
+ if (accessibleContext != null)
+ {
+ AccessibleJScrollPane asp = (AccessibleJScrollPane) accessibleContext;
+ asp.resetViewPort();
+ }
}
public void setViewportBorder(Border b)
@@ -494,79 +535,6 @@ public class JScrollPane
return true;
}
- ChangeListener createScrollListener()
- {
- return new ChangeListener()
- {
-
- public void stateChanged(ChangeEvent event)
- {
- JScrollBar vsb = JScrollPane.this.getVerticalScrollBar();
- JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar();
- JViewport vp = JScrollPane.this.getViewport();
-
- if (vp != null && event.getSource() == vp)
- {
- // if the viewport changed, we should update the VSB / HSB
- // models according to the new vertical and horizontal sizes
-
- Rectangle vr = vp.getViewRect();
- Dimension vs = vp.getViewSize();
- if (vsb != null
- && (vsb.getMinimum() != 0
- || vsb.getMaximum() != vs.height
- || vsb.getValue() != vr.y
- || vsb.getVisibleAmount() != vr.height))
- vsb.setValues(vr.y, vr.height, 0, vs.height);
-
- if (hsb != null
- && (hsb.getMinimum() != 0
- || hsb.getMaximum() != vs.width
- || hsb.getValue() != vr.width
- || hsb.getVisibleAmount() != vr.height))
- hsb.setValues(vr.x, vr.width, 0, vs.width);
- }
- else
- {
- // otherwise we got a change update from either the VSB or
- // HSB model, and we need to update the viewport positions of
- // both the main viewport and any row or column headers to
- // match.
-
- int xpos = 0;
- int ypos = 0;
-
- if (vsb != null)
- ypos = vsb.getValue();
-
- if (hsb != null)
- xpos = hsb.getValue();
-
- Point pt = new Point(xpos, ypos);
-
- if (vp != null
- && vp.getViewPosition() != pt)
- vp.setViewPosition(pt);
-
- pt.x = 0;
-
- if (rowHeader != null
- && rowHeader.getViewPosition() != pt)
- rowHeader.setViewPosition(pt);
-
- pt.x = xpos;
- pt.y = 0;
-
- if (columnHeader != null
- && columnHeader.getViewPosition() != pt)
- columnHeader.setViewPosition(pt);
-
- }
- }
- };
- }
-
-
/**
* Creates a new <code>JScrollPane</code> without a view. The scrollbar
* policy is set to {@link #VERTICAL_SCROLLBAR_AS_NEEDED} and
@@ -627,7 +595,6 @@ public class JScrollPane
*/
public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
{
- scrollListener = createScrollListener();
setVerticalScrollBarPolicy(vsbPolicy);
setVerticalScrollBar(createVerticalScrollBar());
setHorizontalScrollBarPolicy(hsbPolicy);
@@ -635,7 +602,6 @@ public class JScrollPane
viewport = createViewport();
if (view != null)
getViewport().setView(view);
- viewport.addChangeListener(scrollListener);
add(viewport,0);
setLayout(new ScrollPaneLayout());
setOpaque(false);
@@ -728,4 +694,18 @@ public class JScrollPane
}
}
}
+
+ /**
+ * Returns the accessible context associated with this
+ * <code>JScrollPane</code>.
+ *
+ * @return the accessible context associated with this
+ * <code>JScrollPane</code>
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJScrollPane();
+ return accessibleContext;
+ }
}
diff --git a/javax/swing/JSeparator.java b/javax/swing/JSeparator.java
index 6a3b97d35..602af6a38 100644
--- a/javax/swing/JSeparator.java
+++ b/javax/swing/JSeparator.java
@@ -62,6 +62,7 @@ public class JSeparator extends JComponent implements SwingConstants,
*/
protected AccessibleJSeparator()
{
+ // Nothing to do here.
}
/**
@@ -131,7 +132,6 @@ public class JSeparator extends JComponent implements SwingConstants,
public void updateUI()
{
setUI((SeparatorUI) UIManager.getUI(this));
- invalidate();
}
/**
diff --git a/javax/swing/JSlider.java b/javax/swing/JSlider.java
index 2caf509a1..b28b06aba 100644
--- a/javax/swing/JSlider.java
+++ b/javax/swing/JSlider.java
@@ -118,6 +118,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
/**
* DOCUMENT ME!
*/
+ // FIXME: This inner class is a complete stub and needs to be implemented
+ // properly.
protected class AccessibleJSlider extends JComponent.AccessibleJComponent
implements AccessibleValue
{
@@ -128,6 +130,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
*/
protected AccessibleJSlider()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JSpinner.java b/javax/swing/JSpinner.java
index fc2b13e81..af34d9cf6 100644
--- a/javax/swing/JSpinner.java
+++ b/javax/swing/JSpinner.java
@@ -108,10 +108,10 @@ public class JSpinner extends JComponent
/**
* DOCUMENT ME!
*/
- public void commitEdit()
- throws ParseException
+ public void commitEdit() throws ParseException
{
- } /* TODO */
+ // TODO: Implement this properly.
+ }
/**
* DOCUMENT ME!
@@ -184,7 +184,8 @@ public class JSpinner extends JComponent
*/
public void propertyChange(PropertyChangeEvent event)
{
- } /* TODO */
+ // TODO: Implement this properly.
+ }
/**
* DOCUMENT ME!
@@ -193,11 +194,12 @@ public class JSpinner extends JComponent
*/
public void stateChanged(ChangeEvent event)
{
- } /* TODO */
+ // TODO: Implement this properly.
+ }
- /* no-ops */
public void removeLayoutComponent(Component child)
{
+ // Nothing to do here.
}
/**
@@ -208,6 +210,7 @@ public class JSpinner extends JComponent
*/
public void addLayoutComponent(String name, Component child)
{
+ // Nothing to do here.
}
}
@@ -258,6 +261,31 @@ public class JSpinner extends JComponent
}
/**
+ * A <code>JSpinner</code> editor used for the {@link SpinnerListModel}.
+ * This editor uses a <code>JFormattedTextField</code> to edit the values
+ * of the spinner.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ public static class ListEditor extends DefaultEditor
+ {
+ /**
+ * Creates a new instance of <code>ListEditor</code>.
+ *
+ * @param spinner the spinner for which this editor is used
+ */
+ public ListEditor(JSpinner spinner)
+ {
+ super(spinner);
+ }
+
+ public SpinnerListModel getModel()
+ {
+ return (SpinnerListModel) getSpinner().getModel();
+ }
+ }
+
+ /**
* An editor class for a <code>JSpinner</code> that is used
* for displaying and editing dates (e.g. that uses
* <code>SpinnerDateModel</code> as model).
@@ -307,7 +335,7 @@ public class JSpinner extends JComponent
/**
* Initializes the JFormattedTextField for this editor.
*
- * @param the date format to use in the formatted text field
+ * @param format the date format to use in the formatted text field
*/
private void init(SimpleDateFormat format)
{
diff --git a/javax/swing/JSplitPane.java b/javax/swing/JSplitPane.java
index cea5afef2..cdab7bb6c 100644
--- a/javax/swing/JSplitPane.java
+++ b/javax/swing/JSplitPane.java
@@ -59,6 +59,8 @@ public class JSplitPane extends JComponent implements Accessible
/**
* DOCUMENT ME!
*/
+ // FIXME: This inner class is a complete stub and must be implemented
+ // properly.
protected class AccessibleJSplitPane extends JComponent.AccessibleJComponent
implements AccessibleValue
{
@@ -69,6 +71,7 @@ public class JSplitPane extends JComponent implements Accessible
*/
protected AccessibleJSplitPane()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JTabbedPane.java b/javax/swing/JTabbedPane.java
index 77e49cba5..8ef1d8f11 100644
--- a/javax/swing/JTabbedPane.java
+++ b/javax/swing/JTabbedPane.java
@@ -75,6 +75,8 @@ public class JTabbedPane extends JComponent implements Serializable,
/**
* Accessibility support for <code>JTabbedPane</code>.
*/
+ // FIXME: This inner class is a complete stub and must be implemented
+ // properly.
protected class AccessibleJTabbedPane extends JComponent.AccessibleJComponent
implements AccessibleSelection, ChangeListener
{
@@ -99,6 +101,7 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void stateChanged(ChangeEvent e)
{
+ // Implement this properly.
}
/**
@@ -208,6 +211,7 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void addAccessibleSelection(int i)
{
+ // TODO: Implement this properly.
}
/**
@@ -217,6 +221,7 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void removeAccessibleSelection(int i)
{
+ // TODO: Implement this properly.
}
/**
@@ -224,6 +229,7 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void clearAccessibleSelection()
{
+ // TODO: Implement this properly.
}
/**
@@ -231,6 +237,7 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void selectAllAccessibleSelection()
{
+ // TODO: Implement this properly.
}
}
@@ -247,6 +254,7 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
protected ModelListener()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index 531838ab1..39673b19c 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -45,8 +45,6 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
@@ -58,6 +56,10 @@ import java.util.Vector;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleExtendedTable;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleTable;
+import javax.accessibility.AccessibleTableModelChange;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
@@ -78,15 +80,414 @@ import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
import javax.swing.text.Caret;
-public class JTable extends JComponent
+public class JTable
+ extends JComponent
implements TableModelListener, Scrollable, TableColumnModelListener,
ListSelectionListener, CellEditorListener, Accessible
{
/**
+ * Provides accessibility support for <code>JTable</code>.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class AccessibleJTable
+ extends AccessibleJComponent
+ implements AccessibleSelection, ListSelectionListener, TableModelListener,
+ TableColumnModelListener, CellEditorListener, PropertyChangeListener,
+ AccessibleExtendedTable
+ {
+
+ protected class AccessibleJTableModelChange
+ implements AccessibleTableModelChange
+ {
+ protected int type;
+ protected int firstRow;
+ protected int lastRow;
+ protected int firstColumn;
+ protected int lastColumn;
+
+ protected AccessibleJTableModelChange(int type, int firstRow,
+ int lastRow, int firstColumn,
+ int lastColumn)
+ {
+ this.type = type;
+ this.firstRow = firstRow;
+ this.lastRow = lastRow;
+ this.firstColumn = firstColumn;
+ this.lastColumn = lastColumn;
+ }
+
+ public int getType()
+ {
+ return type;
+ }
+
+ public int getFirstRow()
+ {
+ return firstRow;
+ }
+
+ public int getLastRow()
+ {
+ return lastRow;
+ }
+
+ public int getFirstColumn()
+ {
+ return firstColumn;
+ }
+
+ public int getLastColumn()
+ {
+ return lastColumn;
+ }
+ }
+
+ /**
+ * Creates a new <code>AccessibleJTable</code>.
+ *
+ * @since JDK1.5
+ */
+ protected AccessibleJTable()
+ {
+ getModel().addTableModelListener(this);
+ getSelectionModel().addListSelectionListener(this);
+ getColumnModel().addColumnModelListener(this);
+ getCellEditor().addCellEditorListener(this);
+ }
+
+ /**
+ * Returns the number of selected items in this table.
+ */
+ public int getAccessibleSelectionCount()
+ {
+ return getSelectedColumnCount();
+ }
+
+ public Accessible getAccessibleSelection(int i)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isAccessibleChildSelected(int i)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void addAccessibleSelection(int i)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeAccessibleSelection(int i)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void clearAccessibleSelection()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void selectAllAccessibleSelection()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void valueChanged(ListSelectionEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Receives notification when the table model changes. Depending on the
+ * type of change, this method calls {@link #tableRowsInserted} or
+ * {@link #tableRowsDeleted}.
+ *
+ * @param event the table model event
+ */
+ public void tableChanged(TableModelEvent event)
+ {
+ switch (event.getType())
+ {
+ case TableModelEvent.INSERT:
+ tableRowsInserted(event);
+ break;
+ case TableModelEvent.DELETE:
+ tableRowsDeleted(event);
+ break;
+ }
+ }
+
+ /**
+ * Receives notification when one or more rows have been inserted into the
+ * table.
+ *
+ * @param event the table model event
+ */
+ public void tableRowsInserted(TableModelEvent event)
+ {
+ // TODO: What to do here, if anything? This might be a hook method for
+ // subclasses...
+ }
+
+ /**
+ * Receives notification when one or more rows have been deleted from the
+ * table.
+ *
+ * @param event the table model event
+ */
+ public void tableRowsDeleted(TableModelEvent event)
+ {
+ // TODO: What to do here, if anything? This might be a hook method for
+ // subclasses...
+ }
+
+ public void columnAdded(TableColumnModelEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void columnMarginChanged(ChangeEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void columnMoved(TableColumnModelEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void columnRemoved(TableColumnModelEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void columnSelectionChanged(ListSelectionEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void editingCanceled(ChangeEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void editingStopped(ChangeEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Receives notification when any of the JTable's properties changes. This
+ * is used to replace the listeners on the table's model, selection model,
+ * column model and cell editor.
+ *
+ * @param e the property change event
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ String propName = e.getPropertyName();
+ if (propName.equals("tableModel"))
+ {
+ TableModel oldModel = (TableModel) e.getOldValue();
+ oldModel.removeTableModelListener(this);
+ TableModel newModel = (TableModel) e.getNewValue();
+ newModel.addTableModelListener(this);
+ }
+ else if (propName.equals("columnModel"))
+ {
+ TableColumnModel oldModel = (TableColumnModel) e.getOldValue();
+ oldModel.removeColumnModelListener(this);
+ TableColumnModel newModel = (TableColumnModel) e.getNewValue();
+ newModel.addColumnModelListener(this);
+ }
+ else if (propName.equals("selectionModel"))
+ {
+ ListSelectionModel oldModel = (ListSelectionModel) e.getOldValue();
+ oldModel.removeListSelectionListener(this);
+ ListSelectionModel newModel = (ListSelectionModel) e.getNewValue();
+ newModel.addListSelectionListener(this);
+ }
+ else if (propName.equals("cellEditor"))
+ {
+ CellEditor oldEd = (CellEditor) e.getOldValue();
+ oldEd.removeCellEditorListener(this);
+ CellEditor newEd = (CellEditor) e.getNewValue();
+ newEd.addCellEditorListener(this);
+ }
+ }
+
+ public int getAccessibleRow(int index)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getAccessibleColumn(int index)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getAccessibleIndex(int r, int c)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Accessible getAccessibleCaption()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAccessibleCaption(Accessible caption)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Accessible getAccessibleSummary()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAccessibleSummary(Accessible summary)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public int getAccessibleRowCount()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getAccessibleColumnCount()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Accessible getAccessibleAt(int r, int c)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getAccessibleRowExtentAt(int r, int c)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getAccessibleColumnExtentAt(int r, int c)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public AccessibleTable getAccessibleRowHeader()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAccessibleRowHeader(AccessibleTable header)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public AccessibleTable getAccessibleColumnHeader()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAccessibleColumnHeader(AccessibleTable header)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Accessible getAccessibleRowDescription(int r)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAccessibleRowDescription(int r, Accessible description)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Accessible getAccessibleColumnDescription(int c)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAccessibleColumnDescription(int c, Accessible description)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isAccessibleSelected(int r, int c)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isAccessibleRowSelected(int r)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isAccessibleColumnSelected(int c)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public int[] getSelectedAccessibleRows()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int[] getSelectedAccessibleColumns()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+ /**
* Handles property changes from the <code>TableColumn</code>s of this
* <code>JTable</code>.
*
- * More specifically, this triggers a {@link #revalidate} call if the
+ * More specifically, this triggers a {@link #revalidate()} call if the
* preferredWidth of one of the observed columns changes.
*/
class TableColumnPropertyChangeHandler implements PropertyChangeListener
@@ -393,7 +794,7 @@ public class JTable extends JComponent
* property when the {@link #dataModel} property is changed.
*
* @see #setModel(TableModel)
- * @see #createColumnsFromModel()
+ * @see #createDefaultColumnsFromModel()
* @see #setColumnModel(TableColumnModel)
* @see #setAutoCreateColumnsFromModel(boolean)
* @see #getAutoCreateColumnsFromModel()
@@ -509,11 +910,6 @@ public class JTable extends JComponent
protected ListSelectionModel selectionModel;
/**
- * The accessibleContext property.
- */
- protected AccessibleContext accessibleContext;
-
- /**
* The current cell editor.
*/
protected TableCellEditor cellEditor;
@@ -521,7 +917,7 @@ public class JTable extends JComponent
/**
* Whether or not drag-and-drop is enabled on this table.
*
- * @see #setDragEnabled()
+ * @see #setDragEnabled(boolean)
* @see #getDragEnabled()
*/
private boolean dragEnabled;
@@ -678,24 +1074,28 @@ public class JTable extends JComponent
*/
public JTable (TableModel dm, TableColumnModel cm, ListSelectionModel sm)
{
- setModel(dm == null ? createDefaultDataModel() : dm);
- setSelectionModel(sm == null ? createDefaultSelectionModel() : sm);
-
+ boolean autoCreate = false;
if (cm != null)
- {
setColumnModel(cm);
- setAutoCreateColumnsFromModel(false);
- }
else
{
setColumnModel(createDefaultColumnModel());
- setAutoCreateColumnsFromModel(true);
- }
+ autoCreate = true;
+ }
+ setSelectionModel(sm == null ? createDefaultSelectionModel() : sm);
+ setModel(dm == null ? createDefaultDataModel() : dm);
+ setAutoCreateColumnsFromModel(autoCreate);
initializeLocalVars();
- // The next two lines are for compliance with the JDK which starts
- // the JLists associated with a JTable with both lead selection
- // indices at 0, rather than -1 as in regular JLists
+ // The following four lines properly set the lead selection indices.
+ // After this, the UI will handle the lead selection indices.
+ // FIXME: this should probably not be necessary, if the UI is installed
+ // before the TableModel is set then the UI will handle things on its
+ // own, but certain variables need to be set before the UI can be installed
+ // so we must get the correct order for all the method calls in this
+ // constructor.
+ selectionModel.setAnchorSelectionIndex(0);
selectionModel.setLeadSelectionIndex(0);
+ columnModel.getSelectionModel().setAnchorSelectionIndex(0);
columnModel.getSelectionModel().setLeadSelectionIndex(0);
updateUI();
}
@@ -919,6 +1319,12 @@ public class JTable extends JComponent
createDefaultColumnsFromModel();
+ // If the structure changes, we need to revalidate, since that might
+ // affect the size parameters of the JTable. Otherwise we only need
+ // to perform a repaint to update the view.
+ if (event.getType() == TableModelEvent.INSERT
+ || event.getType() == TableModelEvent.DELETE)
+ revalidate();
repaint();
}
@@ -971,8 +1377,7 @@ public class JTable extends JComponent
{
int y0 = getLocation().y;
int nrows = getRowCount();
- Dimension gap = getIntercellSpacing();
- int height = getRowHeight() + (gap == null ? 0 : gap.height);
+ int height = getRowHeight();
int y = point.y;
for (int i = 0; i < nrows; ++i)
@@ -1093,13 +1498,14 @@ public class JTable extends JComponent
// scroll direction.
if (orientation == SwingConstants.VERTICAL)
- return rowHeight;
+ return direction * rowHeight;
else
{
int sum = 0;
for (int i = 0; i < getColumnCount(); ++i)
sum += columnModel.getColumn(0).getWidth();
- return getColumnCount() == 0 ? 10 : sum / getColumnCount();
+ int inc = getColumnCount() == 0 ? 10 : sum / getColumnCount();
+ return direction * inc;
}
}
@@ -1680,7 +2086,9 @@ public class JTable extends JComponent
// Don't do anything if setting the current model again.
if (dataModel == m)
return;
-
+
+ TableModel oldModel = dataModel;
+
// Remove table as TableModelListener from old model.
if (dataModel != null)
dataModel.removeTableModelListener(this);
@@ -1697,7 +2105,10 @@ public class JTable extends JComponent
if (autoCreateColumnsFromModel)
createDefaultColumnsFromModel();
}
-
+
+ // This property is bound, so we fire a property change event.
+ firePropertyChange("model", oldModel, dataModel);
+
// Repaint table.
revalidate();
repaint();
@@ -1983,7 +2394,8 @@ public class JTable extends JComponent
int average = spill / cols.length;
for (int i = 0; i < cols.length; i++)
{
- cols[i].setWidth(cols[i].getWidth() + average);
+ if (cols[i] != null)
+ cols[i].setWidth(cols[i].getWidth() + average);
}
}
@@ -2402,4 +2814,13 @@ public class JTable extends JComponent
return editor.getTableCellEditorComponent
(this, getValueAt(row, column), isCellSelected(row, column), row, column);
}
+
+ /**
+ * This revalidates the <code>JTable</code> and queues a repaint.
+ */
+ protected void resizeAndRepaint()
+ {
+ revalidate();
+ repaint();
+ }
}
diff --git a/javax/swing/JTextArea.java b/javax/swing/JTextArea.java
index e2157bcc6..2fa185b62 100644
--- a/javax/swing/JTextArea.java
+++ b/javax/swing/JTextArea.java
@@ -42,6 +42,8 @@ import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Rectangle;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleStateSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Element;
@@ -92,6 +94,35 @@ import javax.swing.text.View;
public class JTextArea extends JTextComponent
{
/**
+ * Provides accessibility support for <code>JTextArea</code>.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class AccessibleJTextArea extends AccessibleJTextComponent
+ {
+
+ /**
+ * Creates a new <code>AccessibleJTextArea</code> object.
+ */
+ protected AccessibleJTextArea()
+ {
+ super();
+ }
+
+ /**
+ * Returns the accessible state of this <code>AccessibleJTextArea</code>.
+ *
+ * @return the accessible state of this <code>AccessibleJTextArea</code>
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet state = super.getAccessibleStateSet();
+ // TODO: Figure out what state must be added here to the super's state.
+ return state;
+ }
+ }
+
+ /**
* Compatible with Sun's JDK
*/
private static final long serialVersionUID = -6141680179310439825L;
@@ -557,4 +588,16 @@ public class JTextArea extends JTextComponent
return new Dimension(Math.max(reqWidth, neededWidth),
Math.max(reqHeight, neededHeight));
}
+
+ /**
+ * Returns the accessible context associated with the <code>JTextArea</code>.
+ *
+ * @return the accessible context associated with the <code>JTextArea</code>
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJTextArea();
+ return accessibleContext;
+ }
}
diff --git a/javax/swing/JTextField.java b/javax/swing/JTextField.java
index 5ae9c9f1a..845edc001 100644
--- a/javax/swing/JTextField.java
+++ b/javax/swing/JTextField.java
@@ -46,9 +46,8 @@ import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleStateSet;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument;
@@ -69,15 +68,19 @@ public class JTextField extends JTextComponent
*/
protected AccessibleJTextField()
{
+ super();
}
/**
- * getAccessibleStateSet
- * @return AccessibleStateSet
+ * Returns the accessible state of this <code>AccessibleJTextField</code>.
+ *
+ * @return the accessible state of this <code>AccessibleJTextField</code>
*/
public AccessibleStateSet getAccessibleStateSet()
{
- return null;
+ AccessibleStateSet state = super.getAccessibleStateSet();
+ // TODO: Figure out what state must be added here to the super's state.
+ return state;
}
}
@@ -92,17 +95,17 @@ public class JTextField extends JTextComponent
public static final String notifyAction = "notify-field-accept";
static
- {
- actions = new Action[1];
- actions[0] = new TextAction(notifyAction)
+ {
+ actions = new Action[1];
+ actions[0] = new TextAction(notifyAction)
{
- public void actionPerformed(ActionEvent event)
- {
- JTextField textField = (JTextField) event.getSource();
- textField.fireActionPerformed();
- }
+ public void actionPerformed(ActionEvent event)
+ {
+ JTextField textField = (JTextField) event.getSource();
+ textField.fireActionPerformed();
+ }
};
- }
+ }
private int columns;
private int align;
@@ -117,6 +120,11 @@ public class JTextField extends JTextComponent
private PropertyChangeListener actionPropertyChangeListener;
/**
+ * The horizontal visibility of the textfield.
+ */
+ private BoundedRangeModel horizontalVisibility;
+
+ /**
* Creates a new instance of <code>JTextField</code>.
*/
public JTextField()
@@ -172,9 +180,9 @@ public class JTextField extends JTextComponent
{
if (columns < 0)
throw new IllegalArgumentException();
-
+
this.columns = columns;
-
+
setDocument(doc == null ? createDefaultModel() : doc);
if (text != null)
@@ -182,6 +190,9 @@ public class JTextField extends JTextComponent
// default value for alignment
align = LEADING;
+
+ // Initialize the horizontal visibility model.
+ horizontalVisibility = new DefaultBoundedRangeModel();
}
/**
@@ -192,15 +203,7 @@ public class JTextField extends JTextComponent
*/
protected Document createDefaultModel()
{
- // subclassed to swallow newlines
- return new PlainDocument() {
- public void insertString(int offset, String str, AttributeSet a)
- throws BadLocationException
- {
- if (str != null && str.indexOf('\n') == -1)
- super.insertString(offset, str, a);
- }
- };
+ return new PlainDocument();
}
/**
@@ -268,6 +271,11 @@ public class JTextField extends JTextComponent
return columns;
}
+ /**
+ * Sets the number of columns and then invalidates the layout.
+ * @param columns the number of columns
+ * @throws IllegalArgumentException if columns < 0
+ */
public void setColumns(int columns)
{
if (columns < 0)
@@ -275,16 +283,31 @@ public class JTextField extends JTextComponent
this.columns = columns;
invalidate();
+ //FIXME: do we need this repaint call?
repaint();
}
+ /**
+ * Returns the horizontal alignment, which is one of: JTextField.LEFT,
+ * JTextField.CENTER, JTextField.RIGHT, JTextField.LEADING,
+ * JTextField.TRAILING.
+ * @return the horizontal alignment
+ */
public int getHorizontalAlignment()
{
return align;
}
+ /**
+ * Sets the horizontal alignment of the text. Calls invalidate and repaint
+ * and fires a property change event.
+ * @param newAlign must be one of: JTextField.LEFT, JTextField.CENTER,
+ * JTextField.RIGHT, JTextField.LEADING, JTextField.TRAILING.
+ * @throws IllegalArgumentException if newAlign is not one of the above.
+ */
public void setHorizontalAlignment(int newAlign)
{
+ //FIXME: should throw an IllegalArgumentException if newAlign is invalid
if (align == newAlign)
return;
@@ -295,12 +318,20 @@ public class JTextField extends JTextComponent
repaint();
}
+ /**
+ * Sets the current font and revalidates so the font will take effect.
+ */
public void setFont(Font newFont)
{
super.setFont(newFont);
revalidate();
}
+ /**
+ * Returns the preferred size. If there is a non-zero number of columns,
+ * this is the number of columns multiplied by the column width, otherwise
+ * it returns super.getPreferredSize().
+ */
public Dimension getPreferredSize()
{
Dimension size = super.getPreferredSize();
@@ -318,6 +349,7 @@ public class JTextField extends JTextComponent
*/
public int getScrollOffset()
{
+ //FIXME: this should return horizontalVisibility's value
return scrollOffset;
}
@@ -328,9 +360,15 @@ public class JTextField extends JTextComponent
*/
public void setScrollOffset(int offset)
{
+ //FIXME: this should actualy scroll the field if needed
scrollOffset = offset;
}
+ /**
+ * Returns the set of Actions that are commands for the editor.
+ * This is the actions supported by this editor plus the actions
+ * of the UI (returned by JTextComponent.getActions()).
+ */
public Action[] getActions()
{
return TextAction.augmentList(super.getActions(), actions);
@@ -364,26 +402,27 @@ public class JTextField extends JTextComponent
if (action != null)
{
- removeActionListener(action);
- action.removePropertyChangeListener(actionPropertyChangeListener);
- actionPropertyChangeListener = null;
+ removeActionListener(action);
+ action.removePropertyChangeListener(actionPropertyChangeListener);
+ actionPropertyChangeListener = null;
}
-
+
Action oldAction = action;
action = newAction;
if (action != null)
{
- addActionListener(action);
- actionPropertyChangeListener =
- createActionPropertyChangeListener(action);
- action.addPropertyChangeListener(actionPropertyChangeListener);
+ addActionListener(action);
+ actionPropertyChangeListener = createActionPropertyChangeListener(action);
+ action.addPropertyChangeListener(actionPropertyChangeListener);
}
-
+
+ //FIXME: is this a hack? The horizontal alignment hasn't changed
firePropertyChange("horizontalAlignment", oldAction, newAction);
}
/**
+ * Sets the command string used in action events.
* @since 1.3
*/
public void setActionCommand(String command)
@@ -397,45 +436,79 @@ public class JTextField extends JTextComponent
protected PropertyChangeListener createActionPropertyChangeListener(Action action)
{
return new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent event)
{
- public void propertyChange(PropertyChangeEvent event)
- {
- // Update properties "action" and "horizontalAlignment".
- String name = event.getPropertyName();
-
- if (name.equals("enabled"))
- {
- boolean enabled = ((Boolean) event.getNewValue()).booleanValue();
- JTextField.this.setEnabled(enabled);
- }
- else if (name.equals(Action.SHORT_DESCRIPTION))
- {
- JTextField.this.setToolTipText((String) event.getNewValue());
- }
- }
- };
+ // Update properties "action" and "horizontalAlignment".
+ String name = event.getPropertyName();
+
+ if (name.equals("enabled"))
+ {
+ boolean enabled = ((Boolean) event.getNewValue()).booleanValue();
+ JTextField.this.setEnabled(enabled);
+ }
+ else if (name.equals(Action.SHORT_DESCRIPTION))
+ {
+ JTextField.this.setToolTipText((String) event.getNewValue());
+ }
+ }
+ };
}
/**
+ *
* @since 1.3
*/
protected void configurePropertiesFromAction(Action action)
{
if (action != null)
{
- setEnabled(action.isEnabled());
- setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
+ setEnabled(action.isEnabled());
+ setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
}
else
{
- setEnabled(true);
- setToolTipText(null);
+ setEnabled(true);
+ setToolTipText(null);
}
}
+ /**
+ * Returns the column width, which is the width of the character m
+ * for the font in use.
+ * @return the width of the character m for the font in use.
+ */
protected int getColumnWidth()
{
FontMetrics metrics = getToolkit().getFontMetrics(getFont());
return metrics.charWidth('m');
}
+
+ /**
+ * Returns the accessible context associated with the <code>JTextField</code>.
+ *
+ * @return the accessible context associated with the <code>JTextField</code>
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJTextField();
+ return accessibleContext;
+ }
+
+ /**
+ * Returns the bounded range model that describes the horizontal visibility
+ * of the text field in the case when the text does not fit into the
+ * available space. The actual values of this model are managed by the look
+ * and feel implementation.
+ *
+ * @return the bounded range model that describes the horizontal visibility
+ */
+ public BoundedRangeModel getHorizontalVisibility()
+ {
+ // TODO: The real implementation of this property is still missing.
+ // However, this is not done in JTextField but must instead be handled in
+ // javax.swing.text.FieldView.
+ return horizontalVisibility;
+ }
}
diff --git a/javax/swing/JTextPane.java b/javax/swing/JTextPane.java
index 80632fff3..1f5b99e43 100644
--- a/javax/swing/JTextPane.java
+++ b/javax/swing/JTextPane.java
@@ -39,8 +39,6 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
@@ -49,7 +47,6 @@ import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import javax.swing.text.Element;
import javax.swing.text.MutableAttributeSet;
-import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.Style;
import javax.swing.text.StyledDocument;
import javax.swing.text.StyledEditorKit;
@@ -106,7 +103,7 @@ public class JTextPane
* @throws IllegalArgumentException if <code>document</code> is not an
* instance of <code>StyledDocument</code>
*
- * @see {@link #setStyledDocument}
+ * @see #setStyledDocument
*/
public void setDocument(Document document)
{
@@ -120,7 +117,7 @@ public class JTextPane
/**
* Returns the {@link StyledDocument} that is the content model for
* this <code>JTextPane</code>. This is a typed wrapper for
- * {@link #getDocument}.
+ * {@link #getDocument()}.
*
* @return the content model of this <code>JTextPane</code>
*/
@@ -179,8 +176,6 @@ public class JTextPane
doc.setCharacterAttributes(start, contentLength, getInputAttributes(),
true);
- // Set dot to new position.
- setCaretPosition(start + contentLength);
}
catch (BadLocationException e)
{
@@ -300,7 +295,7 @@ public class JTextPane
* @param replace if <code>true</code>, the attributes of the current
* selection are overridden, otherwise they are merged
*
- * @see {@link #getInputAttributes}
+ * @see #getInputAttributes
*/
public void setCharacterAttributes(AttributeSet attribute,
boolean replace)
diff --git a/javax/swing/JToggleButton.java b/javax/swing/JToggleButton.java
index 25d67f59e..077e5adb8 100644
--- a/javax/swing/JToggleButton.java
+++ b/javax/swing/JToggleButton.java
@@ -129,7 +129,7 @@ public class JToggleButton extends AbstractButton implements Accessible
* Compatible with Sun's JDK.
*/
private static final long serialVersionUID = -1589950750899943974L;
-
+
/**
* Sets the pressed state of the button. The selected state
* of the button also changes follwing the button being pressed.
@@ -174,8 +174,27 @@ public class JToggleButton extends AbstractButton implements Accessible
ActionEvent.ACTION_PERFORMED,
actionCommand));
}
-
}
+
+ /**
+ * Checks if the button is selected.
+ *
+ * @returns true if the button is selected
+ */
+ public boolean isSelected()
+ {
+ return super.isSelected();
+ }
+
+ /**
+ * Sets the selected state of the button.
+ *
+ * @param b true if button is selected
+ */
+ public void setSelected(boolean b)
+ {
+ super.setSelected(b);
+ }
}
/**
@@ -276,6 +295,7 @@ public class JToggleButton extends AbstractButton implements Accessible
setModel(new ToggleButtonModel());
model.setSelected(selected);
+ setAlignmentX(LEFT_ALIGNMENT);
}
/**
diff --git a/javax/swing/JToolBar.java b/javax/swing/JToolBar.java
index 649919e06..dc85e294d 100644
--- a/javax/swing/JToolBar.java
+++ b/javax/swing/JToolBar.java
@@ -68,6 +68,8 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible
/**
* AccessibleJToolBar
*/
+ // FIXME: This inner class is a complete stub and must be implemented
+ // properly.
protected class AccessibleJToolBar extends AccessibleJComponent
{
/** DOCUMENT ME! */
@@ -78,6 +80,7 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible
*/
protected AccessibleJToolBar()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JToolTip.java b/javax/swing/JToolTip.java
index 8d7747827..6bc3e3fa2 100644
--- a/javax/swing/JToolTip.java
+++ b/javax/swing/JToolTip.java
@@ -58,6 +58,8 @@ public class JToolTip extends JComponent implements Accessible
/**
* DOCUMENT ME!
*/
+ // FIXME: This inner class is a complete stub and must be implemented
+ // properly.
protected class AccessibleJToolTip extends AccessibleJComponent
{
private static final long serialVersionUID = -6222548177795408476L;
@@ -67,6 +69,7 @@ public class JToolTip extends JComponent implements Accessible
*/
protected AccessibleJToolTip()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index 15271bba4..660945c27 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -73,7 +73,6 @@ import javax.swing.event.TreeWillExpandListener;
import javax.swing.plaf.TreeUI;
import javax.swing.text.Position;
import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.ExpandVetoException;
@@ -84,9 +83,7 @@ import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
-public class JTree
- extends JComponent
- implements Scrollable, Accessible
+public class JTree extends JComponent implements Scrollable, Accessible
{
/**
@@ -977,7 +974,7 @@ public class JTree
/**
* Returns the number of items currently selected.
*
- * @param the number of selected accessibles.
+ * @return the number of selected accessibles.
*/
public int getAccessibleSelectionCount()
{
@@ -1194,6 +1191,7 @@ public class JTree
*/
protected TreeModelHandler()
{
+ // Nothing to do here.
}
/**
@@ -1268,6 +1266,7 @@ public class JTree
*/
protected TreeSelectionRedirector()
{
+ // Nothing to do here.
}
/**
@@ -1303,6 +1302,7 @@ public class JTree
*/
protected EmptySelectionModel()
{
+ // Nothing to do here.
}
/**
@@ -1477,10 +1477,10 @@ public class JTree
*/
public JTree(TreeModel model)
{
+ updateUI();
+ setRootVisible(true);
setModel(model);
setSelectionModel(EmptySelectionModel.sharedInstance());
- setCellRenderer(new DefaultTreeCellRenderer());
- updateUI();
}
/**
@@ -1585,8 +1585,6 @@ public class JTree
public void updateUI()
{
setUI((TreeUI) UIManager.getUI(this));
- revalidate();
- repaint();
}
/**
@@ -1601,13 +1599,13 @@ public class JTree
/**
* Gets the AccessibleContext associated with this
- * <code>JToggleButton</code>.
+ * <code>JTree</code>.
*
* @return the associated context
*/
public AccessibleContext getAccessibleContext()
{
- return null;
+ return new AccessibleJTree();
}
/**
@@ -1632,14 +1630,14 @@ public class JTree
return 1;
}
- public boolean getScrollableTracksViewportWidth()
+ public boolean getScrollableTracksViewportHeight()
{
if (getParent() instanceof JViewport)
return ((JViewport) getParent()).getHeight() > getPreferredSize().height;
return false;
}
- public boolean getScrollableTracksViewportHeight()
+ public boolean getScrollableTracksViewportWidth()
{
if (getParent() instanceof JViewport)
return ((JViewport) getParent()).getWidth() > getPreferredSize().width;
@@ -1837,6 +1835,7 @@ public class JTree
treeModel = model;
firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
+ updateUI();
}
/**
@@ -2047,13 +2046,26 @@ public class JTree
{
if (path == null)
return;
-
+
+ Object[] oPath = path.getPath();
+ TreePath temp = new TreePath(oPath[0]);
+ boolean stop = false;
+ int i = 1;
+ while (!stop)
+ {
+ while (isVisible(temp))
+ if (i < oPath.length)
+ temp = temp.pathByAddingChild(oPath[i++]);
+ else
+ {
+ stop = true;
+ break;
+ }
+ makeVisible(temp);
+ }
Rectangle rect = getPathBounds(path);
-
- if (rect == null)
- return;
-
scrollRectToVisible(rect);
+ setSelectionPath(temp);
}
public void scrollRowToVisible(int row)
@@ -2332,6 +2344,7 @@ public class JTree
}
catch (ExpandVetoException ev)
{
+ // We do nothing if attempt has been vetoed.
}
setExpandedState(path, false);
fireTreeCollapsed(path);
@@ -2360,6 +2373,7 @@ public class JTree
}
catch (ExpandVetoException ev)
{
+ // We do nothing if attempt has been vetoed.
}
setExpandedState(path, true);
@@ -2884,7 +2898,7 @@ public class JTree
}
}
}
-
+
/**
* Sent when the tree has changed enough that we need to resize the bounds,
* but not enough that we need to remove the expanded node set (e.g nodes
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index a02fedd08..ba44461cb 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -41,6 +41,7 @@ package javax.swing;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.Image;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
@@ -129,12 +130,10 @@ public class JViewport extends JComponent implements Accessible
/**
* A {@link java.awt.event.ComponentListener} that listens for
- * changes of the view's size. This class forbids changes of the view
- * component's size that would exceed the viewport's size.
+ * changes of the view's size. This triggers a revalidate() call on the
+ * viewport.
*/
- protected class ViewListener
- extends ComponentAdapter
- implements Serializable
+ protected class ViewListener extends ComponentAdapter implements Serializable
{
private static final long serialVersionUID = -2812489404285958070L;
@@ -143,57 +142,53 @@ public class JViewport extends JComponent implements Accessible
*/
protected ViewListener()
{
+ // Nothing to do here.
}
/**
* Receives notification when a component (in this case: the view
- * component) changes it's size.
+ * component) changes it's size. This simply triggers a revalidate() on the
+ * viewport.
*
* @param ev the ComponentEvent describing the change
*/
public void componentResized(ComponentEvent ev)
{
- // According to some tests that I did with Sun's implementation
- // this class is supposed to make sure that the view component
- // is not resized to a larger size than the viewport.
- // This is not documented anywhere. What I did is: I subclassed JViewport
- // and ViewListener and 'disabled' the componentResized method by
- // overriding it and not calling super.componentResized().
- // When this method is disabled I can set the size on the view component
- // normally, when it is enabled, it gets immediatly resized back,
- // after a resize attempt that would exceed the Viewport's size.
- Component comp = ev.getComponent();
- Dimension newSize = comp.getSize();
- Dimension viewportSize = getSize();
- boolean revert = false;
- if (newSize.width > viewportSize.width)
- {
- newSize.width = viewportSize.width;
- revert = true;
- }
- if (newSize.height > viewportSize.height)
- {
- newSize.height = viewportSize.height;
- revert = true;
- }
- if (revert == true)
- comp.setSize(newSize);
+ revalidate();
}
}
- private static final long serialVersionUID = -6925142919680527970L;
-
public static final int SIMPLE_SCROLL_MODE = 0;
public static final int BLIT_SCROLL_MODE = 1;
public static final int BACKINGSTORE_SCROLL_MODE = 2;
+ private static final long serialVersionUID = -6925142919680527970L;
+
+ protected boolean scrollUnderway;
+ protected boolean isViewSizeSet;
+
+ /**
+ * This flag indicates whether we use a backing store for drawing.
+ *
+ * @deprecated since JDK 1.3
+ */
+ protected boolean backingStore;
+
+ /**
+ * The backingstore image used for the backingstore and blit scroll methods.
+ */
+ protected Image backingStoreImage;
+
+ /**
+ * The position at which the view has been drawn the last time. This is used
+ * to determine the bittable area.
+ */
+ protected Point lastPaintPosition;
+
ChangeEvent changeEvent = new ChangeEvent(this);
int scrollMode;
- protected boolean scrollUnderway;
- protected boolean isViewSizeSet;
-
/**
* The width and height of the Viewport's area in terms of view
* coordinates. Typically this will be the same as the width and height
@@ -201,34 +196,64 @@ public class JViewport extends JComponent implements Accessible
* width and height, which it may do, for example if it magnifies or
* rotates its view.
*
- * @see #toViewCoordinates
+ * @see #toViewCoordinates(Dimension)
*/
Dimension extentSize;
/**
* The width and height of the view in its own coordinate space.
*/
-
Dimension viewSize;
- Point lastPaintPosition;
-
/**
* The ViewListener instance.
*/
ViewListener viewListener;
/**
- * The accessible context of this <code>JViewport</code>.
+ * Stores the location from where to blit. This is a cached Point object used
+ * in blitting calculations.
+ */
+ Point cachedBlitFrom;
+
+ /**
+ * Stores the location where to blit to. This is a cached Point object used
+ * in blitting calculations.
+ */
+ Point cachedBlitTo;
+
+ /**
+ * Stores the width of the blitted area. This is a cached Dimension object
+ * used in blitting calculations.
+ */
+ Dimension cachedBlitSize;
+
+ /**
+ * Stores the bounds of the area that needs to be repainted. This is a cached
+ * Rectangle object used in blitting calculations.
*/
- AccessibleContext accessibleContext;
+ Rectangle cachedBlitPaint;
+
+ boolean damaged = true;
+
+ /**
+ * A flag indicating if the size of the viewport has changed since the
+ * last repaint. This is used in double buffered painting to check if we
+ * need a new double buffer, or can reuse the old one.
+ */
+ boolean sizeChanged = true;
public JViewport()
{
setOpaque(true);
setScrollMode(BLIT_SCROLL_MODE);
- setLayout(createLayoutManager());
updateUI();
+ setLayout(createLayoutManager());
+ lastPaintPosition = new Point();
+ cachedBlitFrom = new Point();
+ cachedBlitTo = new Point();
+ cachedBlitSize = new Dimension();
+ cachedBlitPaint = new Rectangle();
}
public Dimension getExtentSize()
@@ -314,6 +339,8 @@ public class JViewport extends JComponent implements Accessible
public void setViewPosition(Point p)
{
+ if (getViewPosition().equals(p))
+ return;
Component view = getView();
if (view != null)
{
@@ -322,6 +349,7 @@ public class JViewport extends JComponent implements Accessible
isViewSizeSet = false;
fireStateChanged();
}
+ repaint();
}
public Rectangle getViewRect()
@@ -371,12 +399,8 @@ public class JViewport extends JComponent implements Accessible
public void setView(Component v)
{
- while (getComponentCount() > 0)
- {
- if (viewListener != null)
- getView().removeComponentListener(viewListener);
- remove(0);
- }
+ if (viewListener != null)
+ getView().removeComponentListener(viewListener);
if (v != null)
{
@@ -386,37 +410,25 @@ public class JViewport extends JComponent implements Accessible
add(v);
fireStateChanged();
}
- }
-
- public void revalidate()
- {
- fireStateChanged();
- super.revalidate();
+ revalidate();
+ repaint();
}
public void reshape(int x, int y, int w, int h)
{
- boolean changed =
- (x != getX())
- || (y != getY())
- || (w != getWidth())
- || (h != getHeight());
+ if (w != getWidth() || h != getHeight())
+ sizeChanged = true;
super.reshape(x, y, w, h);
- if (changed)
- fireStateChanged();
- }
-
- protected void addImpl(Component comp, Object constraints, int index)
- {
- if (getComponentCount() > 0)
- remove(getComponents()[0]);
-
- super.addImpl(comp, constraints, index);
+ if (sizeChanged)
+ {
+ damaged = true;
+ fireStateChanged();
+ }
}
- public final Insets getInsets()
+ public final Insets getInsets()
{
- return new Insets(0,0,0,0);
+ return new Insets(0, 0, 0, 0);
}
public final Insets getInsets(Insets insets)
@@ -430,6 +442,14 @@ public class JViewport extends JComponent implements Accessible
return insets;
}
+
+ /**
+ * Overridden to return <code>false</code>, so the JViewport's paint method
+ * gets called instead of directly calling the children. This is necessary
+ * in order to get a useful clipping and translation on the children.
+ *
+ * @return <code>false</code>
+ */
public boolean isOptimizedDrawingEnabled()
{
return false;
@@ -437,7 +457,36 @@ public class JViewport extends JComponent implements Accessible
public void paint(Graphics g)
{
- paintComponent(g);
+ Component view = getView();
+
+ if (view == null)
+ return;
+
+ Point pos = getViewPosition();
+ Rectangle viewBounds = view.getBounds();
+ Rectangle portBounds = getBounds();
+
+ if (viewBounds.width == 0
+ || viewBounds.height == 0
+ || portBounds.width == 0
+ || portBounds.height == 0)
+ return;
+
+ switch (getScrollMode())
+ {
+
+ case JViewport.BACKINGSTORE_SCROLL_MODE:
+ paintBackingStore(g);
+ break;
+ case JViewport.BLIT_SCROLL_MODE:
+ paintBlit(g);
+ break;
+ case JViewport.SIMPLE_SCROLL_MODE:
+ default:
+ paintSimple(g);
+ break;
+ }
+ damaged = false;
}
public void addChangeListener(ChangeListener listener)
@@ -455,13 +504,6 @@ public class JViewport extends JComponent implements Accessible
return (ChangeListener[]) getListeners(ChangeListener.class);
}
- protected void fireStateChanged()
- {
- ChangeListener[] listeners = getChangeListeners();
- for (int i = 0; i < listeners.length; ++i)
- listeners[i].stateChanged(changeEvent);
- }
-
/**
* This method returns the String ID of the UI class of Separator.
*
@@ -507,6 +549,90 @@ public class JViewport extends JComponent implements Accessible
}
/**
+ * Scrolls the view so that contentRect becomes visible.
+ *
+ * @param contentRect the rectangle to make visible within the view
+ */
+ public void scrollRectToVisible(Rectangle contentRect)
+ {
+ Component view = getView();
+ if (view == null)
+ return;
+
+ Point pos = getViewPosition();
+ Rectangle viewBounds = getView().getBounds();
+ Rectangle portBounds = getBounds();
+
+ if (isShowing())
+ getView().validate();
+
+ // If the bottom boundary of contentRect is below the port
+ // boundaries, scroll up as necessary.
+ if (contentRect.y + contentRect.height + viewBounds.y > portBounds.height)
+ pos.y = contentRect.y + contentRect.height - portBounds.height;
+ // If contentRect.y is above the port boundaries, scroll down to
+ // contentRect.y.
+ if (contentRect.y + viewBounds.y < 0)
+ pos.y = contentRect.y;
+ // If the right boundary of contentRect is right from the port
+ // boundaries, scroll left as necessary.
+ if (contentRect.x + contentRect.width + viewBounds.x > portBounds.width)
+ pos.x = contentRect.x + contentRect.width - portBounds.width;
+ // If contentRect.x is left from the port boundaries, scroll right to
+ // contentRect.x.
+ if (contentRect.x + viewBounds.x < 0)
+ pos.x = contentRect.x;
+ setViewPosition(pos);
+ }
+
+ /**
+ * Returns the accessible context for this <code>JViewport</code>. This
+ * will be an instance of {@link AccessibleJViewport}.
+ *
+ * @return the accessible context for this <code>JViewport</code>
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJViewport();
+ return accessibleContext;
+ }
+
+ /**
+ * Forward repaint to parent to make sure only one paint is performed by the
+ * RepaintManager.
+ *
+ * @param tm number of milliseconds to defer the repaint request
+ * @param x the X coordinate of the upper left corner of the dirty area
+ * @param y the Y coordinate of the upper left corner of the dirty area
+ * @param w the width of the dirty area
+ * @param h the height of the dirty area
+ */
+ public void repaint(long tm, int x, int y, int w, int h)
+ {
+ Component parent = getParent();
+ if (parent != null)
+ {
+ parent.repaint(tm, x + getX(), y + getY(), w, h);
+ }
+ }
+
+ protected void addImpl(Component comp, Object constraints, int index)
+ {
+ if (getComponentCount() > 0)
+ remove(getComponents()[0]);
+
+ super.addImpl(comp, constraints, index);
+ }
+
+ protected void fireStateChanged()
+ {
+ ChangeListener[] listeners = getChangeListeners();
+ for (int i = 0; i < listeners.length; ++i)
+ listeners[i].stateChanged(changeEvent);
+ }
+
+ /**
* Creates a {@link ViewListener} that is supposed to listen for
* size changes on the view component.
*
@@ -529,56 +655,217 @@ public class JViewport extends JComponent implements Accessible
}
/**
- * Scrolls the view so that contentRect becomes visible.
+ * Computes the parameters for the blitting scroll method. <code>dx</code>
+ * and <code>dy</code> specifiy the X and Y offset by which the viewport
+ * is scrolled. All other arguments are output parameters and are filled by
+ * this method.
*
- * @param contentRect the rectangle to make visible within the view
+ * <code>blitFrom</code> holds the position of the blit rectangle in the
+ * viewport rectangle before scrolling, <code>blitTo</code> where the blitArea
+ * is copied to.
+ *
+ * <code>blitSize</code> holds the size of the blit area and
+ * <code>blitPaint</code> is the area of the view that needs to be painted.
+ *
+ * This method returns <code>true</code> if blitting is possible and
+ * <code>false</code> if the viewport has to be repainted completetly without
+ * blitting.
+ *
+ * @param dx the horizontal delta
+ * @param dy the vertical delta
+ * @param blitFrom the position from where to blit; set by this method
+ * @param blitTo the position where to blit area is copied to; set by this
+ * method
+ * @param blitSize the size of the blitted area; set by this method
+ * @param blitPaint the area that needs repainting; set by this method
+ *
+ * @return <code>true</code> if blitting is possible,
+ * <code>false</code> otherwise
*/
- public void scrollRectToVisible(Rectangle contentRect)
+ protected boolean computeBlit(int dx, int dy, Point blitFrom, Point blitTo,
+ Dimension blitSize, Rectangle blitPaint)
+ {
+ if ((dx != 0 && dy != 0) || damaged)
+ // We cannot blit if the viewport is scrolled in both directions at
+ // once.
+ return false;
+
+ Rectangle portBounds = SwingUtilities.calculateInnerArea(this, getBounds());
+
+ // Compute the blitFrom and blitTo parameters.
+ blitFrom.x = portBounds.x;
+ blitFrom.y = portBounds.y;
+ blitTo.x = portBounds.x;
+ blitTo.y = portBounds.y;
+
+ if (dy > 0)
+ {
+ blitFrom.y = portBounds.y + dy;
+ }
+ else if (dy < 0)
+ {
+ blitTo.y = portBounds.y - dy;
+ }
+ else if (dx > 0)
+ {
+ blitFrom.x = portBounds.x + dx;
+ }
+ else if (dx < 0)
+ {
+ blitTo.x = portBounds.x - dx;
+ }
+
+ // Compute size of the blit area.
+ if (dx != 0)
+ {
+ blitSize.width = portBounds.width - Math.abs(dx);
+ blitSize.height = portBounds.height;
+ }
+ else if (dy != 0)
+ {
+ blitSize.width = portBounds.width;
+ blitSize.height = portBounds.height - Math.abs(dy);
+ }
+
+ // Compute the blitPaint parameter.
+ blitPaint.setBounds(portBounds);
+ if (dy > 0)
+ {
+ blitPaint.y = portBounds.y + portBounds.height - dy;
+ blitPaint.height = dy;
+ }
+ else if (dy < 0)
+ {
+ blitPaint.height = -dy;
+ }
+ if (dx > 0)
+ {
+ blitPaint.x = portBounds.x + portBounds.width - dx;
+ blitPaint.width = dx;
+ }
+ else if (dx < 0)
+ {
+ blitPaint.width = -dx;
+ }
+
+ return true;
+ }
+
+ /**
+ * Paints the viewport in case we have a scrollmode of
+ * {@link #SIMPLE_SCROLL_MODE}.
+ *
+ * This simply paints the view directly on the surface of the viewport.
+ *
+ * @param g the graphics context to use
+ */
+ void paintSimple(Graphics g)
{
Point pos = getViewPosition();
- Rectangle viewBounds = getView().getBounds();
- Rectangle portBounds = getBounds();
-
- // FIXME: should validate the view if it is not valid, however
- // this may cause excessive validation when the containment
- // hierarchy is being created.
-
- // if contentRect is larger than the portBounds, center the view
- if (contentRect.height > portBounds.height ||
- contentRect.width > portBounds.width)
+ Component view = getView();
+ boolean translated = false;
+ try
+ {
+ g.translate(-pos.x, -pos.y);
+ translated = true;
+ view.paint(g);
+ }
+ finally
{
- setViewPosition(new Point(contentRect.x, contentRect.y));
- return;
+ if (translated)
+ g.translate (pos.x, pos.y);
}
-
- // Y-DIRECTION
- if (contentRect.y < -viewBounds.y)
- setViewPosition(new Point(pos.x, contentRect.y));
- else if (contentRect.y + contentRect.height >
- -viewBounds.y + portBounds.height)
- setViewPosition (new Point(pos.x, contentRect.y -
- (portBounds.height - contentRect.height)));
-
- // X-DIRECTION
- pos = getViewPosition();
- if (contentRect.x < -viewBounds.x)
- setViewPosition(new Point(contentRect.x, pos.y));
- else if (contentRect.x + contentRect.width >
- -viewBounds.x + portBounds.width)
- setViewPosition (new Point(contentRect.x -
- (portBounds.width - contentRect.width), pos.y));
}
/**
- * Returns the accessible context for this <code>JViewport</code>. This
- * will be an instance of {@link AccessibleJViewport}.
+ * Paints the viewport in case we have a scroll mode of
+ * {@link #BACKINGSTORE_SCROLL_MODE}.
*
- * @return the accessible context for this <code>JViewport</code>
+ * This method uses a backing store image to paint the view to, which is then
+ * subsequently painted on the screen. This should make scrolling more
+ * smooth.
+ *
+ * @param g the graphics context to use
*/
- public AccessibleContext getAccessibleContext()
+ void paintBackingStore(Graphics g)
{
- if (accessibleContext == null)
- accessibleContext = new AccessibleJViewport();
- return accessibleContext;
+ // If we have no backing store image yet or the size of the component has
+ // changed, we need to rebuild the backing store.
+ if (backingStoreImage == null || sizeChanged)
+ {
+ backingStoreImage = createImage(getWidth(), getHeight());
+ sizeChanged = false;
+ Graphics g2 = backingStoreImage.getGraphics();
+ paintSimple(g2);
+ g2.dispose();
+ }
+ // Otherwise we can perform the blitting on the backing store image:
+ // First we move the part that remains visible after scrolling, then
+ // we only need to paint the bit that becomes newly visible.
+ else
+ {
+ Graphics g2 = backingStoreImage.getGraphics();
+ Point viewPosition = getViewPosition();
+ int dx = viewPosition.x - lastPaintPosition.x;
+ int dy = viewPosition.y - lastPaintPosition.y;
+ boolean canBlit = computeBlit(dx, dy, cachedBlitFrom, cachedBlitTo,
+ cachedBlitSize, cachedBlitPaint);
+ if (canBlit)
+ {
+ // Copy the part that remains visible during scrolling.
+ g2.copyArea(cachedBlitFrom.x, cachedBlitFrom.y,
+ cachedBlitSize.width, cachedBlitSize.height,
+ cachedBlitTo.x - cachedBlitFrom.x,
+ cachedBlitTo.y - cachedBlitFrom.y);
+ // Now paint the part that becomes newly visible.
+ g2.setClip(cachedBlitPaint.x, cachedBlitPaint.y,
+ cachedBlitPaint.width, cachedBlitPaint.height);
+ paintSimple(g2);
+ }
+ // If blitting is not possible for some reason, fall back to repainting
+ // everything.
+ else
+ {
+ paintSimple(g2);
+ }
+ g2.dispose();
+ }
+ // Actually draw the backingstore image to the graphics context.
+ g.drawImage(backingStoreImage, 0, 0, this);
+ // Update the lastPaintPosition so that we know what is already drawn when
+ // we paint the next time.
+ lastPaintPosition.setLocation(getViewPosition());
+ }
+
+ /**
+ * Paints the viewport in case we have a scrollmode of
+ * {@link #BLIT_SCROLL_MODE}.
+ *
+ * This paints the viewport using a backingstore and a blitting algorithm.
+ * Only the newly exposed area of the view is painted from the view painting
+ * methods, the remainder is copied from the backing store.
+ *
+ * @param g the graphics context to use
+ */
+ void paintBlit(Graphics g)
+ {
+ // We cannot perform blitted painting as it is described in Sun's API docs.
+ // There it is suggested that this painting method should blit directly
+ // on the parent window's surface. This is not possible because when using
+ // Swing's double buffering (at least our implementation), it would
+ // immediatly be painted when the buffer is painted on the screen. For this
+ // to work we would need a kind of hole in the buffer image. And honestly
+ // I find this method not very elegant.
+ // The alternative, blitting directly on the buffer image, is also not
+ // possible because the buffer image gets cleared everytime when an opaque
+ // parent component is drawn on it.
+
+ // What we do instead is falling back to the backing store approach which
+ // is in fact a mixed blitting/backing store approach where the blitting
+ // is performed on the backing store image and this is then drawn to the
+ // graphics context. This is very robust and works independent of the
+ // painting mechanism that is used by Swing. And it should have comparable
+ // performance characteristics as the blitting method.
+ paintBackingStore(g);
}
}
diff --git a/javax/swing/KeyStroke.java b/javax/swing/KeyStroke.java
index 12a280c21..b57a71192 100644
--- a/javax/swing/KeyStroke.java
+++ b/javax/swing/KeyStroke.java
@@ -51,6 +51,7 @@ public class KeyStroke
// Called by java.awt.AWTKeyStroke.registerSubclass via reflection.
private KeyStroke()
{
+ // Nothing to do here.
}
private KeyStroke(char keyChar, int keyCode, int modifiers,
diff --git a/javax/swing/LookAndFeel.java b/javax/swing/LookAndFeel.java
index 885874271..1a67e8497 100644
--- a/javax/swing/LookAndFeel.java
+++ b/javax/swing/LookAndFeel.java
@@ -38,9 +38,17 @@ exception statement from your version. */
package javax.swing;
+import java.awt.Color;
import java.awt.Component;
+import java.awt.Font;
import java.awt.Toolkit;
+import java.net.URL;
+import javax.swing.border.Border;
+import javax.swing.plaf.ComponentInputMapUIResource;
+import javax.swing.plaf.IconUIResource;
+import javax.swing.plaf.InputMapUIResource;
+import javax.swing.plaf.UIResource;
import javax.swing.text.JTextComponent;
public abstract class LookAndFeel
@@ -104,6 +112,8 @@ public abstract class LookAndFeel
*/
public void initialize()
{
+ // We do nothing here. This method is meant to be overridden by
+ // LookAndFeel implementations.
}
/**
@@ -113,14 +123,27 @@ public abstract class LookAndFeel
*/
public static void installBorder(JComponent c, String defaultBorderName)
{
+ Border b = c.getBorder();
+ if (b == null || b instanceof UIResource)
+ c.setBorder(UIManager.getBorder(defaultBorderName));
}
/**
* Convenience method for initializing a component's foreground and
* background color properties with values from the current defaults table.
*/
- public static void installColors(JComponent c, String defaultBgName, String defaultFgName)
+ public static void installColors(JComponent c, String defaultBgName,
+ String defaultFgName)
{
+ // Install background.
+ Color bg = c.getBackground();
+ if (bg == null || bg instanceof UIResource)
+ c.setBackground(UIManager.getColor(defaultBgName));
+
+ // Install foreground.
+ Color fg = c.getForeground();
+ if (fg == null || fg instanceof UIResource)
+ c.setForeground(UIManager.getColor(defaultFgName));
}
/**
@@ -128,10 +151,16 @@ public abstract class LookAndFeel
* and font properties with values from the current defaults table.
*/
public static void installColorsAndFont(JComponent component,
- String defaultBgName,
- String defaultFgName,
- String defaultFontName)
+ String defaultBgName,
+ String defaultFgName,
+ String defaultFontName)
{
+ // Install colors.
+ installColors(component, defaultBgName, defaultFgName);
+ // Install font.
+ Font f = component.getFont();
+ if (f == null || f instanceof UIResource)
+ component.setFont(UIManager.getFont(defaultFontName));
}
/**
@@ -156,19 +185,47 @@ public abstract class LookAndFeel
public abstract boolean isSupportedLookAndFeel();
/**
- * Loads the bindings in keys into retMap.
+ * Loads the bindings in keys into retMap. Does not remove existing entries
+ * from retMap. <code>keys</code> describes the InputMap, every even indexed
+ * item is either a KeyStroke or a String representing a KeyStroke and every
+ * odd indexed item is the Object associated with that KeyStroke in an
+ * ActionMap.
+ *
+ * @param retMap the InputMap into which we load bindings
+ * @param keys the Object array describing the InputMap as above
*/
public static void loadKeyBindings(InputMap retMap, Object[] keys)
{
+ if (keys == null)
+ return;
+ for (int i = 0; i < keys.length - 1; i+= 2)
+ {
+ Object key = keys[i];
+ KeyStroke keyStroke;
+ if (key instanceof KeyStroke)
+ keyStroke = (KeyStroke)key;
+ else
+ keyStroke = KeyStroke.getKeyStroke((String)key);
+ retMap.put(keyStroke, keys[i+1]);
+ }
}
/**
- * Creates a ComponentInputMap from keys.
+ * Creates a ComponentInputMap from keys.
+ * <code>keys</code> describes the InputMap, every even indexed
+ * item is either a KeyStroke or a String representing a KeyStroke and every
+ * odd indexed item is the Object associated with that KeyStroke in an
+ * ActionMap.
+ *
+ * @param c the JComponent associated with the ComponentInputMap
+ * @param keys the Object array describing the InputMap as above
*/
public static ComponentInputMap makeComponentInputMap(JComponent c,
Object[] keys)
{
- return null;
+ ComponentInputMap retMap = new ComponentInputMapUIResource(c);
+ loadKeyBindings(retMap, keys);
+ return retMap;
}
/**
@@ -177,23 +234,55 @@ public abstract class LookAndFeel
*/
public static Object makeIcon(Class baseClass, String gifFile)
{
- return null;
+ final URL file = baseClass.getResource(gifFile);
+ return new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults table)
+ {
+ return new IconUIResource(new ImageIcon(file));
+ }
+ };
}
/**
* Creates a InputMap from keys.
+ * <code>keys</code> describes the InputMap, every even indexed
+ * item is either a KeyStroke or a String representing a KeyStroke and every
+ * odd indexed item is the Object associated with that KeyStroke in an
+ * ActionMap.
+ *
+ * @param keys the Object array describing the InputMap as above
*/
public static InputMap makeInputMap(Object[] keys)
{
- return null;
+ InputMap retMap = new InputMapUIResource();
+ loadKeyBindings(retMap, keys);
+ return retMap;
}
/**
- * Convenience method for building lists of KeyBindings.
+ * Convenience method for building lists of KeyBindings.
+ * <code>keyBindingList</code> is an array of KeyStroke-Action pairs where
+ * even indexed elements are KeyStrokes or Strings representing KeyStrokes
+ * and odd indexed elements are the associated Actions.
+ *
+ * @param keyBindingList the array of KeyStroke-Action pairs
+ * @return a JTextComponent.KeyBinding array
*/
public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList)
{
- return null;
+ JTextComponent.KeyBinding[] retBindings =
+ new JTextComponent.KeyBinding[keyBindingList.length / 2];
+ for (int i = 0; i < keyBindingList.length - 1; i+= 2)
+ {
+ KeyStroke stroke;
+ if (keyBindingList[i] instanceof KeyStroke)
+ stroke = (KeyStroke)keyBindingList[i];
+ else
+ stroke = KeyStroke.getKeyStroke((String)keyBindingList[i]);
+ retBindings[i/2] = new JTextComponent.KeyBinding(stroke, (String)keyBindingList[i+1]);
+ }
+ return retBindings;
}
/**
@@ -224,6 +313,8 @@ public abstract class LookAndFeel
*/
public void uninitialize()
{
+ // We do nothing here. This method is meant to be overridden by
+ // LookAndFeel implementations.
}
/**
@@ -232,5 +323,7 @@ public abstract class LookAndFeel
*/
public static void uninstallBorder(JComponent c)
{
+ if (c.getBorder() instanceof UIResource)
+ c.setBorder(null);
}
}
diff --git a/javax/swing/MutableComboBoxModel.java b/javax/swing/MutableComboBoxModel.java
index ee79dac03..93091786e 100644
--- a/javax/swing/MutableComboBoxModel.java
+++ b/javax/swing/MutableComboBoxModel.java
@@ -76,7 +76,7 @@ public interface MutableComboBoxModel extends ComboBoxModel
/**
* This method removes given element from the data model
*
- * @param element to remove.
+ * @param object element to remove.
*/
void removeElement(Object object);
-} // MutableComboBoxModel
+}
diff --git a/javax/swing/OverlayLayout.java b/javax/swing/OverlayLayout.java
index 143fecbef..56b8c8bb6 100644
--- a/javax/swing/OverlayLayout.java
+++ b/javax/swing/OverlayLayout.java
@@ -1,5 +1,5 @@
-/* OverlayLayout.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* OverlayLayout.java -- A layout manager
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,150 +37,376 @@ exception statement from your version. */
package javax.swing;
+import java.awt.AWTError;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.Insets;
import java.awt.LayoutManager2;
import java.io.Serializable;
/**
- * OverlayLayout
- * @author Andrew Selkirk
- * @version 1.0
+ * A layout manager that lays out the components of a container one over
+ * another.
+ *
+ * The components take as much space as is available in the container, but not
+ * more than specified by their maximum size.
+ *
+ * The overall layout is mainly affected by the components
+ * <code>alignmentX</code> and <code>alignmentY</code> properties. All
+ * components are aligned, so that their alignment points (for either
+ * direction) are placed in one line (the baseline for this direction).
+ *
+ * For example: An X alignment of 0.0 means that the component's alignment
+ * point is at it's left edge, an X alignment of 0.5 means that the alignment
+ * point is in the middle, an X alignment of 1.0 means, the aligment point is
+ * at the right edge. So if you have three components, the first with 0.0, the
+ * second with 0.5 and the third with 1.0, then they are laid out like this:
+ *
+ * <pre>
+ * +-------+
+ * | 1 |
+ * +-------+
+ * +-------+
+ * | 2 |
+ * +-------+
+ * +---------+
+ * | 3 +
+ * +---------+
+ * </pre>
+ * The above picture shows the X alignment between the components. An Y
+ * alignment like shown above cannot be achieved with this layout manager. The
+ * components are place on top of each other, with the X alignment shown above.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ * @author Andrew Selkirk
*/
public class OverlayLayout implements LayoutManager2, Serializable
{
private static final long serialVersionUID = 18082829169631543L;
/**
- * target
+ * The container to be laid out.
*/
private Container target;
/**
- * xChildren
+ * The size requirements of the containers children for the X direction.
*/
private SizeRequirements[] xChildren;
/**
- * yChildren
+ * The size requirements of the containers children for the Y direction.
*/
private SizeRequirements[] yChildren;
/**
- * xTotal
+ * The size requirements of the container to be laid out for the X direction.
*/
private SizeRequirements xTotal;
/**
- * yTotal
+ * The size requirements of the container to be laid out for the Y direction.
*/
private SizeRequirements yTotal;
/**
- * Constructor OverlayLayout
- * @param target TODO
+ * The offsets of the child components in the X direction.
+ */
+ private int[] offsetsX;
+
+ /**
+ * The offsets of the child components in the Y direction.
+ */
+ private int[] offsetsY;
+
+ /**
+ * The spans of the child components in the X direction.
+ */
+ private int[] spansX;
+
+ /**
+ * The spans of the child components in the Y direction.
+ */
+ private int[] spansY;
+
+ /**
+ * Creates a new OverlayLayout for the specified container.
+ *
+ * @param target the container to be laid out
*/
public OverlayLayout(Container target)
{
- // TODO
+ this.target = target;
}
/**
- * invalidateLayout
- * @param target TODO
+ * Notifies the layout manager that the layout has become invalid. It throws
+ * away cached layout information and recomputes it the next time it is
+ * requested.
+ *
+ * @param target not used here
*/
public void invalidateLayout(Container target)
{
- // TODO
+ xChildren = null;
+ yChildren = null;
+ xTotal = null;
+ yTotal = null;
+ offsetsX = null;
+ offsetsY = null;
+ spansX = null;
+ spansY = null;
}
/**
- * addLayoutComponent
- * @param string TODO
- * @param component TODO
+ * This method is not used in this layout manager.
+ *
+ * @param string not used here
+ * @param component not used here
*/
public void addLayoutComponent(String string, Component component)
{
- // TODO
+ // Nothing to do here.
}
/**
- * addLayoutComponent
- * @param component TODO
- * @param constraints TODO
+ * This method is not used in this layout manager.
+ *
+ * @param component not used here
+ * @param constraints not used here
*/
public void addLayoutComponent(Component component, Object constraints)
{
- // TODO
+ // Nothing to do here.
}
/**
- * removeLayoutComponent
- * @param component TODO
+ * This method is not used in this layout manager.
+ *
+ * @param component not used here
*/
public void removeLayoutComponent(Component component)
{
- // TODO
+ // Nothing to do here.
}
/**
- * preferredLayoutSize
- * @param target TODO
- * @returns Dimension
+ * Returns the preferred size of the container that is laid out. This is
+ * computed by the children's preferred sizes, taking their alignments into
+ * account.
+ *
+ * @param target not used here
+ *
+ * @returns the preferred size of the container that is laid out
*/
public Dimension preferredLayoutSize(Container target)
{
- return null; // TODO
+ if (target != this.target)
+ throw new AWTError("OverlayLayout can't be shared");
+
+ checkTotalRequirements();
+ return new Dimension(xTotal.preferred, yTotal.preferred);
}
/**
- * minimumLayoutSize
- * @param target TODO
- * @returns Dimension
+ * Returns the minimum size of the container that is laid out. This is
+ * computed by the children's minimum sizes, taking their alignments into
+ * account.
+ *
+ * @param target not used here
+ *
+ * @returns the minimum size of the container that is laid out
*/
public Dimension minimumLayoutSize(Container target)
{
- return null; // TODO
+ if (target != this.target)
+ throw new AWTError("OverlayLayout can't be shared");
+
+ checkTotalRequirements();
+ return new Dimension(xTotal.minimum, yTotal.minimum);
}
/**
- * maximumLayoutSize
- * @param target TODO
- * @returns Dimension
+ * Returns the maximum size of the container that is laid out. This is
+ * computed by the children's maximum sizes, taking their alignments into
+ * account.
+ *
+ * @param target not used here
+ *
+ * @returns the maximum size of the container that is laid out
*/
public Dimension maximumLayoutSize(Container target)
{
- return null; // TODO
+ if (target != this.target)
+ throw new AWTError("OverlayLayout can't be shared");
+
+ checkTotalRequirements();
+ return new Dimension(xTotal.maximum, yTotal.maximum);
}
/**
- * getLayoutAlignmentX
- * @param target TODO
- * @returns float
+ * Returns the X alignment of the container that is laid out. This is
+ * computed by the children's preferred sizes, taking their alignments into
+ * account.
+ *
+ * @param target not used here
+ *
+ * @returns the X alignment of the container that is laid out
*/
public float getLayoutAlignmentX(Container target)
{
- return (float) 0.0; // TODO
+ if (target != this.target)
+ throw new AWTError("OverlayLayout can't be shared");
+
+ checkTotalRequirements();
+ return xTotal.alignment;
}
/**
- * getLayoutAlignmentY
- * @param target TODO
- * @returns float
+ * Returns the Y alignment of the container that is laid out. This is
+ * computed by the children's preferred sizes, taking their alignments into
+ * account.
+ *
+ * @param target not used here
+ *
+ * @returns the X alignment of the container that is laid out
*/
public float getLayoutAlignmentY(Container target)
{
- return (float) 0.0; // TODO
+ if (target != this.target)
+ throw new AWTError("OverlayLayout can't be shared");
+
+ checkTotalRequirements();
+ return yTotal.alignment;
}
/**
- * layoutContainer
- * @param target TODO
+ * Lays out the container and it's children.
+ *
+ * The children are laid out one over another.
+ *
+ * The components take as much space as is available in the container, but
+ * not more than specified by their maximum size.
+ *
+ * The overall layout is mainly affected by the components
+ * <code>alignmentX</code> and <code>alignmentY</code> properties. All
+ * components are aligned, so that their alignment points (for either
+ * direction) are placed in one line (the baseline for this direction).
+ *
+ * For example: An X alignment of 0.0 means that the component's alignment
+ * point is at it's left edge, an X alignment of 0.5 means that the alignment
+ * point is in the middle, an X alignment of 1.0 means, the aligment point is
+ * at the right edge. So if you have three components, the first with 0.0,
+ * the second with 0.5 and the third with 1.0, then they are laid out like
+ * this:
+ *
+ * <pre>
+ * +-------+
+ * | 1 |
+ * +-------+
+ * +-------+
+ * | 2 |
+ * +-------+
+ * +---------+
+ * | 3 +
+ * +---------+
+ * </pre>
+ * The above picture shows the X alignment between the components. An Y
+ * alignment like shown above cannot be achieved with this layout manager.
+ * The components are place on top of each other, with the X alignment shown
+ * above.
+ *
+ * @param target not used here
*/
public void layoutContainer(Container target)
{
- // TODO
+ if (target != this.target)
+ throw new AWTError("OverlayLayout can't be shared");
+
+ checkLayout();
+ Component[] children = target.getComponents();
+ for (int i = 0; i < children.length; i++)
+ children[i].setBounds(offsetsX[i], offsetsY[i], spansX[i], spansY[i]);
}
+ /**
+ * Makes sure that the xChildren and yChildren fields are correctly set up.
+ * A call to {@link #invalidateLayout(Container)} sets these fields to null,
+ * so they have to be set up again.
+ */
+ private void checkRequirements()
+ {
+ if (xChildren == null || yChildren == null)
+ {
+ Component[] children = target.getComponents();
+ xChildren = new SizeRequirements[children.length];
+ yChildren = new SizeRequirements[children.length];
+ for (int i = 0; i < children.length; i++)
+ {
+ if (! children[i].isVisible())
+ {
+ xChildren[i] = new SizeRequirements();
+ yChildren[i] = new SizeRequirements();
+ }
+ else
+ {
+ xChildren[i] =
+ new SizeRequirements(children[i].getMinimumSize().width,
+ children[i].getPreferredSize().width,
+ children[i].getMaximumSize().width,
+ children[i].getAlignmentX());
+ yChildren[i] =
+ new SizeRequirements(children[i].getMinimumSize().height,
+ children[i].getPreferredSize().height,
+ children[i].getMaximumSize().height,
+ children[i].getAlignmentY());
+ }
+ }
+ }
+ }
+
+ /**
+ * Makes sure that the xTotal and yTotal fields are set up correctly. A call
+ * to {@link #invalidateLayout} sets these fields to null and they have to be
+ * recomputed.
+ */
+ private void checkTotalRequirements()
+ {
+ if (xTotal == null || yTotal == null)
+ {
+ checkRequirements();
+ xTotal = SizeRequirements.getAlignedSizeRequirements(xChildren);
+ yTotal = SizeRequirements.getAlignedSizeRequirements(yChildren);
+ }
+ }
+
+ /**
+ * Makes sure that the offsetsX, offsetsY, spansX and spansY fields are set
+ * up correctly. A call to {@link #invalidateLayout} sets these fields
+ * to null and they have to be recomputed.
+ */
+ private void checkLayout()
+ {
+ if (offsetsX == null || offsetsY == null || spansX == null
+ || spansY == null)
+ {
+ checkRequirements();
+ checkTotalRequirements();
+ int len = target.getComponents().length;
+ offsetsX = new int[len];
+ offsetsY = new int[len];
+ spansX = new int[len];
+ spansY = new int[len];
+
+ Insets in = target.getInsets();
+ int width = target.getWidth() - in.left - in.right;
+ int height = target.getHeight() - in.top - in.bottom;
+
+ SizeRequirements.calculateAlignedPositions(width, xTotal,
+ xChildren, offsetsX, spansX);
+ SizeRequirements.calculateAlignedPositions(height, yTotal,
+ yChildren, offsetsY, spansY);
+ }
+ }
}
diff --git a/javax/swing/Popup.java b/javax/swing/Popup.java
index 69e1f5168..5b2615d2f 100644
--- a/javax/swing/Popup.java
+++ b/javax/swing/Popup.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
+import java.awt.Point;
/**
@@ -89,6 +90,7 @@ public class Popup
*/
protected Popup()
{
+ // Nothing to do here.
}
@@ -129,6 +131,7 @@ public class Popup
*/
JWindow window;
+ private Component contents;
/**
* Constructs a new <code>JWindowPopup</code> given its owner,
@@ -155,10 +158,11 @@ public class Popup
/* Checks whether contents is null. */
super(owner, contents, x, y);
+ this.contents = contents;
window = new JWindow();
- window.getRootPane().add(contents);
+ window.getContentPane().add(contents);
window.setLocation(x, y);
- window.pack();
+ window.setFocusableWindowState(false);
}
@@ -168,6 +172,7 @@ public class Popup
*/
public void show()
{
+ window.setSize(contents.getSize());
window.show();
}
@@ -186,4 +191,100 @@ public class Popup
window.dispose();
}
}
+
+ /**
+ * A popup that displays itself within the JLayeredPane of a JRootPane of
+ * the containment hierarchy of the owner component.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ static class LightweightPopup extends Popup
+ {
+ /**
+ * The owner component for this popup.
+ */
+ Component owner;
+
+ /**
+ * The contents that should be shown.
+ */
+ Component contents;
+
+ /**
+ * The X location in screen coordinates.
+ */
+ int x;
+
+ /**
+ * The Y location in screen coordinates.
+ */
+ int y;
+
+ /**
+ * The panel that holds the content.
+ */
+ private JPanel panel;
+
+ /**
+ * Constructs a new <code>LightweightPopup</code> given its owner,
+ * contents and the screen position where the popup
+ * will appear.
+ *
+ * @param owner the component that should own the popup window; this
+ * provides the JRootPane in which we place the popup window
+ *
+ * @param contents the contents that will be displayed inside
+ * the <code>Popup</code>.
+ *
+ * @param x the horizontal position where the Popup will appear in screen
+ * coordinates
+ *
+ * @param y the vertical position where the Popup will appear in screen
+ * coordinates
+ *
+ * @throws IllegalArgumentException if <code>contents</code>
+ * is <code>null</code>.
+ */
+ public LightweightPopup(Component owner, Component contents, int x, int y)
+ {
+ super(owner, contents, x, y);
+ this.owner = owner;
+ this.contents = contents;
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * Places the popup within the JLayeredPane of the owner component and
+ * makes it visible.
+ */
+ public void show()
+ {
+ JRootPane rootPane = SwingUtilities.getRootPane(owner);
+ JLayeredPane layeredPane = rootPane.getLayeredPane();
+ // We insert a JPanel between the layered pane and the contents so we
+ // can fiddle with the setLocation() method without disturbing a
+ // JPopupMenu (which overrides setLocation in an unusual manner).
+ if (panel == null)
+ {
+ panel = new JPanel();
+ panel.setLayout(null);
+ }
+ panel.add(contents);
+ panel.setSize(contents.getSize());
+ Point layeredPaneLoc = layeredPane.getLocationOnScreen();
+ panel.setLocation(x - layeredPaneLoc.x, y - layeredPaneLoc.y);
+ layeredPane.add(panel, JLayeredPane.POPUP_LAYER);
+ }
+
+ /**
+ * Removes the popup from the JLayeredPane thus making it invisible.
+ */
+ public void hide()
+ {
+ JRootPane rootPane = SwingUtilities.getRootPane(owner);
+ JLayeredPane layeredPane = rootPane.getLayeredPane();
+ layeredPane.remove(panel);
+ }
+ }
}
diff --git a/javax/swing/PopupFactory.java b/javax/swing/PopupFactory.java
index 29cf86d55..7bb2529cd 100644
--- a/javax/swing/PopupFactory.java
+++ b/javax/swing/PopupFactory.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Point;
/**
@@ -55,8 +57,8 @@ public class PopupFactory
/**
* The shared factory object.
*
- * @see #getSharedFactory
- * @see #setSharedFactory
+ * @see #getSharedInstance
+ * @see #setSharedInstance
*/
private static PopupFactory sharedFactory;
@@ -69,6 +71,7 @@ public class PopupFactory
*/
public PopupFactory()
{
+ // Nothing to do here.
}
@@ -134,6 +137,30 @@ public class PopupFactory
public Popup getPopup(Component owner, Component contents,
int x, int y)
{
- return new Popup.JWindowPopup(owner, contents, x, y);
+ Popup popup = null;
+ // By default we enable lightweight popups since they are more efficient
+ // than heavyweight popups.
+ boolean lightweightEnabled = true;
+ // Special case JPopupMenu here, since it supports a lightweightEnabled
+ // flag that we must respect.
+ if (contents instanceof JPopupMenu)
+ {
+ JPopupMenu menu = (JPopupMenu) contents;
+ lightweightEnabled = menu.isLightWeightPopupEnabled();
+ }
+
+ // If we have a root pane and the contents fits within the root pane and
+ // lightweight popups are enabled, than we can use a lightweight popup.
+ JRootPane root = SwingUtilities.getRootPane(owner);
+ Point rootLoc = root.getLocationOnScreen();
+ Dimension contentsSize = contents.getSize();
+ Dimension rootSize = root.getSize();
+ if (x >= rootLoc.x && y > rootLoc.y
+ && (x - rootLoc.x) + contentsSize.width < rootSize.width
+ && (y - rootLoc.y) + contentsSize.height < rootSize.height)
+ popup = new Popup.LightweightPopup(owner, contents, x, y);
+ else
+ popup = new Popup.JWindowPopup(owner, contents, x, y);
+ return popup;
}
}
diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java
index 54243aea8..37281e03d 100644
--- a/javax/swing/RepaintManager.java
+++ b/javax/swing/RepaintManager.java
@@ -1,5 +1,5 @@
/* RepaintManager.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,12 +43,11 @@ import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.VolatileImage;
-import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
/**
* <p>The repaint manager holds a set of dirty regions, invalid components,
@@ -111,6 +110,62 @@ public class RepaintManager
}
+ /**
+ * Compares two components using their depths in the component hierarchy.
+ * A component with a lesser depth (higher level components) are sorted
+ * before components with a deeper depth (low level components). This is used
+ * to order paint requests, so that the higher level components are painted
+ * before the low level components get painted.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ private class ComponentComparator implements Comparator
+ {
+
+ /**
+ * Compares two components.
+ *
+ * @param o1 the first component
+ * @param o2 the second component
+ *
+ * @return a negative integer, if <code>o1</code> is higher in the
+ * hierarchy than <code>o2</code>, zero, if both are at the same
+ * level and a positive integer, if <code>o1</code> is deeper in
+ * the hierarchy than <code>o2</code>
+ */
+ public int compare(Object o1, Object o2)
+ {
+ if (o1 instanceof JComponent && o2 instanceof JComponent)
+ {
+ JComponent c1 = (JComponent) o1;
+ JComponent c2 = (JComponent) o2;
+ return getDepth(c1) - getDepth(c2);
+ }
+ else
+ throw new ClassCastException("This comparator can only be used with "
+ + "JComponents");
+ }
+
+ /**
+ * Computes the depth for a given JComponent.
+ *
+ * @param c the component to compute the depth for
+ *
+ * @return the depth of the component
+ */
+ private int getDepth(JComponent c)
+ {
+ Component comp = c;
+ int depth = 0;
+ while (comp != null)
+ {
+ comp = comp.getParent();
+ depth++;
+ }
+ return depth;
+ }
+ }
+
/**
* A table storing the dirty regions of components. The keys of this
* table are components, the values are rectangles. Each component maps
@@ -123,7 +178,20 @@ public class RepaintManager
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
- Hashtable dirtyComponents;
+ HashMap dirtyComponents;
+
+ HashMap workDirtyComponents;
+
+ /**
+ * Stores the order in which the components get repainted.
+ */
+ ArrayList repaintOrder;
+ ArrayList workRepaintOrder;
+
+ /**
+ * The comparator used for ordered inserting into the repaintOrder list.
+ */
+ Comparator comparator;
/**
* A single, shared instance of the helper class. Any methods which mark
@@ -146,14 +214,15 @@ public class RepaintManager
* @see #removeInvalidComponent
* @see #validateInvalidComponents
*/
- Vector invalidComponents;
+ ArrayList invalidComponents;
+ ArrayList workInvalidComponents;
/**
* Whether or not double buffering is enabled on this repaint
* manager. This is merely a hint to clients; the RepaintManager will
* always return an offscreen buffer when one is requested.
*
- * @see #getDoubleBufferingEnabled
+ * @see #isDoubleBufferingEnabled
* @see #setDoubleBufferingEnabled
*/
boolean doubleBufferingEnabled;
@@ -184,7 +253,7 @@ public class RepaintManager
* components in all windows. This is package-private to avoid an accessor
* method.
*
- * @see #currentManager
+ * @see #currentManager(JComponent)
* @see #setCurrentManager
*/
static RepaintManager globalManager;
@@ -194,8 +263,12 @@ public class RepaintManager
*/
public RepaintManager()
{
- dirtyComponents = new Hashtable();
- invalidComponents = new Vector();
+ dirtyComponents = new HashMap();
+ workDirtyComponents = new HashMap();
+ repaintOrder = new ArrayList();
+ workRepaintOrder = new ArrayList();
+ invalidComponents = new ArrayList();
+ workInvalidComponents = new ArrayList();
repaintWorker = new RepaintWorker();
doubleBufferMaximumSize = new Dimension(2000,2000);
doubleBufferingEnabled = true;
@@ -291,7 +364,7 @@ public class RepaintManager
*/
public synchronized void removeInvalidComponent(JComponent component)
{
- invalidComponents.removeElement(component);
+ invalidComponents.remove(component);
}
/**
@@ -315,12 +388,13 @@ public class RepaintManager
public synchronized void addDirtyRegion(JComponent component, int x, int y,
int w, int h)
{
- if (w == 0 || h == 0)
+ if (w == 0 || h == 0 || !component.isShowing())
return;
-
Rectangle r = new Rectangle(x, y, w, h);
if (dirtyComponents.containsKey(component))
r = r.union((Rectangle)dirtyComponents.get(component));
+ else
+ insertInRepaintOrder(component);
dirtyComponents.put(component, r);
if (! repaintWorker.isLive())
{
@@ -328,7 +402,23 @@ public class RepaintManager
SwingUtilities.invokeLater(repaintWorker);
}
}
-
+
+ /**
+ * Inserts a component into the repaintOrder list in an ordered fashion,
+ * using a binary search.
+ *
+ * @param c the component to be inserted
+ */
+ private void insertInRepaintOrder(JComponent c)
+ {
+ if (comparator == null)
+ comparator = new ComponentComparator();
+ int insertIndex = Collections.binarySearch(repaintOrder, c, comparator);
+ if (insertIndex < 0)
+ insertIndex = -(insertIndex + 1);
+ repaintOrder.add(insertIndex, c);
+ }
+
/**
* Get the dirty region associated with a component, or <code>null</code>
* if the component has no dirty region.
@@ -345,7 +435,10 @@ public class RepaintManager
*/
public Rectangle getDirtyRegion(JComponent component)
{
- return (Rectangle) dirtyComponents.get(component);
+ Rectangle dirty = (Rectangle) dirtyComponents.get(component);
+ if (dirty == null)
+ dirty = new Rectangle();
+ return dirty;
}
/**
@@ -363,6 +456,7 @@ public class RepaintManager
{
Rectangle r = component.getBounds();
addDirtyRegion(component, r.x, r.y, r.width, r.height);
+ component.isCompletelyDirty = true;
}
/**
@@ -378,7 +472,11 @@ public class RepaintManager
*/
public void markCompletelyClean(JComponent component)
{
- dirtyComponents.remove(component);
+ synchronized (this)
+ {
+ dirtyComponents.remove(component);
+ }
+ component.isCompletelyDirty = false;
}
/**
@@ -397,13 +495,9 @@ public class RepaintManager
*/
public boolean isCompletelyDirty(JComponent component)
{
- Rectangle dirty = (Rectangle) dirtyComponents.get(component);
- if (dirty == null)
+ if (! dirtyComponents.containsKey(component))
return false;
- Rectangle r = component.getBounds();
- if (r == null)
- return true;
- return dirty.contains(r);
+ return component.isCompletelyDirty;
}
/**
@@ -412,58 +506,56 @@ public class RepaintManager
*/
public void validateInvalidComponents()
{
- for (Enumeration e = invalidComponents.elements(); e.hasMoreElements(); )
+ // In order to keep the blocking of application threads minimal, we switch
+ // the invalidComponents field with the workInvalidComponents field and
+ // work with the workInvalidComponents field.
+ synchronized(this)
+ {
+ ArrayList swap = invalidComponents;
+ invalidComponents = workInvalidComponents;
+ workInvalidComponents = swap;
+ }
+ for (Iterator i = workInvalidComponents.iterator(); i.hasNext(); )
{
- JComponent comp = (JComponent) e.nextElement();
+ JComponent comp = (JComponent) i.next();
if (! (comp.isVisible() && comp.isShowing()))
continue;
comp.validate();
}
- invalidComponents.clear();
+ workInvalidComponents.clear();
}
/**
* Repaint all regions of all components which have been marked dirty in
* the {@link #dirtyComponents} table.
*/
- public void paintDirtyRegions()
+ public synchronized void paintDirtyRegions()
{
- // step 1: pull out roots and calculate spanning damage
-
- HashMap roots = new HashMap();
- for (Enumeration e = dirtyComponents.keys(); e.hasMoreElements(); )
+ // In order to keep the blocking of application threads minimal, we switch
+ // the dirtyComponents field with the workdirtyComponents field and the
+ // repaintOrder field with the workRepaintOrder field and work with the
+ // work* fields.
+ synchronized(this)
+ {
+ ArrayList swap = workRepaintOrder;
+ workRepaintOrder = repaintOrder;
+ repaintOrder = swap;
+ HashMap swap2 = workDirtyComponents;
+ workDirtyComponents = dirtyComponents;
+ dirtyComponents = swap2;
+ }
+ for (Iterator i = workRepaintOrder.iterator(); i.hasNext();)
{
- JComponent comp = (JComponent) e.nextElement();
- if (! (comp.isVisible() && comp.isShowing()))
- continue;
- Rectangle damaged = getDirtyRegion(comp);
- if (damaged.width == 0 || damaged.height == 0)
- continue;
- JRootPane root = comp.getRootPane();
- // If the component has no root, no repainting will occur.
- if (root == null)
+ JComponent comp = (JComponent) i.next();
+ // If a component is marked completely clean in the meantime, then skip
+ // it.
+ Rectangle damaged = (Rectangle) workDirtyComponents.get(comp);
+ if (damaged == null || damaged.isEmpty())
continue;
- Rectangle rootDamage = SwingUtilities.convertRectangle(comp, damaged, root);
- if (! roots.containsKey(root))
- {
- roots.put(root, rootDamage);
- }
- else
- {
- roots.put(root, ((Rectangle)roots.get(root)).union(rootDamage));
- }
- }
- dirtyComponents.clear();
-
- // step 2: paint those roots
- Iterator i = roots.entrySet().iterator();
- while(i.hasNext())
- {
- Map.Entry ent = (Map.Entry) i.next();
- JRootPane root = (JRootPane) ent.getKey();
- Rectangle rect = (Rectangle) ent.getValue();
- root.paintImmediately(rect);
+ comp.paintImmediately(damaged);
}
+ workRepaintOrder.clear();
+ workDirtyComponents.clear();
}
/**
diff --git a/javax/swing/ScrollPaneLayout.java b/javax/swing/ScrollPaneLayout.java
index 940d47d35..edf1f1f42 100644
--- a/javax/swing/ScrollPaneLayout.java
+++ b/javax/swing/ScrollPaneLayout.java
@@ -43,12 +43,9 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
-import java.awt.Point;
import java.awt.Rectangle;
import java.io.Serializable;
-import javax.swing.border.Border;
-
/**
* ScrollPaneLayout
* @author Andrew Selkirk
@@ -60,8 +57,11 @@ public class ScrollPaneLayout
private static final long serialVersionUID = -4480022884523193743L;
public static class UIResource extends ScrollPaneLayout
- implements javax.swing.plaf.UIResource {
- public UIResource() {
+ implements javax.swing.plaf.UIResource
+ {
+ public UIResource()
+ {
+ super();
}
}
@@ -77,8 +77,9 @@ public class ScrollPaneLayout
protected int vsbPolicy;
protected int hsbPolicy;
- public ScrollPaneLayout() {
-
+ public ScrollPaneLayout()
+ {
+ // Nothing to do here.
}
public void syncWithScrollPane(JScrollPane scrollPane) {
@@ -251,151 +252,53 @@ public class ScrollPaneLayout
return null;
}
- private static void maybeSetPreferredSize(JComponent src, Dimension dim)
- {
- Dimension tmp = null;
- if (src != null)
- tmp = src.getPreferredSize();
- if (tmp != null)
- dim.setSize(tmp);
- }
-
- private static void maybeSetMinimumSize(JComponent src, Dimension dim)
- {
- Dimension tmp = null;
- if (src != null)
- tmp = src.getMinimumSize();
- if (tmp != null)
- dim.setSize(tmp);
- }
-
public Dimension preferredLayoutSize(Container parent)
{
- if (parent != null && parent instanceof JScrollPane)
- {
- JScrollPane sc = (JScrollPane) parent;
- synchronized (sc.getTreeLock ())
- {
- Dimension insetsSize = new Dimension(0,0);
- Dimension viewportSize = new Dimension(0,0);
- Dimension viewportInsetsSize = new Dimension(0,0);
- Dimension columnHeaderSize = new Dimension(0,0);
- Dimension rowHeaderSize = new Dimension(0,0);
- Dimension verticalScrollBarSize = new Dimension(0,0);
- Dimension horizontalScrollBarSize = new Dimension(0,0);
-
- Insets insets = sc.getInsets();
- Border viewportBorder = sc.getViewportBorder();
- Insets viewportInsets = null;
-
- if (viewportBorder != null)
- {
- viewportInsets = viewportBorder.getBorderInsets(parent);
- if (viewportInsets != null)
- viewportInsetsSize.setSize(viewportInsets.left + viewportInsets.right,
- viewportInsets.top + viewportInsets.bottom);
- }
-
- if (insets != null)
- insetsSize.setSize(insets.left + insets.right,
- insets.top + insets.bottom);
-
- if (viewport != null)
- {
- Component view = null;
- Scrollable scr = null;
- Dimension pref = null;
-
- view = viewport.getView();
- if (view != null && view instanceof Scrollable)
- scr = (Scrollable) view;
- if (scr != null)
- pref = scr.getPreferredScrollableViewportSize();
- if (pref == null)
- pref = viewport.getPreferredSize();
- if (pref != null)
- viewportSize.setSize(pref);
- }
-
- maybeSetPreferredSize(colHead, columnHeaderSize);
- maybeSetPreferredSize(rowHead, rowHeaderSize);
- maybeSetPreferredSize(vsb, verticalScrollBarSize);
- maybeSetPreferredSize(hsb, horizontalScrollBarSize);
-
- return new Dimension(insetsSize.width
- + viewportSize.width
- + viewportInsetsSize.width
- + rowHeaderSize.width
- + verticalScrollBarSize.width,
- insetsSize.height
- + viewportSize.height
- + viewportInsetsSize.height
- + columnHeaderSize.height
- + horizontalScrollBarSize.height);
- }
- }
- else
- {
- return new Dimension(0,0);
- }
+ // Sun's implementation simply throws a ClassCastException if
+ // parent is no JScrollPane, so do we.
+ JScrollPane sc = (JScrollPane) parent;
+ Dimension viewportSize = viewport.getPreferredSize();
+ Dimension viewSize = viewport.getViewSize();
+ int width = viewportSize.width;
+ int height = viewportSize.height;
+
+ // horizontal scrollbar needed if the view's preferred width
+ // is larger than the viewport's preferred width
+ if (hsb != null && viewSize.width > viewportSize.width)
+ height += hsb.getPreferredSize().height;
+
+ // vertical scrollbar needed if the view's preferred height
+ // is larger than the viewport's preferred height
+ if (vsb != null && viewSize.height > viewportSize.height)
+ width += vsb.getPreferredSize().width;
+ if (rowHead != null && rowHead.isVisible())
+ width += rowHead.getPreferredSize().width;
+ if (colHead != null && colHead.isVisible())
+ height += colHead.getPreferredSize().height;
+ Insets i = sc.getInsets();
+ return new Dimension(width + i.left + i.right,
+ height + i.left + i.right);
}
public Dimension minimumLayoutSize(Container parent)
{
- if (parent instanceof JScrollPane)
- {
- JScrollPane sc = (JScrollPane) parent;
- synchronized (sc.getTreeLock ())
- {
- Dimension insetsSize = new Dimension(0,0);
- Dimension viewportSize = new Dimension(0,0);
- Dimension viewportInsetsSize = new Dimension(0,0);
- Dimension columnHeaderSize = new Dimension(0,0);
- Dimension rowHeaderSize = new Dimension(0,0);
- Dimension verticalScrollBarSize = new Dimension(0,0);
- Dimension horizontalScrollBarSize = new Dimension(0,0);
-
- Insets insets = sc.getInsets();
- Border viewportBorder = sc.getViewportBorder();
- Insets viewportInsets = null;
-
- if (viewportBorder != null)
- {
- viewportInsets = viewportBorder.getBorderInsets(parent);
- if (viewportInsets != null)
- viewportInsetsSize.setSize(viewportInsets.left + viewportInsets.right,
- viewportInsets.top + viewportInsets.bottom);
- }
-
- if (insets != null)
- insetsSize.setSize(insets.left + insets.right,
- insets.top + insets.bottom);
-
- maybeSetMinimumSize(colHead, columnHeaderSize);
- maybeSetMinimumSize(rowHead, rowHeaderSize);
-
- if (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)
- maybeSetMinimumSize(vsb, verticalScrollBarSize);
-
- if (hsbPolicy != HORIZONTAL_SCROLLBAR_NEVER)
- maybeSetMinimumSize(hsb, horizontalScrollBarSize);
-
- return new Dimension(insetsSize.width
- + viewportSize.width
- + viewportInsetsSize.width
- + rowHeaderSize.width
- + verticalScrollBarSize.width,
- insetsSize.height
- + viewportSize.height
- + viewportInsetsSize.height
- + columnHeaderSize.height
- + horizontalScrollBarSize.height);
- }
- }
- else
- {
- return new Dimension(0,0);
- }
+ // Sun's implementation simply throws a ClassCastException if
+ // parent is no JScrollPane, so do we.
+ JScrollPane sc = (JScrollPane) parent;
+ Dimension viewportSize = viewport.getMinimumSize();
+ int width = viewportSize.width;
+ int height = viewportSize.height;
+ if (hsb != null && hsb.isVisible())
+ height += hsb.getMinimumSize().height;
+ if (vsb != null && vsb.isVisible())
+ width += vsb.getMinimumSize().width;
+ if (rowHead != null && rowHead.isVisible())
+ width += rowHead.getMinimumSize().width;
+ if (colHead != null && colHead.isVisible())
+ height += colHead.getMinimumSize().height;
+ Insets i = sc.getInsets();
+ return new Dimension(width + i.left + i.right,
+ height + i.top + i.bottom);
}
/**
@@ -421,100 +324,91 @@ public class ScrollPaneLayout
*/
public void layoutContainer(Container parent)
{
- if (parent instanceof JScrollPane)
+ // Sun's implementation simply throws a ClassCastException if
+ // parent is no JScrollPane, so do we.
+ JScrollPane sc = (JScrollPane) parent;
+ JViewport viewport = sc.getViewport();
+ Dimension viewSize = viewport.getViewSize();
+
+ int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
+ int y1 = 0, y2 = 0, y3 = 0, y4 = 0;
+ Rectangle scrollPaneBounds = SwingUtilities.calculateInnerArea(sc, null);
+
+ x1 = scrollPaneBounds.x;
+ y1 = scrollPaneBounds.y;
+ x4 = scrollPaneBounds.x + scrollPaneBounds.width;
+ y4 = scrollPaneBounds.y + scrollPaneBounds.height;
+ if (colHead != null)
+ y2 = y1 + colHead.getPreferredSize().height;
+ else
+ y2 = y1;
+
+ if (rowHead != null)
+ x2 = x1 + rowHead.getPreferredSize().width;
+ else
+ x2 = x1;
+
+ int vsbPolicy = sc.getVerticalScrollBarPolicy();
+ int hsbPolicy = sc.getHorizontalScrollBarPolicy();
+
+ boolean showVsb =
+ (vsb != null)
+ && ((vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS)
+ || (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED
+ && viewSize.height > (y4 - y2)));
+ boolean showHsb =
+ (hsb != null)
+ && ((hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS)
+ || (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
+ && viewSize.width > (x4 - x2)));
+
+ if (!showVsb)
+ x3 = x4;
+ else
+ x3 = x4 - vsb.getPreferredSize().width;
+
+ if (!showHsb)
+ y3 = y4;
+ else
+ y3 = y4 - hsb.getPreferredSize().height;
+
+ // now set the layout
+ if (viewport != null)
+ viewport.setBounds(new Rectangle(x2, y2, x3 - x2, y3 - y2));
+
+ if (colHead != null)
+ colHead.setBounds(new Rectangle(x2, y1, x3 - x2, y2 - y1));
+
+ if (rowHead != null)
+ rowHead.setBounds(new Rectangle(x1, y2, x2 - x1, y3 - y2));
+
+ if (showVsb)
+ {
+ vsb.setVisible(true);
+ vsb.setBounds(new Rectangle(x3, y2, x4 - x3, y3 - y2));
+ }
+ else if (vsb != null)
+ vsb.setVisible(false);
+
+ if (showHsb)
{
- JScrollPane sc = (JScrollPane) parent;
- synchronized (sc.getTreeLock ())
- {
- JViewport viewport = sc.getViewport();
- Dimension viewSize = viewport.getViewSize();
- Point viewPos = viewport.getViewPosition();
-
- int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
- int y1 = 0, y2 = 0, y3 = 0, y4 = 0;
-
- Rectangle scrollPaneBounds = SwingUtilities.calculateInnerArea(sc, null);
-
- x1 = scrollPaneBounds.x;
- y1 = scrollPaneBounds.y;
- x4 = scrollPaneBounds.x + scrollPaneBounds.width;
- y4 = scrollPaneBounds.y + scrollPaneBounds.height;
-
- if (colHead != null)
- y2 = y1 + colHead.getPreferredSize().height;
- else
- y2 = y1;
-
- if (rowHead != null)
- x2 = x1 + rowHead.getPreferredSize().width;
- else
- x2 = x1;
-
- int vsbPolicy = sc.getVerticalScrollBarPolicy();
- int hsbPolicy = sc.getHorizontalScrollBarPolicy();
-
- x3 = x4 - vsb.getPreferredSize().width;
- y3 = y4 - hsb.getPreferredSize().height;
-
- boolean showVsb =
- (vsb != null)
- && ((vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS)
- || (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED
- && viewSize.height > (y3 - y2)));
-
- boolean showHsb =
- (hsb != null)
- && ((hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS)
- || (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
- && viewSize.width > (x3 - x2)));
-
- if (!showVsb)
- x3 = x4;
-
- if (!showHsb)
- y3 = y4;
-
- // now set the layout
-
- if (viewport != null)
- viewport.setBounds(new Rectangle(x2, y2, x3-x2, y3-y2));
-
- if (colHead != null)
- colHead.setBounds(new Rectangle(x2, y1, x3-x2, y2-y1));
-
- if (rowHead != null)
- rowHead.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2));
-
- if (showVsb)
- {
- vsb.setVisible(true);
- vsb.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
- }
- else if (vsb != null)
- vsb.setVisible(false);
-
- if (showHsb)
- {
- hsb.setVisible(true);
- hsb.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3));
- }
- else if (hsb != null)
- hsb.setVisible(false);
-
- if (upperLeft != null)
- upperLeft.setBounds(new Rectangle(x1, y1, x2-x1, y2-y1));
-
- if (upperRight != null)
- upperRight.setBounds(new Rectangle(x3, y1, x4-x3, y2-y1));
-
- if (lowerLeft != null)
- lowerLeft.setBounds(new Rectangle(x1, y3, x2-x1, y4-y3));
-
- if (lowerRight != null)
- lowerRight.setBounds(new Rectangle(x3, y3, x4-x3, y4-y3));
-
- }
+ hsb.setVisible(true);
+ hsb.setBounds(new Rectangle(x2, y3, x3 - x2, y4 - y3));
}
+ else if (hsb != null)
+ hsb.setVisible(false);
+
+ if (upperLeft != null)
+ upperLeft.setBounds(new Rectangle(x1, y1, x2 - x1, y2 - y1));
+
+ if (upperRight != null)
+ upperRight.setBounds(new Rectangle(x3, y1, x4 - x3, y2 - y1));
+
+ if (lowerLeft != null)
+ lowerLeft.setBounds(new Rectangle(x1, y3, x2 - x1, y4 - y3));
+
+ if (lowerRight != null)
+ lowerRight.setBounds(new Rectangle(x3, y3, x4 - x3, y4 - y3));
}
/**
diff --git a/javax/swing/SizeRequirements.java b/javax/swing/SizeRequirements.java
index 4f9d41824..dc855dd32 100644
--- a/javax/swing/SizeRequirements.java
+++ b/javax/swing/SizeRequirements.java
@@ -166,7 +166,34 @@ public class SizeRequirements implements Serializable
public static SizeRequirements
getAlignedSizeRequirements(SizeRequirements[] children)
{
- return null; // TODO
+ float minLeft = 0;
+ float minRight = 0;
+ float prefLeft = 0;
+ float prefRight = 0;
+ float maxLeft = 0;
+ float maxRight = 0;
+ for (int i = 0; i < children.length; i++)
+ {
+ float myMinLeft = children[i].minimum * children[i].alignment;
+ float myMinRight = children[i].minimum - myMinLeft;
+ minLeft = Math.max(myMinLeft, minLeft);
+ minRight = Math.max(myMinRight, minRight);
+ float myPrefLeft = children[i].preferred * children[i].alignment;
+ float myPrefRight = children[i].preferred - myPrefLeft;
+ prefLeft = Math.max(myPrefLeft, prefLeft);
+ prefRight = Math.max(myPrefRight, prefRight);
+ float myMaxLeft = children[i].maximum * children[i].alignment;
+ float myMaxRight = children[i].maximum - myMaxLeft;
+ maxLeft = Math.max(myMaxLeft, maxLeft);
+ maxRight = Math.max(myMaxRight, maxRight);
+ }
+ int minSize = (int) (minLeft + minRight);
+ int prefSize = (int) (prefLeft + prefRight);
+ int maxSize = (int) (maxLeft + maxRight);
+ float align = prefLeft / (prefRight + prefLeft);
+ if (Float.isNaN(align))
+ align = 0;
+ return new SizeRequirements(minSize, prefSize, maxSize, align);
}
/**
@@ -232,6 +259,7 @@ public class SizeRequirements implements Serializable
int[] offsets, int[] spans,
boolean forward)
{
+ int span = 0;
if (forward)
{
int offset = 0;
@@ -239,6 +267,7 @@ public class SizeRequirements implements Serializable
{
offsets[i] = offset;
spans[i] = children[i].preferred;
+ span += spans[i];
offset += children[i].preferred;
}
}
@@ -249,9 +278,86 @@ public class SizeRequirements implements Serializable
{
offset -= children[i].preferred;
offsets[i] = offset;
+ span += spans[i];
spans[i] = children[i].preferred;
}
}
+ // Adjust spans so that we exactly fill the allocated region. If
+ if (span > allocated)
+ adjustSmaller(allocated, children, spans, span);
+ else if (span < allocated)
+ adjustGreater(allocated, children, spans, span);
+
+ // Adjust offsets.
+ if (forward)
+ {
+ int offset = 0;
+ for (int i = 0; i < children.length; i++)
+ {
+ offsets[i] = offset;
+ offset += spans[i];
+ }
+ }
+ else
+ {
+ int offset = allocated;
+ for (int i = 0; i < children.length; i++)
+ {
+ offset -= spans[i];
+ offsets[i] = offset;
+ }
+ }
+ }
+
+ private static void adjustSmaller(int allocated, SizeRequirements[] children,
+ int[] spans, int span)
+ {
+ // Sum up (prefSize - minSize) over all children
+ int sumDelta = 0;
+ for (int i = 0; i < children.length; i++)
+ sumDelta += children[i].preferred - children[i].minimum;
+
+ // If we have sumDelta == 0, then all components have prefSize == maxSize
+ // and we can't do anything about it.
+ if (sumDelta == 0)
+ return;
+
+ // Adjust all sizes according to their preferred and minimum sizes.
+ for (int i = 0; i < children.length; i++)
+ {
+ double factor = ((double) (children[i].preferred - children[i].minimum))
+ / ((double) sumDelta);
+ // In case we have a sumDelta of 0, the factor should also be 0.
+ if (Double.isNaN(factor))
+ factor = 0;
+ spans[i] -= factor * (span - allocated);
+ }
+ }
+
+ private static void adjustGreater(int allocated, SizeRequirements[] children,
+ int[] spans, int span)
+ {
+ // Sum up (maxSize - prefSize) over all children
+ int sumDelta = 0;
+ for (int i = 0; i < children.length; i++)
+ {
+ sumDelta += children[i].maximum - children[i].preferred;
+ if (sumDelta < 0)
+ sumDelta = Integer.MAX_VALUE;
+ }
+
+ // If we have sumDelta == 0, then all components have prefSize == maxSize
+ // and we can't do anything about it.
+ if (sumDelta == 0)
+ return;
+
+ // Adjust all sizes according to their preferred and minimum sizes.
+ for (int i = 0; i < children.length; i++)
+ {
+ double factor = ((double) (children[i].maximum - children[i].preferred))
+ / ((double) sumDelta);
+ spans[i] -= factor * (span - allocated);
+ }
}
/**
@@ -317,15 +423,77 @@ public class SizeRequirements implements Serializable
int[] offset, int[] spans,
boolean forward)
{
- // TODO: Implement this correctly.
- for (int i = 0; i < children.length; ++i)
+ // First we compute the position of the baseline.
+ float baseline = allocated * total.alignment;
+
+ // Now we can layout the components along the baseline.
+ for (int i = 0; i < children.length; i++)
{
- // This is only a hack to make things work a little.
- spans[i] = Math.min(allocated, children[i].maximum);
+ float align = children[i].alignment;
+ // Try to fit the component into the available space.
+ int[] spanAndOffset = new int[2];
+ if (align < .5F || baseline == 0)
+ adjustFromRight(children[i], baseline, allocated, spanAndOffset);
+ else
+ adjustFromLeft(children[i], baseline, allocated, spanAndOffset);
+ spans[i] = spanAndOffset[0];
+ offset[i] = spanAndOffset[1];
}
}
/**
+ * Adjusts the span and offset of a component for the aligned layout.
+ *
+ * @param reqs
+ * @param baseline
+ * @param allocated
+ * @param spanAndOffset
+ */
+ private static void adjustFromRight(SizeRequirements reqs, float baseline,
+ int allocated, int[] spanAndOffset)
+ {
+ float right = allocated - baseline;
+ // If the resulting span exceeds the maximum of the component, then adjust
+ // accordingly.
+ float maxRight = ((float) reqs.maximum) * (1.F - reqs.alignment);
+ if (right / (1.F - reqs.alignment) > reqs.maximum)
+ right = maxRight;
+ // If we have not enough space on the left side, then adjust accordingly.
+ if (right / (1.F - reqs.alignment) * reqs.alignment > allocated - baseline)
+ right = ((float) (allocated - baseline))
+ / reqs.alignment * (1.F - reqs.alignment);
+
+ spanAndOffset[0] = (int) (right / (1.F - reqs.alignment));
+ spanAndOffset[1] = (int) (baseline - spanAndOffset[0] * reqs.alignment);
+ }
+
+ /**
+ * Adjusts the span and offset of a component for the aligned layout.
+ *
+ * @param reqs
+ * @param baseline
+ * @param allocated
+ * @param spanAndOffset
+ */
+ private static void adjustFromLeft(SizeRequirements reqs, float baseline,
+ int allocated, int[] spanAndOffset)
+ {
+ float left = baseline;
+ // If the resulting span exceeds the maximum of the component, then adjust
+ // accordingly.
+ float maxLeft = ((float) reqs.maximum) * reqs.alignment;
+ if (left / reqs.alignment > reqs.maximum)
+ left = maxLeft;
+ // If we have not enough space on the right side, then adjust accordingly.
+ if (left / reqs.alignment * (1.F - reqs.alignment) > allocated - baseline)
+ left = ((float) (allocated - baseline))
+ / (1.F - reqs.alignment) * reqs.alignment;
+
+ spanAndOffset[0] = (int) (left / reqs.alignment);
+ spanAndOffset[1] = (int) (baseline - spanAndOffset[0] * reqs.alignment);
+ }
+
+ /**
* Returns an array of new preferred sizes for the children based on
* <code>delta</code>. <code>delta</code> specifies a change in the
* allocated space. The sizes of the children will be shortened or
diff --git a/javax/swing/SortingFocusTraversalPolicy.java b/javax/swing/SortingFocusTraversalPolicy.java
index fada17c63..96ef38329 100644
--- a/javax/swing/SortingFocusTraversalPolicy.java
+++ b/javax/swing/SortingFocusTraversalPolicy.java
@@ -72,7 +72,7 @@ public class SortingFocusTraversalPolicy
* simply advance within the containing focus cycle, subject to the
* {@link #comparator} order and the {@link #accept} judgment.</p>
*
- * @see #getNextFocusableComponent
+ * @see #getImplicitDownCycleTraversal()
*/
boolean implicitDownCycleTraversal = true;
diff --git a/javax/swing/Spring.java b/javax/swing/Spring.java
index 69c88c77d..8f7105d49 100644
--- a/javax/swing/Spring.java
+++ b/javax/swing/Spring.java
@@ -65,6 +65,7 @@ public abstract class Spring
*/
protected Spring()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java
index 216057e0e..a1fba1cbd 100644
--- a/javax/swing/SwingUtilities.java
+++ b/javax/swing/SwingUtilities.java
@@ -890,7 +890,7 @@ public class SwingUtilities
iconR.y = 0;
textR.y = (horizontalTextPosition == CENTER
? iconR.height + textIconGap
- : iconR.height - textR.height);
+ : Math.max(iconR.height - textR.height, 0));
break;
case CENTER:
int centerLine = Math.max(textR.height, iconR.height) / 2;
@@ -1116,7 +1116,7 @@ public class SwingUtilities
* <pre>
* [{@link javax.swing.JComponent#getActionMap()}]
* --&gt; [{@link javax.swing.ActionMap}]
- * parent --&gt; [{@link javax.swing.text.KeymapActionMap}]
+ * parent --&gt; [{@link javax.swing.text.JTextComponent.KeymapActionMap}]
* parent --&gt; [{@link javax.swing.plaf.ActionMapUIResource}]
* </pre>
*
@@ -1159,7 +1159,7 @@ public class SwingUtilities
* <pre>
* [{@link javax.swing.JComponent#getInputMap()}]
* --&gt; [{@link javax.swing.InputMap}]
- * parent --&gt; [{@link javax.swing.text.KeymapWrapper}]
+ * parent --&gt; [{@link javax.swing.text.JTextComponent.KeymapWrapper}]
* parent --&gt; [{@link javax.swing.plaf.InputMapUIResource}]
* </pre>
*
diff --git a/javax/swing/ToolTipManager.java b/javax/swing/ToolTipManager.java
index 227144f44..03835794b 100644
--- a/javax/swing/ToolTipManager.java
+++ b/javax/swing/ToolTipManager.java
@@ -44,7 +44,6 @@ import java.awt.FlowLayout;
import java.awt.LayoutManager;
import java.awt.Panel;
import java.awt.Point;
-import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@@ -68,6 +67,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
*/
protected stillInsideTimerAction()
{
+ // Nothing to do here.
}
/**
@@ -93,6 +93,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
*/
protected outsideTimerAction()
{
+ // Nothing to do here.
}
/**
@@ -103,6 +104,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
*/
public void actionPerformed(ActionEvent event)
{
+ // TODO: What should be done here, if anything?
}
}
@@ -118,6 +120,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
*/
protected insideTimerAction()
{
+ // Nothing to do here.
}
/**
@@ -421,13 +424,6 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
insideTimer.stop();
hideTip();
}
-
- if (currentComponent == null)
- currentComponent = (Component) event.getSource();
-
- currentComponent.invalidate();
- currentComponent.validate();
- currentComponent.repaint();
}
/**
@@ -452,16 +448,8 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
public void mouseMoved(MouseEvent event)
{
currentPoint = event.getPoint();
- if (currentTip != null)
- {
- if (currentComponent == null)
- currentComponent = (Component) event.getSource();
-
- String text = ((JComponent) currentComponent).getToolTipText(event);
- currentTip.setTipText(text);
- }
if (enterTimer.isRunning())
- enterTimer.restart();
+ enterTimer.restart();
}
/**
@@ -471,78 +459,103 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
*/
void showTip()
{
- if (! enabled || currentComponent == null ||
- (currentTip != null && currentTip.isVisible()))
+ if (!enabled || currentComponent == null || !currentComponent.isEnabled()
+ || (currentTip != null && currentTip.isVisible()))
return;
- if (currentTip == null
- || currentTip.getComponent() != currentComponent
+ if (currentTip == null || currentTip.getComponent() != currentComponent
&& currentComponent instanceof JComponent)
currentTip = ((JComponent) currentComponent).createToolTip();
-
+
+ currentTip.setVisible(true);
+ Container parent = currentComponent.getParent();
Point p = currentPoint;
Dimension dims = currentTip.getPreferredSize();
- if (canToolTipFit(currentTip))
- {
- JLayeredPane pane = ((JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,
- currentComponent))
- .getLayeredPane();
-
- // This should never happen, but just in case.
- if (pane == null)
- return;
-
- if (containerPanel != null)
- hideTip();
- if (isLightWeightPopupEnabled())
- {
- containerPanel = new Panel();
- JRootPane root = new JRootPane();
- root.getContentPane().add(currentTip);
- containerPanel.add(root);
- }
- else
- {
- containerPanel = new JPanel();
- containerPanel.add(currentTip);
- }
- LayoutManager lm = containerPanel.getLayout();
- if (lm instanceof FlowLayout)
- {
- FlowLayout fm = (FlowLayout) lm;
- fm.setVgap(0);
- fm.setHgap(0);
- }
-
- p = getGoodPoint(p, pane, currentTip, dims);
-
- pane.add(containerPanel);
- containerPanel.setBounds(p.x, p.y, dims.width, dims.height);
- currentTip.setBounds(0, 0, dims.width, dims.height);
-
- pane.revalidate();
- pane.repaint();
- }
+
+ if (parent instanceof JPopupMenu)
+ setLightWeightPopupEnabled(((JPopupMenu) parent).isLightWeightPopupEnabled());
else
+ setLightWeightPopupEnabled(true);
+
+ if (isLightWeightPopupEnabled())
{
- if (currentComponent.isShowing())
+ JLayeredPane pane = null;
+ JRootPane r = ((JRootPane) SwingUtilities.
+ getAncestorOfClass(JRootPane.class, currentComponent));
+ if (r != null)
+ pane = r.getLayeredPane();
+ if (pane == null)
+ return;
+
+ if (containerPanel != null)
+ hideTip();
+
+ containerPanel = new Panel();
+ JRootPane root = new JRootPane();
+ root.getContentPane().add(currentTip);
+ containerPanel.add(root);
+
+ LayoutManager lm = containerPanel.getLayout();
+ if (lm instanceof FlowLayout)
{
- SwingUtilities.convertPointToScreen(p, currentComponent);
- tooltipWindow = new JDialog();
- tooltipWindow.getContentPane().add(currentTip);
- tooltipWindow.setUndecorated(true);
- tooltipWindow.getRootPane().
- setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
- tooltipWindow.setFocusable(false);
- tooltipWindow.pack();
- tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
- tooltipWindow.show();
+ FlowLayout fm = (FlowLayout) lm;
+ fm.setVgap(0);
+ fm.setHgap(0);
}
+
+ p = SwingUtilities.convertPoint(currentComponent, p, pane);
+ p = adjustLocation(p, pane, dims);
+
+ pane.add(containerPanel);
+ containerPanel.setBounds(p.x, p.y, dims.width, dims.height);
+ currentTip.setBounds(0, 0, dims.width, dims.height);
+ containerPanel.validate();
+ containerPanel.repaint();
+ }
+ else if (currentComponent.isShowing())
+ {
+ SwingUtilities.convertPointToScreen(p, currentComponent);
+ p = adjustLocation(p, SwingUtilities.getWindowAncestor(currentComponent),
+ dims);
+
+ tooltipWindow = new JDialog();
+ tooltipWindow.setContentPane(currentTip);
+ tooltipWindow.setUndecorated(true);
+ tooltipWindow.getRootPane().
+ setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
+ tooltipWindow.pack();
+ tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
+ tooltipWindow.show();
+ tooltipWindow.validate();
+ tooltipWindow.repaint();
+ currentTip.revalidate();
+ currentTip.repaint();
}
- currentTip.setVisible(true);
}
/**
+ * Adjusts the point to a new location on the component,
+ * using the currentTip's dimensions.
+ *
+ * @param p - the point to convert.
+ * @param c - the component the point is on.
+ * @param d - the dimensions of the currentTip.
+ */
+ private Point adjustLocation(Point p, Component c, Dimension d)
+ {
+ if (p.x + d.width > c.getWidth())
+ p.x -= d.width;
+ if (p.x < 0)
+ p.x = 0;
+ if (p.y + d.height < c.getHeight())
+ p.y += d.height;
+ if (p.y + d.height > c.getHeight())
+ p.y -= d.height*2;
+
+ return p;
+ }
+
+ /**
* This method hides the ToolTip.
* This is package-private to avoid an accessor method.
*/
@@ -557,15 +570,11 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
if (parent == null)
return;
parent.remove(containerPanel);
- parent.invalidate();
- parent.validate();
- parent.repaint();
parent = currentTip.getParent();
if (parent == null)
return;
parent.remove(currentTip);
-
containerPanel = null;
}
if (tooltipWindow != null)
@@ -574,35 +583,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
tooltipWindow.dispose();
tooltipWindow = null;
}
- }
-
- /**
- * This method returns a point in the LayeredPane where the ToolTip can be
- * shown. The point returned (if the ToolTip is to be displayed at the
- * preferred dimensions) will always place the ToolTip inside the
- * currentComponent if possible.
- *
- * @param p The last known good point for the mouse.
- * @param c The JLayeredPane in the first RootPaneContainer up from the
- * currentComponent.
- * @param tip The ToolTip to display.
- * @param dims The ToolTip preferred dimensions (can be null).
- *
- * @return A good point to place the ToolTip.
- */
- private Point getGoodPoint(Point p, JLayeredPane c, JToolTip tip,
- Dimension dims)
- {
- if (dims == null)
- dims = tip.getPreferredSize();
- Rectangle bounds = currentComponent.getBounds();
- if (p.x + dims.width > bounds.width)
- p.x = bounds.width - dims.width;
- if (p.y + dims.height > bounds.height)
- p.y = bounds.height - dims.height;
-
- p = SwingUtilities.convertPoint(currentComponent, p, c);
- return p;
+ currentTip = null;
}
/**
@@ -627,25 +608,4 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
Component target = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
return target;
}
-
- /**
- * This method returns whether the ToolTip can fit in the first
- * RootPaneContainer up from the currentComponent.
- *
- * @param tip The ToolTip.
- *
- * @return Whether the ToolTip can fit.
- */
- private boolean canToolTipFit(JToolTip tip)
- {
- JRootPane root = (JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,
- currentComponent);
- if (root == null)
- return false;
- Dimension pref = tip.getPreferredSize();
- Dimension rootSize = root.getSize();
- if (rootSize.width > pref.width && rootSize.height > pref.height)
- return true;
- return false;
- }
}
diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java
index 96cb9d42a..73479f5c8 100644
--- a/javax/swing/TransferHandler.java
+++ b/javax/swing/TransferHandler.java
@@ -162,15 +162,18 @@ public class TransferHandler implements Serializable
}
public void exportAsDrag (JComponent c, InputEvent e, int action)
- {
+ {
+ // TODO: Implement this properly
}
protected void exportDone (JComponent c, Transferable data, int action)
{
+ // TODO: Implement this properly
}
public void exportToClipboard(JComponent c, Clipboard clip, int action)
{
+ // TODO: Implement this properly
}
public int getSourceActions (JComponent c)
diff --git a/javax/swing/UIDefaults.java b/javax/swing/UIDefaults.java
index ab78ca644..f6aee1b94 100644
--- a/javax/swing/UIDefaults.java
+++ b/javax/swing/UIDefaults.java
@@ -577,8 +577,8 @@ public class UIDefaults extends Hashtable
*
* @param key the key to the requested entry
*
- * @return the boolean entry for <code>key</code> or null if no such entry
- * exists
+ * @return The boolean entry for <code>key</code> or <code>false</code> if no
+ * such entry exists.
*/
public boolean getBoolean(Object key)
{
@@ -674,9 +674,9 @@ public class UIDefaults extends Hashtable
return null;
try
{
- if (loader != null)
- return loader.loadClass (className);
- return Class.forName (className);
+ if (loader == null)
+ loader = ClassLoader.getSystemClassLoader();
+ return loader.loadClass (className);
}
catch (Exception e)
{
diff --git a/javax/swing/UIManager.java b/javax/swing/UIManager.java
index f4648f1e2..aca816d33 100644
--- a/javax/swing/UIManager.java
+++ b/javax/swing/UIManager.java
@@ -146,19 +146,29 @@ public class UIManager implements Serializable
LookAndFeel laf = (LookAndFeel) lafClass.newInstance();
setLookAndFeel(laf);
}
+ else
+ {
+ setLookAndFeel(new MetalLookAndFeel());
+ }
}
catch (Exception ex)
{
System.err.println("cannot initialize Look and Feel: " + defaultlaf);
System.err.println("error: " + ex.getMessage());
System.err.println("falling back to Metal Look and Feel");
+ try
+ {
+ setLookAndFeel(new MetalLookAndFeel());
+ }
+ catch (Exception ex2)
+ {
+ throw (Error) new AssertionError("There must be no problem installing"
+ + " the MetalLookAndFeel.")
+ .initCause(ex2);
+ }
}
- currentLookAndFeel = new MetalLookAndFeel();
- currentLookAndFeel.initialize();
- currentUIDefaults = currentLookAndFeel.getDefaults();
-
}
-
+
/**
* Creates a new instance of the <code>UIManager</code>. There is no need
* to construct an instance of this class, since all methods are static.
diff --git a/javax/swing/ViewportLayout.java b/javax/swing/ViewportLayout.java
index fe7453fc6..884f7cb27 100644
--- a/javax/swing/ViewportLayout.java
+++ b/javax/swing/ViewportLayout.java
@@ -56,14 +56,17 @@ public class ViewportLayout implements LayoutManager, Serializable
public ViewportLayout()
{
+ // Nothing to do here.
}
public void addLayoutComponent(String name, Component c)
{
+ // Nothing to do here.
}
public void removeLayoutComponent(Component c)
{
+ // Nothing to do here.
}
public Dimension preferredLayoutSize(Container parent)
diff --git a/javax/swing/border/AbstractBorder.java b/javax/swing/border/AbstractBorder.java
index 951debd52..7cbbcdaa8 100644
--- a/javax/swing/border/AbstractBorder.java
+++ b/javax/swing/border/AbstractBorder.java
@@ -52,20 +52,18 @@ import java.io.Serializable;
* @author Sascha Brawer (brawer@dandelis.ch)
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
-public abstract class AbstractBorder
- implements Border, Serializable
+public abstract class AbstractBorder implements Border, Serializable
{
static final long serialVersionUID = -545885975315191844L;
-
/**
* Constructs a new AbstractBorder.
*/
- public AbstractBorder ()
+ public AbstractBorder()
{
+ // Nothing to do here.
}
-
/**
* Performs nothing, because the default implementation provided by
* this class is an invisible, zero-width border. Subclasses will
@@ -79,17 +77,15 @@ public abstract class AbstractBorder
* @param width the width of the available area for painting the border.
* @param height the height of the available area for painting the border.
*/
- public void paintBorder (Component c, Graphics g,
- int x, int y, int width, int height)
+ public void paintBorder(Component c, Graphics g, int x, int y, int width,
+ int height)
{
- /* A previous version of Classpath had emitted a warning when
- * this method was called. The warning was removed because it is
- * perfectly legal for a subclass to not override the paintBorder
- * method. An example would be EmptyBorder.
- */
+ // A previous version of Classpath had emitted a warning when
+ // this method was called. The warning was removed because it is
+ // perfectly legal for a subclass to not override the paintBorder
+ // method. An example would be EmptyBorder.
}
-
/**
* Measures the width of this border.
*
@@ -102,31 +98,29 @@ public abstract class AbstractBorder
*
* @see #getBorderInsets(java.awt.Component, java.awt.Insets)
*/
- public Insets getBorderInsets (Component c)
+ public Insets getBorderInsets(Component c)
{
- return new Insets (0, 0, 0, 0);
+ return new Insets(0, 0, 0, 0);
}
-
/**
* Determines the insets of this border. The implementation provided
* by AbstractButton sets the <code>left</code>, <code>right</code>,
* <code>top</code> and <code>bottom</code> fields of the passed
* <code>insets</code> parameter to zero.
*
- * @param c the component whose border is to be measured.
+ * @param c the component whose border is to be measured
*
- * @return the same object that was passed for <code>insets</code>.
+ * @return the same object that was passed for <code>insets</code>
*
* @see #getBorderInsets(Component)
*/
- public Insets getBorderInsets (Component c, Insets insets)
+ public Insets getBorderInsets(Component c, Insets insets)
{
insets.left = insets.right = insets.top = insets.bottom = 0;
return insets;
}
-
/**
* Determines whether or not this border is opaque. An opaque border
* fills every pixel in its area when painting. Partially
@@ -136,12 +130,11 @@ public abstract class AbstractBorder
*
* @return <code>false</code>.
*/
- public boolean isBorderOpaque ()
+ public boolean isBorderOpaque()
{
return false;
}
-
/**
* Returns a rectangle that covers the specified area minus this
* border. Components that wish to determine an area into which
@@ -154,12 +147,11 @@ public abstract class AbstractBorder
* @param width the width of the available area for the border.
* @param height the height of the available area for the border.
*/
- public Rectangle getInteriorRectangle (Component c,
- int x, int y, int width, int height)
+ public Rectangle getInteriorRectangle(Component c, int x, int y, int width,
+ int height)
{
return getInteriorRectangle (c, this, x, y, width, height);
}
-
/**
* Returns a rectangle that covers the specified area minus a
@@ -173,8 +165,8 @@ public abstract class AbstractBorder
* @param width the width of the available area for the border.
* @param height the height of the available area for the border.
*/
- public static Rectangle getInteriorRectangle (Component c, Border b,
- int x, int y, int width, int height)
+ public static Rectangle getInteriorRectangle(Component c, Border b, int x,
+ int y, int width, int height)
{
Insets borderInsets;
diff --git a/javax/swing/border/BevelBorder.java b/javax/swing/border/BevelBorder.java
index fcdc1c646..45b758cae 100644
--- a/javax/swing/border/BevelBorder.java
+++ b/javax/swing/border/BevelBorder.java
@@ -55,8 +55,7 @@ import java.awt.Insets;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class BevelBorder
- extends AbstractBorder
+public class BevelBorder extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
@@ -508,11 +507,11 @@ public class BevelBorder
* Paints a two-pixel bevel in four colors.
*
* <pre>
- * @@@@@@@@@@@@
- * @..........# @ = color a
- * @. X# . = color b
- * @. X# X = color c
- * @.XXXXXXXXX# # = color d
+ * ++++++++++++
+ * +..........# + = color a
+ * +. X# . = color b
+ * +. X# X = color c
+ * +.XXXXXXXXX# # = color d
* ############</pre>
*
* @param g the graphics for painting.
diff --git a/javax/swing/border/Border.java b/javax/swing/border/Border.java
index 11bddfe78..f4af3fb38 100644
--- a/javax/swing/border/Border.java
+++ b/javax/swing/border/Border.java
@@ -77,9 +77,8 @@ public interface Border
* @param width the width of the available area for painting the border.
* @param height the height of the available area for painting the border.
*/
- void paintBorder(Component c, Graphics g,
- int x, int y, int width, int height);
-
+ void paintBorder(Component c, Graphics g, int x, int y, int width,
+ int height);
/**
* Measures the width of this border.
@@ -92,7 +91,6 @@ public interface Border
*/
Insets getBorderInsets(Component c);
-
/**
* Determines whether this border fills every pixel in its area
* when painting.
diff --git a/javax/swing/border/CompoundBorder.java b/javax/swing/border/CompoundBorder.java
index 2130a0e34..998a9bab3 100644
--- a/javax/swing/border/CompoundBorder.java
+++ b/javax/swing/border/CompoundBorder.java
@@ -48,8 +48,7 @@ import java.awt.Insets;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class CompoundBorder
- extends AbstractBorder
+public class CompoundBorder extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
@@ -57,7 +56,6 @@ public class CompoundBorder
*/
static final long serialVersionUID = 9054540377030555103L;
-
/**
* The inside border, which is painted between the bordered
* Component and the outside border. It is valid for
@@ -65,7 +63,6 @@ public class CompoundBorder
*/
protected Border insideBorder;
-
/**
* The outside border, which is painted outside both the
* bordered Component and the inside border. It is valid for
@@ -73,7 +70,6 @@ public class CompoundBorder
*/
protected Border outsideBorder;
-
/**
* Constructs a CompoundBorder whose inside and outside borders
* are both <code>null</code>. While this does not really make
@@ -83,12 +79,11 @@ public class CompoundBorder
*
* @see EmptyBorder
*/
- public CompoundBorder ()
+ public CompoundBorder()
{
this (null, null);
}
-
/**
* Constructs a CompoundBorder with the specified inside and
* outside borders.
@@ -103,13 +98,12 @@ public class CompoundBorder
* component. It is acceptable to pass <code>null</code>, in
* which case no inside border is painted.
*/
- public CompoundBorder (Border outsideBorder, Border insideBorder)
+ public CompoundBorder(Border outsideBorder, Border insideBorder)
{
this.outsideBorder = outsideBorder;
this.insideBorder = insideBorder;
}
-
/**
* Determines whether or not this border is opaque. An opaque
* border fills every pixel in its area when painting. Partially
@@ -119,20 +113,18 @@ public class CompoundBorder
* @return <code>true</code> if both the inside and outside borders
* are opaque, or <code>false</code> otherwise.
*/
- public boolean isBorderOpaque ()
+ public boolean isBorderOpaque()
{
- /* While it would be safe to assume true for the opacity of
- * a null border, this behavior would not be according to
- * the API specification. Also, it is pathological to have
- * null borders anyway.
- */
+ // While it would be safe to assume true for the opacity of
+ // a null border, this behavior would not be according to
+ // the API specification. Also, it is pathological to have
+ // null borders anyway.
if ((insideBorder == null) || (outsideBorder == null))
return false;
return insideBorder.isBorderOpaque()
&& outsideBorder.isBorderOpaque();
}
-
/**
* Paints the compound border by first painting the outside border,
@@ -148,9 +140,9 @@ public class CompoundBorder
public void paintBorder(Component c, Graphics g,
int x, int y, int width, int height)
{
- /* If there is an outside border, paint it and reduce the
- * bounding box by its insets.
- */
+ // If there is an outside border, paint it and reduce the
+ // bounding box by its insets.
+ //
if (outsideBorder != null)
{
Insets outsideInsets;
@@ -161,9 +153,8 @@ public class CompoundBorder
x += outsideInsets.left;
y += outsideInsets.top;
- /* Reduce width and height by the respective extent of the
- * outside border.
- */
+ // Reduce width and height by the respective extent of the
+ // outside border.
width -= outsideInsets.left + outsideInsets.right;
height -= outsideInsets.top + outsideInsets.bottom;
}
@@ -172,7 +163,6 @@ public class CompoundBorder
insideBorder.paintBorder(c, g, x, y, width, height);
}
-
/**
* Changes the specified insets to the insets of this border,
* which is the sum of the insets of the inside and the outside
@@ -192,7 +182,7 @@ public class CompoundBorder
else
insets.left = insets.right = insets.top = insets.bottom = 0;
- /* If there is an outside border, add it to insets. */
+ // If there is an outside border, add it to insets.
if (outsideBorder != null)
{
borderInsets = outsideBorder.getBorderInsets(c);
@@ -202,7 +192,7 @@ public class CompoundBorder
insets.bottom += borderInsets.bottom;
}
- /* If there is an inside border, add it to insets. */
+ // If there is an inside border, add it to insets.
if (insideBorder != null)
{
borderInsets = insideBorder.getBorderInsets(c);
@@ -215,35 +205,31 @@ public class CompoundBorder
return insets;
}
-
/**
* Determines the insets of this border, which is the sum of the
* insets of the inside and the outside border.
*
* @param c the component in the center of this border.
*/
- public Insets getBorderInsets (Component c)
+ public Insets getBorderInsets(Component c)
{
- /* It is not clear why CompoundBorder does not simply inherit
- * the implementation from AbstractBorder. However, we want
- * to be compatible with the API specification, which overrides
- * the getBorderInsets(Component) method.
- */
+ // It is not clear why CompoundBorder does not simply inherit
+ // the implementation from AbstractBorder. However, we want
+ // to be compatible with the API specification, which overrides
+ // the getBorderInsets(Component) method.
return getBorderInsets (c, null);
}
-
/**
* Returns the outside border, which is painted outside both the
* bordered Component and the inside border. It is valid for the
* result to be <code>null</code>.
*/
- public Border getOutsideBorder ()
+ public Border getOutsideBorder()
{
return outsideBorder;
}
-
/**
* Returns the inside border, which is painted between the bordered
* Component and the outside border. It is valid for the result to
@@ -254,4 +240,3 @@ public class CompoundBorder
return insideBorder;
}
}
-
diff --git a/javax/swing/border/EmptyBorder.java b/javax/swing/border/EmptyBorder.java
index 0f3b7b693..c8e9c6044 100644
--- a/javax/swing/border/EmptyBorder.java
+++ b/javax/swing/border/EmptyBorder.java
@@ -53,8 +53,7 @@ import java.awt.Insets;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class EmptyBorder
- extends AbstractBorder
+public class EmptyBorder extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
@@ -142,6 +141,7 @@ public class EmptyBorder
public void paintBorder(Component c, Graphics g,
int x, int y, int width, int height)
{
+ // Nothing to do here.
}
diff --git a/javax/swing/border/EtchedBorder.java b/javax/swing/border/EtchedBorder.java
index 0bd76ff0f..22882b78c 100644
--- a/javax/swing/border/EtchedBorder.java
+++ b/javax/swing/border/EtchedBorder.java
@@ -56,8 +56,7 @@ import java.awt.Insets;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class EtchedBorder
- extends AbstractBorder
+public class EtchedBorder extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
@@ -199,8 +198,8 @@ public class EtchedBorder
* @param width the width of the available area for painting the border.
* @param height the height of the available area for painting the border.
*/
- public void paintBorder(Component c, Graphics g,
- int x, int y, int width, int height)
+ public void paintBorder(Component c, Graphics g, int x, int y, int width,
+ int height)
{
switch (etchType)
{
@@ -270,16 +269,14 @@ public class EtchedBorder
*/
public boolean isBorderOpaque()
{
- /* If the colors are to be drived from the enclosed Component's
- * background color, the border is guaranteed to be fully opaque
- * because Color.brighten() and Color.darken() always return an
- * opaque color.
- */
+ // If the colors are to be derived from the enclosed Component's
+ // background color, the border is guaranteed to be fully opaque
+ // because Color.brighten() and Color.darken() always return an
+ // opaque color.
return
((highlight == null) || (highlight.getAlpha() == 255))
&& ((shadow == null) || (shadow.getAlpha() == 255));
}
-
/**
* Returns the appearance of this EtchedBorder, which is either
@@ -310,8 +307,7 @@ public class EtchedBorder
else
return c.getBackground().brighter();
}
-
-
+
/**
* Returns the color that will be used for highlighted parts when
* painting the border, or <code>null</code> if that color will be
@@ -359,11 +355,11 @@ public class EtchedBorder
* Paints a two-pixel etching in two colors.
*
* <pre>
- * @@@@@@@@@@@.
- * @.........@. @ = color a
- * @. @. . = color b
- * @. @.
- * @@@@@@@@@@@.
+ * +++++++++++.
+ * +.........+. + = color a
+ * +. +. . = color b
+ * +. +.
+ * +++++++++++.
* ............</pre>
*
* @param g the graphics for painting.
@@ -374,9 +370,8 @@ public class EtchedBorder
* @param a one of the two colors.
* @param b the second of the two colors.
*/
- private static void paintEtchedBorder(Graphics g,
- int x, int y, int width, int height,
- Color a, Color b)
+ private static void paintEtchedBorder(Graphics g, int x, int y, int width,
+ int height, Color a, Color b)
{
Color oldColor;
@@ -387,11 +382,10 @@ public class EtchedBorder
try
{
- /* To understand this code, it might be helpful to look at the
- * images that are included with the JavaDoc. They are located
- * in the "doc-files" subdirectory. EtchedBorder-2.png might
- * be especially informative.
- */
+ // To understand this code, it might be helpful to look at the
+ // images that are included with the JavaDoc. They are located
+ // in the "doc-files" subdirectory. EtchedBorder-2.png might
+ // be especially informative.
g.setColor(a);
g.drawRect(0, 0, width - 1, height - 1);
@@ -408,4 +402,3 @@ public class EtchedBorder
}
}
}
-
diff --git a/javax/swing/border/LineBorder.java b/javax/swing/border/LineBorder.java
index c34e38c57..36abddd91 100644
--- a/javax/swing/border/LineBorder.java
+++ b/javax/swing/border/LineBorder.java
@@ -50,8 +50,7 @@ import java.awt.Insets;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class LineBorder
- extends AbstractBorder
+public class LineBorder extends AbstractBorder
{
/**
* Determined using the <code>serialver</code> tool
@@ -71,7 +70,7 @@ public class LineBorder
/**
* A shared instance of a gray, one pixel thick, plain LineBorder.
* The singleton object is lazily created by {@link
- * #createBlackGrayBorder()} upon its first invocation.
+ * #createGrayLineBorder()} upon its first invocation.
*/
private static LineBorder grayLineBorder;
@@ -213,29 +212,27 @@ public class LineBorder
{
g.setColor(lineColor);
- /* If width and height were not adjusted, the border would
- * appear one pixel too large in both directions.
- */
+ // If width and height were not adjusted, the border would
+ // appear one pixel too large in both directions.
width -= 1;
height -= 1;
- /* Blurred, too large appearance
- * -----------------------------
- * While Java 2D has introduced line strokes of arbitrary width,
- * it seems desirable to keep this code independent of Java 2D.
- * Therefore, multiple nested rectangles (or rounded rectangles)
- * are drawn in order to simulate a line whose thickness is
- * greater than one pixel.
- *
- * This hack causes a blurred appearance when anti-aliasing is
- * on. Interestingly enough, though, the Sun JDK 1.3.1 (at least
- * on MacOS X 10.1.5) shows exactly the same appearance under
- * this condition. It thus seems likely that Sun does the same
- * hack for simulating thick lines. For this reason, the
- * blurred appearance seems acceptable -- especially since GNU
- * Classpath tries to be compatible with the Sun reference
- * implementation.
- */
+ // Blurred, too large appearance
+ // -----------------------------
+ // While Java 2D has introduced line strokes of arbitrary width,
+ // it seems desirable to keep this code independent of Java 2D.
+ // Therefore, multiple nested rectangles (or rounded rectangles)
+ // are drawn in order to simulate a line whose thickness is
+ // greater than one pixel.
+ //
+ // This hack causes a blurred appearance when anti-aliasing is
+ // on. Interestingly enough, though, the Sun JDK 1.3.1 (at least
+ // on MacOS X 10.1.5) shows exactly the same appearance under
+ // this condition. It thus seems likely that Sun does the same
+ // hack for simulating thick lines. For this reason, the
+ // blurred appearance seems acceptable -- especially since GNU
+ // Classpath tries to be compatible with the Sun reference
+ // implementation.
for (int i = 0; i < thickness; i++)
{
if (roundedCorners)
@@ -340,4 +337,3 @@ public class LineBorder
return (!roundedCorners) && (lineColor.getAlpha() == 255);
}
}
-
diff --git a/javax/swing/border/MatteBorder.java b/javax/swing/border/MatteBorder.java
index f7ff1ca01..4d5b8c253 100644
--- a/javax/swing/border/MatteBorder.java
+++ b/javax/swing/border/MatteBorder.java
@@ -54,8 +54,7 @@ import javax.swing.Icon;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class MatteBorder
- extends EmptyBorder
+public class MatteBorder extends EmptyBorder
{
/**
* Determined using the <code>serialver</code> tool
@@ -401,4 +400,3 @@ public class MatteBorder
}
}
}
-
diff --git a/javax/swing/border/SoftBevelBorder.java b/javax/swing/border/SoftBevelBorder.java
index 379ecb65a..028fd00e0 100644
--- a/javax/swing/border/SoftBevelBorder.java
+++ b/javax/swing/border/SoftBevelBorder.java
@@ -55,8 +55,7 @@ import java.awt.Insets;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class SoftBevelBorder
- extends BevelBorder
+public class SoftBevelBorder extends BevelBorder
{
/**
* Determined using the <code>serialver</code> tool
@@ -264,10 +263,10 @@ public class SoftBevelBorder
* Paints a soft bevel in four colors.
*
* <pre>
- * @@@@@@@@@@@.
- * @@.........# @ = color a
- * @.. # . = color b
- * @. # X = color c
+ * +++++++++++.
+ * ++.........# + = color a
+ * +.. # . = color b
+ * +. # X = color c
* .. X# # = color d
* . ##########</pre>
*
@@ -326,4 +325,3 @@ public class SoftBevelBorder
}
}
}
-
diff --git a/javax/swing/border/TitledBorder.java b/javax/swing/border/TitledBorder.java
index 3ed60815a..8d3ee13d4 100644
--- a/javax/swing/border/TitledBorder.java
+++ b/javax/swing/border/TitledBorder.java
@@ -1,5 +1,5 @@
/* TitledBorder.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -58,8 +58,7 @@ import javax.swing.UIManager;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class TitledBorder
- extends AbstractBorder
+public class TitledBorder extends AbstractBorder
{
/**
* A value for the <code>titlePosition</code> property that vertically
@@ -304,7 +303,7 @@ public class TitledBorder
public TitledBorder(String title)
{
this(/* border */ null,
- title, DEFAULT_JUSTIFICATION, DEFAULT_POSITION,
+ title, LEADING, TOP,
/* titleFont */ null, /* titleColor */ null);
}
@@ -317,7 +316,7 @@ public class TitledBorder
*/
public TitledBorder(Border border)
{
- this(border, /* title */ "", DEFAULT_JUSTIFICATION, DEFAULT_POSITION,
+ this(border, /* title */ "", LEADING, TOP,
/* titleFont */ null, /* titleColor */ null);
}
@@ -333,7 +332,7 @@ public class TitledBorder
*/
public TitledBorder(Border border, String title)
{
- this(border, title, DEFAULT_JUSTIFICATION, DEFAULT_POSITION,
+ this(border, title, LEADING, TOP,
/* titleFont */ null, /* titleColor */ null);
}
@@ -507,7 +506,7 @@ public class TitledBorder
public void paint(Graphics g)
{
if (b != null)
- b.paintBorder(c, g, x, y, width - 1, height - 1);
+ b.paintBorder(c, g, x, y, width, height);
}
@@ -565,7 +564,7 @@ public class TitledBorder
if (stripeHeight > 0)
{
paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3
- paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight);
+ paint(g, holeX + holeWidth, holeY, x + width - (holeX + holeWidth), stripeHeight);
}
stripeHeight = height - (holeY - y + holeHeight);
@@ -577,16 +576,16 @@ public class TitledBorder
BorderPainter bp;
int textX, textY, borderWidth, borderHeight;
- borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right);
- borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom);
+ borderWidth = width - (mes.outerSpacing.left + mes.outerSpacing.right);
+ borderHeight = height - (mes.outerSpacing.top + mes.outerSpacing.bottom);
bp = new BorderPainter(c, getBorder(),
- x + mes.borderSpacing.left, y + mes.borderSpacing.top,
+ x + mes.outerSpacing.left, y + mes.outerSpacing.top,
borderWidth, borderHeight);
switch (getRealTitleJustification(c))
{
case LEFT:
- textX = x + TEXT_INSET_H;
+ textX = x + EDGE_SPACING + TEXT_INSET_H;
break;
case CENTER:
@@ -604,22 +603,22 @@ public class TitledBorder
switch (titlePosition)
{
case ABOVE_TOP:
- textY = y;
+ textY = y + EDGE_SPACING;
break;
case TOP:
case DEFAULT_POSITION:
default:
- textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent
+ textY = y + mes.outerSpacing.top + mes.borderInsets.top - mes.textAscent
+ mes.lineHeight;
break;
case BELOW_TOP:
- textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING;
+ textY = y + mes.outerSpacing.top + mes.borderInsets.top + TEXT_SPACING;
break;
case ABOVE_BOTTOM:
- textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom
+ textY = y + height - mes.outerSpacing.bottom - mes.borderInsets.bottom
- TEXT_SPACING - (mes.textAscent + mes.textDescent);
break;
@@ -644,8 +643,8 @@ public class TitledBorder
g.setFont(oldFont);
g.setColor(oldColor);
}
- bp.paintExcept(g, textX - 2, textY,
- mes.textWidth + 2, mes.textAscent + mes.textDescent);
+ bp.paintExcept(g, textX, textY,
+ mes.textWidth, mes.textAscent + mes.textDescent);
}
}
@@ -1002,49 +1001,63 @@ public class TitledBorder
m.trimmedText = null;
}
- m.textAscent = fmet.getAscent();
- m.textDescent = fmet.getDescent();
-
- FontRenderContext frc = new FontRenderContext(new AffineTransform(), false,
- false);
- LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0,
- m.trimmedText.length(), frc);
- m.lineHeight = (int) lmet.getStrikethroughOffset();
- // Fallback in case that LineMetrics is not available/working.
- if (m.lineHeight == 0)
- m.lineHeight = (int) (0.3333 * (double) m.textAscent);
-
if (m.trimmedText != null)
- m.textWidth = fmet.stringWidth(m.trimmedText) + 3;
+ {
+ m.textAscent = fmet.getAscent();
+ m.textDescent = fmet.getDescent() + fmet.getLeading();
+
+ FontRenderContext frc = new FontRenderContext(new AffineTransform(),
+ false, false);
+ LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0,
+ m.trimmedText.length(), frc);
+ m.lineHeight = (int) lmet.getStrikethroughOffset();
+
+ // Fallback in case that LineMetrics is not available/working.
+ if (m.lineHeight == 0)
+ m.lineHeight = (int) (0.3333 * (double) m.textAscent);
+ m.textWidth = fmet.stringWidth(m.trimmedText) + 3;
+ }
+ else
+ {
+ m.textAscent = 0;
+ m.textDescent = 0;
+ }
- m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING);
- m.borderSpacing = new Insets(0, 0, 0, 0);
+ m.innerSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING,
+ EDGE_SPACING);
+ m.outerSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING,
+ EDGE_SPACING);
switch (titlePosition)
{
case ABOVE_TOP:
- m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING;
+ m.outerSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING;
break;
+ case TOP:
+ m.outerSpacing.top += m.textDescent + m.lineHeight;
+ m.innerSpacing.top += m.textAscent - m.lineHeight;
+ break;
+
case BELOW_TOP:
- m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING;
+ m.innerSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING;
break;
case ABOVE_BOTTOM:
- m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING;
+ m.innerSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING;
break;
case BOTTOM:
- m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0);
- m.borderSpacing.bottom += m.textDescent;
+ m.innerSpacing.bottom += Math.max(m.textAscent - m.lineHeight, 0);
+ m.outerSpacing.bottom += m.textDescent + m.lineHeight;
break;
case BELOW_BOTTOM:
- m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING;
+ m.outerSpacing.bottom += m.textAscent + m.textDescent;
break;
default:
- m.borderSpacing.top += m.textAscent;
+ m.outerSpacing.top += m.textAscent;
}
return m;
@@ -1067,7 +1080,7 @@ public class TitledBorder
* which means that the font is to be retrieved from the current
* LookAndFeel. In this case, this <code>font</code> field will
* contain the result of the retrieval. Therefore, it is safe
- * to assume that his <code>font</code> field will never have
+ * to assume that this <code>font</code> field will never have
* a <code>null</code> value.
*/
Font font;
@@ -1107,7 +1120,7 @@ public class TitledBorder
/**
- * The border that constitues the interior border
+ * The border that constitutes the interior border
* underneath the title text.
*/
Border border;
@@ -1116,8 +1129,7 @@ public class TitledBorder
/**
* The distance between the TitledBorder and the interior border.
*/
- Insets borderSpacing;
-
+ Insets outerSpacing;
/**
* The width of the interior border, as returned by
@@ -1130,7 +1142,7 @@ public class TitledBorder
* The distance between the interior border and the nested
* Component for which this TitledBorder is a border.
*/
- Insets edgeSpacing;
+ Insets innerSpacing;
/**
@@ -1149,10 +1161,10 @@ public class TitledBorder
{
if (i == null)
i = new Insets(0, 0, 0, 0);
- i.left = borderSpacing.left + borderInsets.left + edgeSpacing.left;
- i.right = borderSpacing.right + borderInsets.right + edgeSpacing.right;
- i.top = borderSpacing.top + borderInsets.top + edgeSpacing.top;
- i.bottom = borderSpacing.bottom + borderInsets.bottom + edgeSpacing.bottom;
+ i.left = outerSpacing.left + borderInsets.left + innerSpacing.left;
+ i.right = outerSpacing.right + borderInsets.right + innerSpacing.right;
+ i.top = outerSpacing.top + borderInsets.top + innerSpacing.top;
+ i.bottom = outerSpacing.bottom + borderInsets.bottom + innerSpacing.bottom;
return i;
}
@@ -1167,7 +1179,8 @@ public class TitledBorder
Insets insets;
insets = getContentInsets(null);
- width = Math.max(insets.left + insets.right, textWidth + 2 * TEXT_INSET_H);
+ width = Math.max(insets.left + insets.right, textWidth + 2
+ * TEXT_INSET_H);
return new Dimension(width, insets.top + insets.bottom);
}
}
diff --git a/javax/swing/colorchooser/AbstractColorChooserPanel.java b/javax/swing/colorchooser/AbstractColorChooserPanel.java
index d55346aaf..efb527725 100644
--- a/javax/swing/colorchooser/AbstractColorChooserPanel.java
+++ b/javax/swing/colorchooser/AbstractColorChooserPanel.java
@@ -1,5 +1,5 @@
/* AbstractColorChooserPanel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -64,7 +64,8 @@ public abstract class AbstractColorChooserPanel extends JPanel
*/
public AbstractColorChooserPanel()
{
- } // AbstractColorChooserPanel()
+ // Nothing to do here.
+ }
/**
* This method returns the name displayed in the tab for this chooser panel.
@@ -74,6 +75,36 @@ public abstract class AbstractColorChooserPanel extends JPanel
public abstract String getDisplayName();
/**
+ * Returns the key code for the mnemonic for this panel. This method returns
+ * zero to indicate no mnemonic, subclasses can override this.
+ *
+ * @return <code>0</code>, to indicate no mnemonic key code.
+ *
+ * @see #getDisplayedMnemonicIndex()
+ * @since 1.4
+ */
+ public int getMnemonic()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the index of the character in the display name that is the
+ * mnemonic. This method returns <code>-1</code> to indicate no mnemonic,
+ * subclasses can override.
+ *
+ * @return <code>-1</code>, to indicate no mnemonic.
+ *
+ * @see #getDisplayName()
+ * @see #getMnemonic()
+ * @since 1.4
+ */
+ public int getDisplayedMnemonicIndex()
+ {
+ return -1;
+ }
+
+ /**
* This method updates the chooser panel when the JColorChooser's color has
* changed.
*/
diff --git a/javax/swing/colorchooser/ColorChooserComponentFactory.java b/javax/swing/colorchooser/ColorChooserComponentFactory.java
index 77e319c70..923ea531f 100644
--- a/javax/swing/colorchooser/ColorChooserComponentFactory.java
+++ b/javax/swing/colorchooser/ColorChooserComponentFactory.java
@@ -53,7 +53,8 @@ public class ColorChooserComponentFactory
*/
private ColorChooserComponentFactory()
{
- } // ColorChooserComponentFactory()
+ // Nothing to do here.
+ }
/**
* This method returns the three default chooser panels to be used in
diff --git a/javax/swing/colorchooser/DefaultSwatchChooserPanel.java b/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
index f28af4cac..ff3436808 100644
--- a/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
+++ b/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
@@ -587,6 +587,7 @@ class DefaultSwatchChooserPanel extends AbstractColorChooserPanel
*/
public void addLayoutComponent(String name, Component comp)
{
+ // Nothing to do here.
}
/**
@@ -634,6 +635,7 @@ class DefaultSwatchChooserPanel extends AbstractColorChooserPanel
*/
public void removeLayoutComponent(Component comp)
{
+ // Nothing to do here.
}
/**
@@ -786,6 +788,7 @@ class DefaultSwatchChooserPanel extends AbstractColorChooserPanel
*/
public void updateChooser()
{
+ // Nothing to do here yet.
}
/**
diff --git a/javax/swing/event/EventListenerList.java b/javax/swing/event/EventListenerList.java
index 7ed8582bd..fca248dfc 100644
--- a/javax/swing/event/EventListenerList.java
+++ b/javax/swing/event/EventListenerList.java
@@ -119,6 +119,7 @@ public class EventListenerList
*/
public EventListenerList()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/event/InternalFrameAdapter.java b/javax/swing/event/InternalFrameAdapter.java
index a2878e76e..dfa88c3d4 100644
--- a/javax/swing/event/InternalFrameAdapter.java
+++ b/javax/swing/event/InternalFrameAdapter.java
@@ -39,75 +39,88 @@ exception statement from your version. */
package javax.swing.event;
/**
- * InternalFrameAdapter
+ * InternalFrameAdapter.
+ *
* @author Andrew Selkirk
*/
public abstract class InternalFrameAdapter implements InternalFrameListener
{
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * InternalFrameAdapter constructor
- */
- public InternalFrameAdapter() {
- } // InternalFrameAdapter()
-
-
- //-------------------------------------------------------------
- // Interface: InternalFrameListener ---------------------------
- //-------------------------------------------------------------
+ /**
+ * InternalFrameAdapter constructor.
+ */
+ public InternalFrameAdapter()
+ {
+ // Nothing to do here.
+ }
- /**
- * Internal frame activated
- * @param event Internal frame event
- */
- public void internalFrameActivated(InternalFrameEvent event) {
- } // internalFrameActivated()
-
- /**
- * Internal frame closed
- * @param event Internal frame event
- */
- public void internalFrameClosed(InternalFrameEvent event) {
- } // internalFrameClosed()
-
- /**
- * Internal frame closing
- * @param event Internal frame event
- */
- public void internalFrameClosing(InternalFrameEvent event) {
- } // internalFrameClosing()
-
- /**
- * Internal frame deactivated
- * @param event Internal frame event
- */
- public void internalFrameDeactivated(InternalFrameEvent event) {
- } // internalFrameDeactivated()
-
- /**
- * Internal frame deiconified
- * @param event Internal frame event
- */
- public void internalFrameDeiconified(InternalFrameEvent event) {
- } // internalFrameDeiconified()
-
- /**
- * Internal frame iconified
- * @param event Internal frame event
- */
- public void internalFrameIconified(InternalFrameEvent event) {
- } // internalFrameIconified()
-
- /**
- * Internal frame opened
- * @param event Internal frame event
- */
- public void internalFrameOpened(InternalFrameEvent event) {
- } // internalFrameOpened()
-
-
-} // InternalFrameAdapter
+ /**
+ * Internal frame activated.
+ *
+ * @param event internal frame event
+ */
+ public void internalFrameActivated(InternalFrameEvent event)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Internal frame closed.
+ *
+ * @param event internal frame event
+ */
+ public void internalFrameClosed(InternalFrameEvent event)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Internal frame closing.
+ *
+ * @param event internal frame event
+ */
+ public void internalFrameClosing(InternalFrameEvent event)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Internal frame deactivated.
+ *
+ * @param event internal frame event
+ */
+ public void internalFrameDeactivated(InternalFrameEvent event)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Internal frame deiconified.
+ *
+ * @param event internal frame event
+ */
+ public void internalFrameDeiconified(InternalFrameEvent event)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Internal frame iconified.
+ *
+ * @param event internal frame event
+ */
+ public void internalFrameIconified(InternalFrameEvent event)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Internal frame opened.
+ *
+ * @param event internal frame event
+ */
+ public void internalFrameOpened(InternalFrameEvent event)
+ {
+ // Nothing to do here.
+ }
+
+}
diff --git a/javax/swing/event/ListDataListener.java b/javax/swing/event/ListDataListener.java
index 7ce17d86f..f42777d09 100644
--- a/javax/swing/event/ListDataListener.java
+++ b/javax/swing/event/ListDataListener.java
@@ -1,5 +1,5 @@
/* ListDataListener.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,33 +37,46 @@ exception statement from your version. */
package javax.swing.event;
-// Imports
import java.util.EventListener;
+import javax.swing.ListModel;
+
/**
- * ListDataListener public interface
+ * A <code>ListDataListener</code> can register with a {@link ListModel} and
+ * receive notification of updates to the model.
+ *
* @author Andrew Selkirk
* @author Ronald Veldema
*/
-public interface ListDataListener extends EventListener {
-
- /**
- * Contents Changed
- * @param event ListDataEvent Event
- */
- void contentsChanged(ListDataEvent event);
+public interface ListDataListener extends EventListener
+{
- /**
- * Interval Added
- * @param event ListDataEvent Event
- */
- void intervalAdded(ListDataEvent event);
+ /**
+ * Notifies the listener that the contents of the list have changed
+ * in some way. This method will be called if the change cannot be
+ * notified via the {@link #intervalAdded(ListDataEvent)} or the
+ * {@link #intervalRemoved(ListDataEvent)} methods.
+ *
+ * @param event the event.
+ */
+ void contentsChanged(ListDataEvent event);
- /**
- * Interval Removed
- * @param event ListDataEvent Event
- */
- void intervalRemoved(ListDataEvent event);
+ /**
+ * Notifies the listener that one or more items have been added to the
+ * list. The <code>event</code> argument can supply the indices for the
+ * range of items added.
+ *
+ * @param event the event.
+ */
+ void intervalAdded(ListDataEvent event);
+ /**
+ * Notifies the listener that one or more items have been removed from
+ * the list. The <code>event</code> argument can supply the indices for
+ * the range of items removed.
+ *
+ * @param event the event.
+ */
+ void intervalRemoved(ListDataEvent event);
-} // ListDataListener
+}
diff --git a/javax/swing/event/MouseInputListener.java b/javax/swing/event/MouseInputListener.java
index 3c3ca2347..3d879b9e7 100644
--- a/javax/swing/event/MouseInputListener.java
+++ b/javax/swing/event/MouseInputListener.java
@@ -37,16 +37,17 @@ exception statement from your version. */
package javax.swing.event;
-// Imports
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
/**
- * MouseInputListener public interface
+ * MouseInputListener public interface.
+ *
* @author Andrew Selkirk
*/
public interface MouseInputListener extends MouseListener,
- MouseMotionListener {
-
-} // MouseInputListener
-
+ MouseMotionListener
+{
+ // This interface only pulls together MouseListener and MouseMotionListener
+ // without adding any methods on its own.
+}
diff --git a/javax/swing/event/SwingPropertyChangeSupport.java b/javax/swing/event/SwingPropertyChangeSupport.java
index 408ca957e..7e8ff0dc2 100644
--- a/javax/swing/event/SwingPropertyChangeSupport.java
+++ b/javax/swing/event/SwingPropertyChangeSupport.java
@@ -289,10 +289,9 @@ public final class SwingPropertyChangeSupport
int index;
PropertyChangeListener listener;
- // Check Values if they are equal
- if (event.getOldValue() == null && event.getNewValue() == null ||
- (event.getOldValue() != null && event.getNewValue() != null &&
- event.getOldValue().equals(event.getNewValue())))
+ // if the old and new values are non-null and equal, don't notify listeners
+ if (event.getOldValue() != null && event.getNewValue() != null &&
+ event.getOldValue().equals(event.getNewValue()))
return;
// Process Main Listener List
diff --git a/javax/swing/filechooser/FileFilter.java b/javax/swing/filechooser/FileFilter.java
index 42770d981..ecfa54b58 100644
--- a/javax/swing/filechooser/FileFilter.java
+++ b/javax/swing/filechooser/FileFilter.java
@@ -1,5 +1,5 @@
/* FileFilter.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,41 +40,46 @@ package javax.swing.filechooser;
import java.io.File;
+import javax.swing.JFileChooser;
+
/**
- * FileFilter
+ * The base class for filters that control the visibility of files in the
+ * {@link JFileChooser} component.
+ *
+ * @see JFileChooser#addChoosableFileFilter(FileFilter)
+ *
* @author Andrew Selkirk
- * @version 1.0
*/
-public abstract class FileFilter {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor FileFilter
- */
- public FileFilter() {
- // TODO
- } // FileFilter()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * accept
- * @param file TODO
- * @returns boolean
- */
- public abstract boolean accept(File file);
-
- /**
- * getDescription
- * @returns String
- */
- public abstract String getDescription();
-
-
-} // FileFilter
+public abstract class FileFilter
+{
+
+ /**
+ * Default constructor.
+ */
+ public FileFilter()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns <code>true</code> if the specified file matches the filter, and
+ * <code>false</code> otherwise.
+ *
+ * @param file the file.
+ *
+ * @returns A boolean.
+ */
+ public abstract boolean accept(File file);
+
+ /**
+ * Returns a description of the files that will be selected by the filter
+ * (for example, "Java source files"). This description will usually be
+ * displayed on the {@link JFileChooser} component, often in a combo box that
+ * is used to select the appropriate filter (in cases where more than one
+ * filter is available).
+ *
+ * @returns A description of the filter.
+ */
+ public abstract String getDescription();
+
+}
diff --git a/javax/swing/filechooser/FileSystemView.java b/javax/swing/filechooser/FileSystemView.java
index 0c3dfbf6e..5867cdbe3 100644
--- a/javax/swing/filechooser/FileSystemView.java
+++ b/javax/swing/filechooser/FileSystemView.java
@@ -48,6 +48,9 @@ import javax.swing.Icon;
*/
public abstract class FileSystemView
{
+ /** The instance returned by {@link #getFileSystemView()}. */
+ private static FileSystemView defaultFileSystemView;
+
/**
* DOCUMENT ME!
*
@@ -148,20 +151,22 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns a default {@link FileSystemView} appropriate for the platform.
*
- * @return DOCUMENT ME!
+ * @return A default {@link FileSystemView} appropriate for the platform.
*/
public static FileSystemView getFileSystemView()
{
- if (File.separator.equals("/"))
- return new UnixFileSystemView();
-
- // else if (File.Separator.equals("\"))
- // return new Win32FileSystemView();
- // else
- // return new GenericFileSystemView();
- return null;
+ if (defaultFileSystemView == null)
+ {
+ if (File.separator.equals("/"))
+ defaultFileSystemView = new UnixFileSystemView();
+ // else if (File.Separator.equals("\"))
+ // return new Win32FileSystemView();
+ // else
+ // return new GenericFileSystemView();
+ }
+ return defaultFileSystemView;
}
/**
diff --git a/javax/swing/filechooser/FileView.java b/javax/swing/filechooser/FileView.java
index f07114342..ea1989f93 100644
--- a/javax/swing/filechooser/FileView.java
+++ b/javax/swing/filechooser/FileView.java
@@ -56,6 +56,7 @@ public abstract class FileView
*/
public FileView()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/plaf/ActionMapUIResource.java b/javax/swing/plaf/ActionMapUIResource.java
index f6af0880d..07292fe24 100644
--- a/javax/swing/plaf/ActionMapUIResource.java
+++ b/javax/swing/plaf/ActionMapUIResource.java
@@ -50,9 +50,7 @@ import javax.swing.ActionMap;
* @author Andrew Selkirk
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class ActionMapUIResource
- extends ActionMap
- implements UIResource
+public class ActionMapUIResource extends ActionMap implements UIResource
{
/**
* Constructs a new ActionMapUIResource.
diff --git a/javax/swing/plaf/BorderUIResource.java b/javax/swing/plaf/BorderUIResource.java
index 4402bbb48..317cb09ac 100644
--- a/javax/swing/plaf/BorderUIResource.java
+++ b/javax/swing/plaf/BorderUIResource.java
@@ -71,9 +71,7 @@ import javax.swing.border.TitledBorder;
* @author Brian Jones (cbj@gnu.org)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class BorderUIResource
- extends Object
- implements Border, UIResource, Serializable
+public class BorderUIResource implements Border, UIResource, Serializable
{
/**
* Verified using the <code>serialver</code> tool
diff --git a/javax/swing/plaf/ButtonUI.java b/javax/swing/plaf/ButtonUI.java
index 197299e0c..6910e4298 100644
--- a/javax/swing/plaf/ButtonUI.java
+++ b/javax/swing/plaf/ButtonUI.java
@@ -46,7 +46,7 @@ package javax.swing.plaf;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ButtonUI
- extends ComponentUI
+public abstract class ButtonUI extends ComponentUI
{
+ // This abstract class does not define any methods of its own.
}
diff --git a/javax/swing/plaf/ColorChooserUI.java b/javax/swing/plaf/ColorChooserUI.java
index 68ffd916d..16091416a 100644
--- a/javax/swing/plaf/ColorChooserUI.java
+++ b/javax/swing/plaf/ColorChooserUI.java
@@ -46,8 +46,7 @@ package javax.swing.plaf;
* @author Andrew Selkirk
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ColorChooserUI
- extends ComponentUI
+public abstract class ColorChooserUI extends ComponentUI
{
/**
* Constructs a ColorChooserUI.
diff --git a/javax/swing/plaf/ColorUIResource.java b/javax/swing/plaf/ColorUIResource.java
index 33b1676e0..36e10f2d1 100644
--- a/javax/swing/plaf/ColorUIResource.java
+++ b/javax/swing/plaf/ColorUIResource.java
@@ -50,9 +50,7 @@ import java.awt.Color;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class ColorUIResource
- extends Color
- implements UIResource
+public class ColorUIResource extends Color implements UIResource
{
/**
* Constructs a <code>ColorUIResource</code> using the specified
diff --git a/javax/swing/plaf/ComboBoxUI.java b/javax/swing/plaf/ComboBoxUI.java
index 9498a4815..3e81ed75a 100644
--- a/javax/swing/plaf/ComboBoxUI.java
+++ b/javax/swing/plaf/ComboBoxUI.java
@@ -48,14 +48,14 @@ import javax.swing.JComboBox;
* @author Andrew Selkirk
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ComboBoxUI
- extends ComponentUI
+public abstract class ComboBoxUI extends ComponentUI
{
/**
* Constructs a new <code>ComboBoxUI</code>.
*/
public ComboBoxUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/ComponentInputMapUIResource.java b/javax/swing/plaf/ComponentInputMapUIResource.java
index e1418710f..cfc43e4fc 100644
--- a/javax/swing/plaf/ComponentInputMapUIResource.java
+++ b/javax/swing/plaf/ComponentInputMapUIResource.java
@@ -52,8 +52,7 @@ import javax.swing.JComponent;
* @author Andrew Selkirk
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class ComponentInputMapUIResource
- extends ComponentInputMap
+public class ComponentInputMapUIResource extends ComponentInputMap
implements UIResource
{
/**
diff --git a/javax/swing/plaf/ComponentUI.java b/javax/swing/plaf/ComponentUI.java
index 0e7680542..ced3904c7 100644
--- a/javax/swing/plaf/ComponentUI.java
+++ b/javax/swing/plaf/ComponentUI.java
@@ -40,6 +40,7 @@ package javax.swing.plaf;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.Rectangle;
import javax.accessibility.Accessible;
import javax.swing.JComponent;
@@ -86,6 +87,7 @@ public abstract class ComponentUI
*/
public ComponentUI()
{
+ // Nothing to do here.
}
@@ -157,6 +159,8 @@ public abstract class ComponentUI
*/
public void paint(Graphics g, JComponent c)
{
+ // Nothing is done here. This method is meant to be overridden by
+ // subclasses.
}
@@ -182,12 +186,12 @@ public abstract class ComponentUI
if (c.isOpaque())
{
g.setColor(c.getBackground());
+ Rectangle clip = g.getClipBounds();
g.fillRect(0, 0, c.getWidth(), c.getHeight());
}
paint(g, c);
}
-
-
+
/**
* Determines the preferred size of a component. The default
* implementation returns <code>null</code>, which means that
diff --git a/javax/swing/plaf/DesktopIconUI.java b/javax/swing/plaf/DesktopIconUI.java
index 2e44088ca..676233ec2 100644
--- a/javax/swing/plaf/DesktopIconUI.java
+++ b/javax/swing/plaf/DesktopIconUI.java
@@ -44,13 +44,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class DesktopIconUI
- extends ComponentUI
+public abstract class DesktopIconUI extends ComponentUI
{
/**
* Constructs a new <code>DesktopIconUI</code>.
*/
public DesktopIconUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/DesktopPaneUI.java b/javax/swing/plaf/DesktopPaneUI.java
index de553eaf4..3d4cfc830 100644
--- a/javax/swing/plaf/DesktopPaneUI.java
+++ b/javax/swing/plaf/DesktopPaneUI.java
@@ -46,14 +46,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class DesktopPaneUI
- extends ComponentUI
+public abstract class DesktopPaneUI extends ComponentUI
{
/**
* Constructs a new <code>DesktopPaneUI</code>.
*/
public DesktopPaneUI()
{
+ // Nothing to do here.
}
}
-
diff --git a/javax/swing/plaf/DimensionUIResource.java b/javax/swing/plaf/DimensionUIResource.java
index 63c6838c4..618c22036 100644
--- a/javax/swing/plaf/DimensionUIResource.java
+++ b/javax/swing/plaf/DimensionUIResource.java
@@ -51,9 +51,7 @@ import java.awt.Dimension;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class DimensionUIResource
- extends Dimension
- implements UIResource
+public class DimensionUIResource extends Dimension implements UIResource
{
/**
* Constructs a new DimensionUIResource, given its width and height.
diff --git a/javax/swing/plaf/FileChooserUI.java b/javax/swing/plaf/FileChooserUI.java
index 8b661e399..e9be8f2ba 100644
--- a/javax/swing/plaf/FileChooserUI.java
+++ b/javax/swing/plaf/FileChooserUI.java
@@ -53,14 +53,14 @@ import javax.swing.filechooser.FileView;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class FileChooserUI
- extends ComponentUI
+public abstract class FileChooserUI extends ComponentUI
{
/**
* Constructs a new <code>FileChooserUI</code>.
*/
public FileChooserUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/FontUIResource.java b/javax/swing/plaf/FontUIResource.java
index 1c1731048..c54f987fd 100644
--- a/javax/swing/plaf/FontUIResource.java
+++ b/javax/swing/plaf/FontUIResource.java
@@ -50,9 +50,7 @@ import java.awt.Font;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class FontUIResource
- extends Font
- implements UIResource
+public class FontUIResource extends Font implements UIResource
{
/**
* Constructs a new <code>FontUIResource</code> given
diff --git a/javax/swing/plaf/IconUIResource.java b/javax/swing/plaf/IconUIResource.java
index 1b09ed31f..659c8e7ba 100644
--- a/javax/swing/plaf/IconUIResource.java
+++ b/javax/swing/plaf/IconUIResource.java
@@ -53,8 +53,7 @@ import javax.swing.Icon;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class IconUIResource
- implements Icon, UIResource, Serializable
+public class IconUIResource implements Icon, UIResource, Serializable
{
/**
* Verified using the <code>serialver</code> tool of Sun JDK 1.4.1_01
diff --git a/javax/swing/plaf/InputMapUIResource.java b/javax/swing/plaf/InputMapUIResource.java
index ae032e51f..0c5f6f9e9 100644
--- a/javax/swing/plaf/InputMapUIResource.java
+++ b/javax/swing/plaf/InputMapUIResource.java
@@ -49,15 +49,13 @@ import javax.swing.InputMap;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class InputMapUIResource
- extends InputMap
- implements UIResource
+public class InputMapUIResource extends InputMap implements UIResource
{
/**
* Constructs a new <code>InputMapUIResource</code>.
*/
public InputMapUIResource()
{
+ // Nothing to do here.
}
}
-
diff --git a/javax/swing/plaf/InsetsUIResource.java b/javax/swing/plaf/InsetsUIResource.java
index 755d8add1..d64feb44c 100644
--- a/javax/swing/plaf/InsetsUIResource.java
+++ b/javax/swing/plaf/InsetsUIResource.java
@@ -50,8 +50,7 @@ import java.io.Serializable;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class InsetsUIResource
- extends Insets
+public class InsetsUIResource extends Insets
implements Cloneable, UIResource, Serializable
{
/**
diff --git a/javax/swing/plaf/InternalFrameUI.java b/javax/swing/plaf/InternalFrameUI.java
index fd1e3374c..0b2f77caa 100644
--- a/javax/swing/plaf/InternalFrameUI.java
+++ b/javax/swing/plaf/InternalFrameUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class InternalFrameUI
- extends ComponentUI
+public abstract class InternalFrameUI extends ComponentUI
{
/**
* Constructs a new <code>InternalFrameUI</code>.
*/
public InternalFrameUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/LabelUI.java b/javax/swing/plaf/LabelUI.java
index 8fc1d711b..f4b74d59e 100644
--- a/javax/swing/plaf/LabelUI.java
+++ b/javax/swing/plaf/LabelUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class LabelUI
- extends ComponentUI
+public abstract class LabelUI extends ComponentUI
{
/**
* Constructs a new <code>LabelUI</code>.
*/
public LabelUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/ListUI.java b/javax/swing/plaf/ListUI.java
index 66d5cf588..bdfe4b307 100644
--- a/javax/swing/plaf/ListUI.java
+++ b/javax/swing/plaf/ListUI.java
@@ -49,14 +49,14 @@ import javax.swing.JList;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ListUI
- extends ComponentUI
+public abstract class ListUI extends ComponentUI
{
/**
* Constructs a new <code>ListUI</code>.
*/
public ListUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/MenuBarUI.java b/javax/swing/plaf/MenuBarUI.java
index 8835571ac..2c82adfa0 100644
--- a/javax/swing/plaf/MenuBarUI.java
+++ b/javax/swing/plaf/MenuBarUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class MenuBarUI
- extends ComponentUI
+public abstract class MenuBarUI extends ComponentUI
{
/**
* Constructs a new <code>MenuBarUI</code>.
*/
public MenuBarUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/MenuItemUI.java b/javax/swing/plaf/MenuItemUI.java
index 31d73194a..83ad52fb1 100644
--- a/javax/swing/plaf/MenuItemUI.java
+++ b/javax/swing/plaf/MenuItemUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class MenuItemUI
- extends ButtonUI
+public abstract class MenuItemUI extends ButtonUI
{
/**
* Constructs a new <code>MenuItemUI</code>.
*/
public MenuItemUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/PanelUI.java b/javax/swing/plaf/PanelUI.java
index b1171b80d..12a6f52cf 100644
--- a/javax/swing/plaf/PanelUI.java
+++ b/javax/swing/plaf/PanelUI.java
@@ -46,13 +46,13 @@ package javax.swing.plaf;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class PanelUI
- extends ComponentUI
+public abstract class PanelUI extends ComponentUI
{
/**
* Constructs a new <code>PanelUI</code>.
*/
public PanelUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/PopupMenuUI.java b/javax/swing/plaf/PopupMenuUI.java
index c70ad2a4e..de351f2ef 100644
--- a/javax/swing/plaf/PopupMenuUI.java
+++ b/javax/swing/plaf/PopupMenuUI.java
@@ -53,14 +53,14 @@ import javax.swing.PopupFactory;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class PopupMenuUI
- extends ComponentUI
+public abstract class PopupMenuUI extends ComponentUI
{
/**
* Constructs a new <code>PopupMenuUI</code>.
*/
public PopupMenuUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/ProgressBarUI.java b/javax/swing/plaf/ProgressBarUI.java
index 79c1b95a3..013b8c5c2 100644
--- a/javax/swing/plaf/ProgressBarUI.java
+++ b/javax/swing/plaf/ProgressBarUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ProgressBarUI
- extends ComponentUI
+public abstract class ProgressBarUI extends ComponentUI
{
/**
* Constructs a new <code>ProgressBarUI</code>.
*/
public ProgressBarUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/RootPaneUI.java b/javax/swing/plaf/RootPaneUI.java
index ff7d0a6e7..9637c9cf2 100644
--- a/javax/swing/plaf/RootPaneUI.java
+++ b/javax/swing/plaf/RootPaneUI.java
@@ -46,13 +46,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class RootPaneUI
- extends ComponentUI
+public abstract class RootPaneUI extends ComponentUI
{
/**
* Constructs a new <code>RootPaneUI</code>.
*/
public RootPaneUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/ScrollBarUI.java b/javax/swing/plaf/ScrollBarUI.java
index 3cad39327..51b4bf2d8 100644
--- a/javax/swing/plaf/ScrollBarUI.java
+++ b/javax/swing/plaf/ScrollBarUI.java
@@ -46,13 +46,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ScrollBarUI
- extends ComponentUI
+public abstract class ScrollBarUI extends ComponentUI
{
/**
* Constructs a new <code>ScrollBarUI</code>.
*/
public ScrollBarUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/ScrollPaneUI.java b/javax/swing/plaf/ScrollPaneUI.java
index 14d2ac61e..8b37fed22 100644
--- a/javax/swing/plaf/ScrollPaneUI.java
+++ b/javax/swing/plaf/ScrollPaneUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ScrollPaneUI
- extends ComponentUI
+public abstract class ScrollPaneUI extends ComponentUI
{
/**
* Constructs a new <code>ScrollPaneUI</code>.
*/
public ScrollPaneUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/SeparatorUI.java b/javax/swing/plaf/SeparatorUI.java
index 6855bd035..8a9f8cf4d 100644
--- a/javax/swing/plaf/SeparatorUI.java
+++ b/javax/swing/plaf/SeparatorUI.java
@@ -54,5 +54,6 @@ public abstract class SeparatorUI
*/
public SeparatorUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/SliderUI.java b/javax/swing/plaf/SliderUI.java
index 775f19620..570e962aa 100644
--- a/javax/swing/plaf/SliderUI.java
+++ b/javax/swing/plaf/SliderUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class SliderUI
- extends ComponentUI
+public abstract class SliderUI extends ComponentUI
{
/**
* Constructs a new <code>SliderUI</code>.
*/
public SliderUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/SpinnerUI.java b/javax/swing/plaf/SpinnerUI.java
index fb4a3b13a..ca29ddb8e 100644
--- a/javax/swing/plaf/SpinnerUI.java
+++ b/javax/swing/plaf/SpinnerUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class SpinnerUI
- extends ComponentUI
+public abstract class SpinnerUI extends ComponentUI
{
/**
* Constructs a new <code>SpinnerUI</code>.
*/
public SpinnerUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/SplitPaneUI.java b/javax/swing/plaf/SplitPaneUI.java
index ea9af2b17..59ededf58 100644
--- a/javax/swing/plaf/SplitPaneUI.java
+++ b/javax/swing/plaf/SplitPaneUI.java
@@ -51,14 +51,14 @@ import javax.swing.JSplitPane;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class SplitPaneUI
- extends ComponentUI
+public abstract class SplitPaneUI extends ComponentUI
{
/**
* Constructs a new <code>SplitPaneUI</code>.
*/
public SplitPaneUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/TabbedPaneUI.java b/javax/swing/plaf/TabbedPaneUI.java
index 6ab823b50..01a772014 100644
--- a/javax/swing/plaf/TabbedPaneUI.java
+++ b/javax/swing/plaf/TabbedPaneUI.java
@@ -51,14 +51,14 @@ import javax.swing.JTabbedPane;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class TabbedPaneUI
- extends ComponentUI
+public abstract class TabbedPaneUI extends ComponentUI
{
/**
* Constructs a new <code>TabbedPaneUI</code>.
*/
public TabbedPaneUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/TableHeaderUI.java b/javax/swing/plaf/TableHeaderUI.java
index f23ca74d7..34ac0e0fc 100644
--- a/javax/swing/plaf/TableHeaderUI.java
+++ b/javax/swing/plaf/TableHeaderUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class TableHeaderUI
- extends ComponentUI
+public abstract class TableHeaderUI extends ComponentUI
{
/**
* Constructs a new <code>TableHeaderUI</code>.
*/
public TableHeaderUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/TableUI.java b/javax/swing/plaf/TableUI.java
index e56bcd131..a8c6bf909 100644
--- a/javax/swing/plaf/TableUI.java
+++ b/javax/swing/plaf/TableUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class TableUI
- extends ComponentUI
+public abstract class TableUI extends ComponentUI
{
/**
* Constructs a new <code>TableUI</code>.
*/
public TableUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/TextUI.java b/javax/swing/plaf/TextUI.java
index dcabdfcdb..9f2737cc2 100644
--- a/javax/swing/plaf/TextUI.java
+++ b/javax/swing/plaf/TextUI.java
@@ -57,14 +57,14 @@ import javax.swing.text.View;
* @author Ronald Veldema (rveldema@cs.vu.nl)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class TextUI
- extends ComponentUI
+public abstract class TextUI extends ComponentUI
{
/**
* Constructs a new <code>TextUI</code>.
*/
public TextUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/ToolBarUI.java b/javax/swing/plaf/ToolBarUI.java
index 730cf4887..9a26e7b59 100644
--- a/javax/swing/plaf/ToolBarUI.java
+++ b/javax/swing/plaf/ToolBarUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ToolBarUI
- extends ComponentUI
+public abstract class ToolBarUI extends ComponentUI
{
/**
* Constructs a new <code>ToolBarUI</code>.
*/
public ToolBarUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/ToolTipUI.java b/javax/swing/plaf/ToolTipUI.java
index 4383d0edd..ae2d465e5 100644
--- a/javax/swing/plaf/ToolTipUI.java
+++ b/javax/swing/plaf/ToolTipUI.java
@@ -47,13 +47,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ToolTipUI
- extends ComponentUI
+public abstract class ToolTipUI extends ComponentUI
{
/**
* Constructs a new <code>ToolTipUI</code>.
*/
public ToolTipUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/TreeUI.java b/javax/swing/plaf/TreeUI.java
index e32952de7..308ec63e2 100644
--- a/javax/swing/plaf/TreeUI.java
+++ b/javax/swing/plaf/TreeUI.java
@@ -51,14 +51,14 @@ import javax.swing.tree.TreePath;
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class TreeUI
- extends ComponentUI
+public abstract class TreeUI extends ComponentUI
{
/**
* Constructs a new <code>TreeUI</code>.
*/
public TreeUI()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/UIResource.java b/javax/swing/plaf/UIResource.java
index 59edf5666..fe398fe54 100644
--- a/javax/swing/plaf/UIResource.java
+++ b/javax/swing/plaf/UIResource.java
@@ -50,6 +50,10 @@ package javax.swing.plaf;
* they are initialized or set to <code>null</code>.
*
* @author Brian Jones
+ *
* @see ComponentUI
*/
-public interface UIResource { }
+public interface UIResource
+{
+ // This is a marker interface and declares no methods.
+}
diff --git a/javax/swing/plaf/ViewportUI.java b/javax/swing/plaf/ViewportUI.java
index 087938f1e..db514de1a 100644
--- a/javax/swing/plaf/ViewportUI.java
+++ b/javax/swing/plaf/ViewportUI.java
@@ -48,13 +48,13 @@ package javax.swing.plaf;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public abstract class ViewportUI
- extends ComponentUI
+public abstract class ViewportUI extends ComponentUI
{
/**
* Constructs a new <code>ViewportUI</code>.
*/
public ViewportUI()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/basic/BasicArrowButton.java b/javax/swing/plaf/basic/BasicArrowButton.java
index e6d7188c4..69d441537 100644
--- a/javax/swing/plaf/basic/BasicArrowButton.java
+++ b/javax/swing/plaf/basic/BasicArrowButton.java
@@ -39,43 +39,30 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.Color;
-import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
-import java.awt.Insets;
import java.awt.Polygon;
import java.awt.Rectangle;
-import javax.swing.AbstractButton;
+import javax.swing.ButtonModel;
import javax.swing.JButton;
import javax.swing.SwingConstants;
-import javax.swing.border.Border;
/**
- * This class draws simple arrow buttons for the Basic Look and Feel.
+ * A button that displays an arrow (triangle) that points {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} or {@link #WEST}. This button is used by
+ * the {@link BasicComboBoxUI} class.
+ *
+ * @see BasicComboBoxUI#createArrowButton
*/
public class BasicArrowButton extends JButton implements SwingConstants
{
- /** The default size of the Arrow buttons. */
- private static int defaultSize = 12;
- /** The Polygon that points up. */
- private static Polygon upIcon = new Polygon(new int[] { 0, 5, 9 },
- new int[] { 7, 2, 7 }, 3);
-
- /** The Polygon that points down. */
- private static Polygon downIcon = new Polygon(new int[] { 1, 5, 9 },
- new int[] { 3, 7, 3 }, 3);
-
- /** The Polygon that points left. */
- private static Polygon leftIcon = new Polygon(new int[] { 7, 3, 7 },
- new int[] { 1, 5, 9 }, 3);
-
- /** The Polygon that points right. */
- private static Polygon rightIcon = new Polygon(new int[] { 3, 7, 3 },
- new int[] { 1, 5, 9 }, 3);
-
- /** The direction to point in. */
+ /**
+ * The direction that the arrow points.
+ *
+ * @see #getDirection()
+ */
protected int direction;
/**
@@ -90,7 +77,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
* edges of the button.
* This is package-private to avoid an accessor method.
*/
- transient Color darkShadow = Color.DARK_GRAY;
+ transient Color darkShadow = new Color(102, 102, 102);
/**
* The top and left edges of the button.
@@ -98,57 +85,15 @@ public class BasicArrowButton extends JButton implements SwingConstants
*/
transient Color highlight = Color.WHITE;
- /** The border around the ArrowButton. */
- private transient Border buttonBorder = new Border()
- {
- public Insets getBorderInsets(Component c)
- {
- return new Insets(2, 2, 2, 2);
- }
-
- public boolean isBorderOpaque()
- {
- return true;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int w,
- int h)
- {
- Color saved = g.getColor();
- AbstractButton b = (AbstractButton) c;
- if (b.getModel().isPressed())
- {
- g.setColor(darkShadow);
- g.drawRect(x, y, x + w - 1, y + h - 1);
- }
- else
- {
- g.setColor(highlight);
- g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
- g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
-
- g.setColor(shadow);
- g.drawLine(x + 1, y + h - 2, x + w - 1, y + h - 2);
- g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
-
- g.setColor(darkShadow);
- g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
- g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
-
- g.setColor(saved);
- }
- }
- };
-
/**
- * Creates a new BasicArrowButton object.
+ * Creates a new <code>BasicArrowButton</code> object.
*
- * @param direction The direction the arrow points in.
+ * @param direction The direction the arrow points in (one of:
+ * {@link #NORTH}, {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
*/
public BasicArrowButton(int direction)
{
super();
- setBorder(buttonBorder);
setDirection(direction);
}
@@ -156,7 +101,8 @@ public class BasicArrowButton extends JButton implements SwingConstants
* Creates a new BasicArrowButton object with the given colors and
* direction.
*
- * @param direction The direction to point in.
+ * @param direction The direction to point in (one of:
+ * {@link #NORTH}, {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
* @param background The background color.
* @param shadow The shadow color.
* @param darkShadow The dark shadow color.
@@ -173,9 +119,10 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * This method returns whether the focus can traverse to this component.
+ * Returns whether the focus can traverse to this component. This method
+ * always returns <code>false</code>.
*
- * @return Whether the focus can traverse to this component.
+ * @return <code>false</code>.
*/
public boolean isFocusTraversable()
{
@@ -183,7 +130,8 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * This method returns the direction of the arrow.
+ * Returns the direction of the arrow (one of: {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
*
* @return The direction of the arrow.
*/
@@ -193,9 +141,10 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * This method changes the direction of the arrow.
+ * Sets the direction of the arrow.
*
- * @param dir The new direction of the arrow.
+ * @param dir The new direction of the arrow (one of: {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
*/
public void setDirection(int dir)
{
@@ -203,7 +152,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * This method paints the arrow button. The painting is delegated to the
+ * Paints the arrow button. The painting is delegated to the
* paintTriangle method.
*
* @param g The Graphics object to paint with.
@@ -211,13 +160,17 @@ public class BasicArrowButton extends JButton implements SwingConstants
public void paint(Graphics g)
{
super.paint(g);
- Insets insets = getInsets();
Rectangle bounds = getBounds();
- int x = insets.left
- + (bounds.width - insets.left - insets.right - defaultSize) / 2;
- int y = insets.top
- + (bounds.height - insets.left - insets.right - defaultSize) / 2;
- paintTriangle(g, x, y, defaultSize, direction, isEnabled());
+ int size = bounds.height / 4;
+ int x = (bounds.width - size) / 2;
+ int y = (bounds.height - size) / 2;
+ ButtonModel m = getModel();
+ if (m.isArmed())
+ {
+ x++;
+ y++;
+ }
+ paintTriangle(g, x, y, size, direction, isEnabled());
}
/** The preferred size for the button. */
@@ -231,9 +184,9 @@ public class BasicArrowButton extends JButton implements SwingConstants
= new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
/**
- * This method returns the preferred size of the arrow button.
+ * Returns the preferred size of the arrow button.
*
- * @return The preferred size.
+ * @return The preferred size (always 16 x 16).
*/
public Dimension getPreferredSize()
{
@@ -241,9 +194,9 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * This method returns the minimum size of the arrow button.
+ * Returns the minimum size of the arrow button.
*
- * @return The minimum size.
+ * @return The minimum size (always 5 x 5).
*/
public Dimension getMinimumSize()
{
@@ -251,7 +204,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * This method returns the maximum size of the arrow button.
+ * Returns the maximum size of the arrow button.
*
* @return The maximum size.
*/
@@ -261,103 +214,203 @@ public class BasicArrowButton extends JButton implements SwingConstants
}
/**
- * The method paints a triangle with the given size and direction at the
- * given x and y coordinates.
+ * Paints a triangle with the given size, location and direction. It is
+ * difficult to explain the rationale behind the positioning of the triangle
+ * relative to the given (x, y) position - by trial and error we seem to
+ * match the behaviour of the reference implementation (which is missing a
+ * specification for this method).
*
- * @param g The Graphics object to paint with.
- * @param x The x coordinate to paint at.
- * @param y The y coordinate to paint at.
- * @param size The size of the icon.
- * @param direction The direction of the icon.
- * @param isEnabled Whether it is enabled.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the triangle's location.
+ * @param y the y-coordinate for the triangle's location.
+ * @param size the arrow size (depth).
+ * @param direction the direction of the arrow (one of: {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
*/
public void paintTriangle(Graphics g, int x, int y, int size, int direction,
boolean isEnabled)
{
- Polygon arrow = null;
- switch (direction)
- {
- case NORTH:
- arrow = upIcon;
- break;
- case SOUTH:
- arrow = downIcon;
- break;
- case EAST:
- case RIGHT:
- arrow = rightIcon;
- break;
- case WEST:
- case LEFT:
- arrow = leftIcon;
- break;
- }
-
- int[] xPoints = arrow.xpoints;
- int[] yPoints = arrow.ypoints;
- int x1;
- int y1;
- int x2;
- int y2;
- x1 = y1 = x2 = y2 = 0;
-
- if (size != defaultSize)
- {
- float scale = size * 1f / defaultSize;
- for (int i = 0; i < 3; i++)
- {
- xPoints[i] *= scale;
- yPoints[i] *= scale;
- }
- }
- g.translate(x, y);
-
+ Color savedColor = g.getColor();
switch (direction)
{
case NORTH:
- x1 = xPoints[0] + 2;
- y1 = yPoints[0];
- y2 = y1;
- x2 = xPoints[2] - 1;
- break;
+ paintTriangleNorth(g, x, y, size, isEnabled);
+ break;
case SOUTH:
- x1 = xPoints[1];
- y1 = yPoints[1];
- x2 = xPoints[2];
- y2 = yPoints[2];
- break;
+ paintTriangleSouth(g, x, y, size, isEnabled);
+ break;
case LEFT:
case WEST:
- x1 = xPoints[0] + 1;
- y1 = yPoints[0] + 1;
- x2 = x1;
- y2 = yPoints[2] + 1;
- break;
+ paintTriangleWest(g, x, y, size, isEnabled);
+ break;
case RIGHT:
case EAST:
- x1 = xPoints[2];
- y1 = yPoints[2] + 1;
- x2 = xPoints[1] - 1;
- y2 = yPoints[1] + 1;
- break;
+ paintTriangleEast(g, x, y, size, isEnabled);
+ break;
}
- Color saved = g.getColor();
-
+ g.setColor(savedColor);
+ }
+
+ /**
+ * Paints an upward-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleNorth(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x + (size - 2) / 2;
+ int tipY = y;
+ int baseX1 = tipX - (size - 1);
+ int baseX2 = tipX + (size - 1);
+ int baseY = y + (size - 1);
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX1, baseY);
+ triangle.addPoint(baseX2, baseY);
if (isEnabled)
- {
- g.setColor(Color.DARK_GRAY);
-
- if (arrow != null)
- g.fillPolygon(xPoints, yPoints, 3);
- }
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
else
- {
- g.setColor(Color.GRAY);
- g.fillPolygon(xPoints, yPoints, 3);
- g.setColor(Color.WHITE);
- g.drawLine(x1, y1, x2, y2);
- }
- g.setColor(saved);
- g.translate(-x, -y);
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(baseX1 + 1, baseY + 1, baseX2 + 1, baseY + 1);
+ }
}
+
+ /**
+ * Paints an downward-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleSouth(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x + (size - 2) / 2;
+ int tipY = y + (size - 1);
+ int baseX1 = tipX - (size - 1);
+ int baseX2 = tipX + (size - 1);
+ int baseY = y;
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX1, baseY);
+ triangle.addPoint(baseX2, baseY);
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(tipX + 1, tipY, baseX2, baseY + 1);
+ g.drawLine(tipX + 1, tipY + 1, baseX2 + 1, baseY + 1);
+ }
+ }
+
+ /**
+ * Paints a right-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleEast(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x + (size - 1);
+ int tipY = y + (size - 2) / 2;
+ int baseX = x;
+ int baseY1 = tipY - (size - 1);
+ int baseY2 = tipY + (size - 1);
+
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX, baseY1);
+ triangle.addPoint(baseX, baseY2);
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(baseX + 1, baseY2, tipX, tipY + 1);
+ g.drawLine(baseX + 1, baseY2 + 1, tipX + 1, tipY + 1);
+ }
+ }
+
+ /**
+ * Paints a left-pointing triangle. This method is called by the
+ * {@link #paintTriangle(Graphics, int, int, int, int, boolean)} method.
+ *
+ * @param g the graphics device.
+ * @param x the x-coordinate for the anchor point.
+ * @param y the y-coordinate for the anchor point.
+ * @param size the arrow size (depth).
+ * @param isEnabled if <code>true</code> the arrow is drawn in the enabled
+ * state, otherwise it is drawn in the disabled state.
+ */
+ private void paintTriangleWest(Graphics g, int x, int y, int size,
+ boolean isEnabled)
+ {
+ int tipX = x;
+ int tipY = y + (size - 2) / 2;
+ int baseX = x + (size - 1);
+ int baseY1 = tipY - (size - 1);
+ int baseY2 = tipY + (size - 1);
+
+ Polygon triangle = new Polygon();
+ triangle.addPoint(tipX, tipY);
+ triangle.addPoint(baseX, baseY1);
+ triangle.addPoint(baseX, baseY2);
+ if (isEnabled)
+ {
+ g.setColor(Color.DARK_GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ }
+ else
+ {
+ g.setColor(Color.GRAY);
+ g.fillPolygon(triangle);
+ g.drawPolygon(triangle);
+ g.setColor(Color.WHITE);
+ g.drawLine(baseX + 1, baseY1 + 1, baseX + 1, baseY2 + 1);
+ }
+ }
+
}
diff --git a/javax/swing/plaf/basic/BasicBorders.java b/javax/swing/plaf/basic/BasicBorders.java
index e7d6e4338..cec7bec85 100644
--- a/javax/swing/plaf/basic/BasicBorders.java
+++ b/javax/swing/plaf/basic/BasicBorders.java
@@ -806,9 +806,9 @@ public class BasicBorders
*/
public MarginBorder()
{
+ // Nothing to do here.
}
-
/**
* Measures the width of this border.
*
@@ -1313,33 +1313,32 @@ public class BasicBorders
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
- public static class SplitPaneBorder
- implements Border, UIResource
+ public static class SplitPaneBorder implements Border, UIResource
{
/**
* Indicates that the top edge shall be not be painted
- * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ * by {@link #paintRect}.
*/
private static final int SUPPRESS_TOP = 1;
/**
* Indicates that the left edge shall be not be painted
- * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ * by {@link #paintRect}.
*/
private static final int SUPPRESS_LEFT = 2;
/**
* Indicates that the bottom edge shall be not be painted
- * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ * by {@link #paintRect}.
*/
private static final int SUPPRESS_BOTTOM = 4;
/**
* Indicates that the right edge shall be not be painted
- * by {@link #paintRect(java.awt.Graphics, int, int, int, int, int)}.
+ * by {@link #paintRect}.
*/
private static final int SUPPRESS_RIGHT = 8;
diff --git a/javax/swing/plaf/basic/BasicButtonListener.java b/javax/swing/plaf/basic/BasicButtonListener.java
index 5349f5240..1fca69451 100644
--- a/javax/swing/plaf/basic/BasicButtonListener.java
+++ b/javax/swing/plaf/basic/BasicButtonListener.java
@@ -55,9 +55,8 @@ import javax.swing.JComponent;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-public class BasicButtonListener
- implements MouseListener, MouseMotionListener, FocusListener,
- ChangeListener, PropertyChangeListener
+public class BasicButtonListener implements MouseListener, MouseMotionListener,
+ FocusListener, ChangeListener, PropertyChangeListener
{
public BasicButtonListener(AbstractButton b)
{
@@ -66,10 +65,12 @@ public class BasicButtonListener
public void propertyChange(PropertyChangeEvent e)
{
+ // TODO: What should be done here, if anything?
}
protected void checkOpacity(AbstractButton b)
{
+ // TODO: What should be done here?
}
public void focusGained(FocusEvent e)
@@ -129,18 +130,22 @@ public class BasicButtonListener
public void stateChanged(ChangeEvent e)
{
+ // TODO: What should be done here, if anything?
}
public void mouseMoved(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
public void mouseDragged(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
public void mouseClicked(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
diff --git a/javax/swing/plaf/basic/BasicButtonUI.java b/javax/swing/plaf/basic/BasicButtonUI.java
index acc1265a6..2d3dbd350 100644
--- a/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/javax/swing/plaf/basic/BasicButtonUI.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
@@ -49,7 +48,9 @@ import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.InputMap;
+import javax.swing.JButton;
import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -57,6 +58,9 @@ import javax.swing.plaf.ButtonUI;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
+/**
+ * A UI delegate for the {@link JButton} component.
+ */
public class BasicButtonUI extends ButtonUI
{
/**
@@ -73,13 +77,11 @@ public class BasicButtonUI extends ButtonUI
private int textShiftOffset;
- private Color focusColor;
-
/**
* Factory method to create an instance of BasicButtonUI for a given
* {@link JComponent}, which should be an {@link AbstractButton}.
*
- * @param c The component to create a UI got
+ * @param c The component.
*
* @return A new UI capable of drawing the component
*/
@@ -88,21 +90,46 @@ public class BasicButtonUI extends ButtonUI
return new BasicButtonUI();
}
+ /**
+ * Returns the default gap between the button's text and icon (in pixels).
+ *
+ * @param b the button (ignored).
+ *
+ * @return The gap.
+ */
public int getDefaultTextIconGap(AbstractButton b)
{
return defaultTextIconGap;
}
+ /**
+ * Sets the text shift offset to zero.
+ *
+ * @see #setTextShiftOffset()
+ */
protected void clearTextShiftOffset()
{
textShiftOffset = 0;
}
+ /**
+ * Returns the text shift offset.
+ *
+ * @return The text shift offset.
+ *
+ * @see #clearTextShiftOffset()
+ * @see #setTextShiftOffset()
+ */
protected int getTextShiftOffset()
{
return textShiftOffset;
}
+ /**
+ * Sets the text shift offset to the value in {@link #defaultTextShiftOffset}.
+ *
+ * @see #clearTextShiftOffset()
+ */
protected void setTextShiftOffset()
{
textShiftOffset = defaultTextShiftOffset;
@@ -119,23 +146,29 @@ public class BasicButtonUI extends ButtonUI
return "Button.";
}
+ /**
+ * Installs the default settings.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
protected void installDefaults(AbstractButton b)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
String prefix = getPropertyPrefix();
- b.setFont(defaults.getFont(prefix + "font"));
- focusColor = defaults.getColor(prefix + "focus");
- b.setForeground(defaults.getColor(prefix + "foreground"));
- b.setBackground(defaults.getColor(prefix + "background"));
- b.setMargin(defaults.getInsets(prefix + "margin"));
- b.setBorder(defaults.getBorder(prefix + "border"));
- b.setIconTextGap(defaults.getInt(prefix + "textIconGap"));
+ LookAndFeel.installColorsAndFont(b, prefix + "background",
+ prefix + "foreground", prefix + "font");
+ LookAndFeel.installBorder(b, prefix + "border");
+ b.setMargin(UIManager.getInsets(prefix + "margin"));
+ b.setIconTextGap(UIManager.getInt(prefix + "textIconGap"));
b.setInputMap(JComponent.WHEN_FOCUSED,
- (InputMap) defaults.get(prefix + "focusInputMap"));
- b.setRolloverEnabled(defaults.getBoolean(prefix + "rollover"));
- b.setOpaque(true);
+ (InputMap) UIManager.get(prefix + "focusInputMap"));
+ b.setRolloverEnabled(UIManager.getBoolean(prefix + "rollover"));
}
+ /**
+ * Removes the defaults added by {@link #installDefaults(AbstractButton)}.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
protected void uninstallDefaults(AbstractButton b)
{
if (b.getFont() instanceof UIResource)
@@ -149,11 +182,25 @@ public class BasicButtonUI extends ButtonUI
protected BasicButtonListener listener;
+ /**
+ * Creates and returns a new instance of {@link BasicButtonListener}. This
+ * method provides a hook to make it easy for subclasses to install a
+ * different listener.
+ *
+ * @param b the button.
+ *
+ * @return A new listener.
+ */
protected BasicButtonListener createButtonListener(AbstractButton b)
{
return new BasicButtonListener(b);
}
+ /**
+ * Installs listeners for the button.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
protected void installListeners(AbstractButton b)
{
listener = createButtonListener(b);
@@ -164,6 +211,11 @@ public class BasicButtonUI extends ButtonUI
b.addMouseMotionListener(listener);
}
+ /**
+ * Uninstalls listeners for the button.
+ *
+ * @param b the button (<code>null</code> not permitted).
+ */
protected void uninstallListeners(AbstractButton b)
{
b.removeChangeListener(listener);
@@ -220,12 +272,12 @@ public class BasicButtonUI extends ButtonUI
return d;
}
- private static Icon currentIcon(AbstractButton b)
+ static Icon currentIcon(AbstractButton b)
{
Icon i = b.getIcon();
ButtonModel model = b.getModel();
- if (model.isPressed() && b.getPressedIcon() != null)
+ if (model.isPressed() && b.getPressedIcon() != null && b.isEnabled())
i = b.getPressedIcon();
else if (model.isRollover())
@@ -236,7 +288,7 @@ public class BasicButtonUI extends ButtonUI
i = b.getRolloverIcon();
}
- else if (b.isSelected())
+ else if (b.isSelected() && b.isEnabled())
{
if (b.isEnabled() && b.getSelectedIcon() != null)
i = b.getSelectedIcon();
@@ -287,13 +339,11 @@ public class BasicButtonUI extends ButtonUI
if ((b.getModel().isArmed() && b.getModel().isPressed())
|| b.isSelected())
paintButtonPressed(g, b);
- else
- paintButtonNormal(g, vr, c);
paintIcon(g, c, ir);
if (text != null)
paintText(g, b, tr, text);
- if (b.isFocusOwner())
+ if (b.isFocusOwner() && b.isFocusPainted())
paintFocus(g, b, vr, tr, ir);
}
@@ -339,44 +389,25 @@ public class BasicButtonUI extends ButtonUI
/**
* Paints the background area of an {@link AbstractButton} in the pressed
- * state. This means filling the supplied area with the {@link
- * pressedBackgroundColor}.
+ * state. This means filling the supplied area with a darker than normal
+ * background.
*
* @param g The graphics context to paint with
* @param b The button to paint the state of
*/
protected void paintButtonPressed(Graphics g, AbstractButton b)
{
- if (b.isContentAreaFilled())
- {
- Rectangle area = new Rectangle();
- SwingUtilities.calculateInnerArea(b, area);
- g.setColor(b.getBackground().darker());
- g.fillRect(area.x, area.y, area.width, area.height);
- }
- }
-
- /**
- * Paints the background area of an {@link AbstractButton} in the normal,
- * non-pressed state. This means filling the supplied area with the
- * {@link normalBackgroundColor}.
- *
- * @param g The graphics context to paint with
- * @param area The area in which to paint
- * @param b The component to paint the state of
- */
- private void paintButtonNormal(Graphics g, Rectangle area, JComponent b)
- {
- if (((AbstractButton)b).isContentAreaFilled() && b.isOpaque())
+ if (b.isContentAreaFilled() && b.isOpaque())
{
- g.setColor(b.getBackground());
+ Rectangle area = new Rectangle();
+ SwingUtilities.calculateInnerArea(b, area);
+ g.setColor(UIManager.getColor(getPropertyPrefix() + "shadow"));
g.fillRect(area.x, area.y, area.width, area.height);
}
}
/**
- * Paints the "text" property of an {@link AbstractButton}, using the
- * {@link textColor} color.
+ * Paints the "text" property of an {@link AbstractButton}.
*
* @param g The graphics context to paint with
* @param c The component to paint the state of
@@ -390,8 +421,7 @@ public class BasicButtonUI extends ButtonUI
}
/**
- * Paints the "text" property of an {@link AbstractButton}, using the
- * {@link textColor} color.
+ * Paints the "text" property of an {@link AbstractButton}.
*
* @param g The graphics context to paint with
* @param b The button to paint the state of
diff --git a/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java b/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
index 945aea53d..95e0dc982 100644
--- a/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
@@ -53,6 +53,15 @@ import javax.swing.plaf.ComponentUI;
*/
public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
{
+
+ /**
+ * Creates a new BasicCheckBoxMenuItemUI object.
+ */
+ public BasicCheckBoxMenuItemUI()
+ {
+ super();
+ }
+
/**
* Factory method to create a BasicCheckBoxMenuItemUI for the given {@link
* JComponent}, which should be a JCheckBoxMenuItem
@@ -77,18 +86,6 @@ public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
}
/**
- * This method installs the defaults that are defined in the Basic look and
- * feel for this JRadioButtonMenuItem
- */
- protected void installDefaults()
- {
- super.installDefaults();
-
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- checkIcon = defaults.getIcon("CheckBoxMenuItem.checkIcon");
- }
-
- /**
* DOCUMENT ME!
*
* @param item DOCUMENT ME!
@@ -100,5 +97,7 @@ public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
MenuElement[] path,
MenuSelectionManager manager)
{
+ // TODO: May not be implemented properly.
+ item.processMouseEvent(e, path, manager);
}
}
diff --git a/javax/swing/plaf/basic/BasicColorChooserUI.java b/javax/swing/plaf/basic/BasicColorChooserUI.java
index 4e6d38154..5a872ae63 100644
--- a/javax/swing/plaf/basic/BasicColorChooserUI.java
+++ b/javax/swing/plaf/basic/BasicColorChooserUI.java
@@ -47,8 +47,7 @@ import javax.swing.JColorChooser;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
+import javax.swing.LookAndFeel;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorChooserComponentFactory;
import javax.swing.event.ChangeEvent;
@@ -243,12 +242,21 @@ public class BasicColorChooserUI extends ColorChooserUI
{
uninstallListeners();
uninstallDefaults();
+ uninstallDefaultChoosers();
pane = null;
chooser = null;
}
/**
+ * Uninstalls the default color choosers that have been installed by this UI.
+ */
+ protected void uninstallDefaultChoosers()
+ {
+ defaultChoosers = null;
+ }
+
+ /**
* This method installs the preview panel for the JColorChooser.
*/
protected void installPreviewPanel()
@@ -281,11 +289,9 @@ public class BasicColorChooserUI extends ColorChooserUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- chooser.setFont(defaults.getFont("ColorChooser.font"));
- chooser.setForeground(defaults.getColor("ColorChooser.foreground"));
- chooser.setBackground(defaults.getColor("ColorChooser.background"));
+ LookAndFeel.installColorsAndFont(chooser, "ColorChooser.background",
+ "ColorChooser.foreground",
+ "ColorChooser.font");
}
/**
diff --git a/javax/swing/plaf/basic/BasicComboBoxEditor.java b/javax/swing/plaf/basic/BasicComboBoxEditor.java
index dd867f0dc..be8c776aa 100644
--- a/javax/swing/plaf/basic/BasicComboBoxEditor.java
+++ b/javax/swing/plaf/basic/BasicComboBoxEditor.java
@@ -168,6 +168,7 @@ public class BasicComboBoxEditor extends Object implements ComboBoxEditor,
*/
public UIResource()
{
+ // Nothing to do here.
}
}
}
diff --git a/javax/swing/plaf/basic/BasicComboBoxRenderer.java b/javax/swing/plaf/basic/BasicComboBoxRenderer.java
index 94a35bc69..8115605b7 100644
--- a/javax/swing/plaf/basic/BasicComboBoxRenderer.java
+++ b/javax/swing/plaf/basic/BasicComboBoxRenderer.java
@@ -156,6 +156,7 @@ public class BasicComboBoxRenderer
*/
public UIResource()
{
+ // Nothing to do here.
}
}
}
diff --git a/javax/swing/plaf/basic/BasicComboBoxUI.java b/javax/swing/plaf/basic/BasicComboBoxUI.java
index b4267e56a..7356423d3 100644
--- a/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -43,6 +43,7 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
@@ -70,8 +71,8 @@ import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
@@ -157,12 +158,29 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
protected PropertyChangeListener propertyChangeListener;
+ /**
+ * The button background.
+ * @see #installDefaults()
+ */
+ private Color buttonBackground;
+
+ /**
+ * The button shadow.
+ * @see #installDefaults()
+ */
+ private Color buttonShadow;
+
/**
- * Colors that are used to render selected item in the combo box.
+ * The button dark shadow.
+ * @see #installDefaults()
+ */
+ private Color buttonDarkShadow;
+
+ /**
+ * The button highlight.
+ * @see #installDefaults()
*/
- private Color shadow;
- private Color darkShadow;
- private Color highlight;
+ private Color buttonHighlight;
/* Size of the largest item in the comboBox
* This is package-private to avoid an accessor method.
@@ -179,6 +197,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public BasicComboBoxUI()
{
+ // Nothing to do here.
}
/**
@@ -207,13 +226,13 @@ public class BasicComboBoxUI extends ComboBoxUI
if (c instanceof JComboBox)
{
- comboBox = (JComboBox) c;
- comboBox.setOpaque(true);
- comboBox.setLayout(createLayoutManager());
- installDefaults();
- installComponents();
- installListeners();
- installKeyboardActions();
+ comboBox = (JComboBox) c;
+ comboBox.setOpaque(true);
+ comboBox.setLayout(createLayoutManager());
+ installDefaults();
+ installComponents();
+ installListeners();
+ installKeyboardActions();
}
}
@@ -241,21 +260,14 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- if (comboBox.getFont() instanceof UIResource)
- comboBox.setFont(defaults.getFont("ComboBox.font"));
+ LookAndFeel.installColorsAndFont(comboBox, "ComboBox.background",
+ "ComboBox.foreground", "ComboBox.font");
- if (comboBox.getForeground() instanceof UIResource)
- comboBox.setForeground(defaults.getColor("ComboBox.foreground"));
-
- if (comboBox.getBackground() instanceof UIResource)
- comboBox.setBackground(defaults.getColor("ComboBox.background"));
-
// fetch the button color scheme
- shadow = defaults.getColor("ComboBox.buttonShadow");
- darkShadow = defaults.getColor("ComboBox.buttonDarkShadow");
- highlight = defaults.getColor("ComboBox.buttonHighlight");
+ buttonBackground = UIManager.getColor("ComboBox.buttonBackground");
+ buttonShadow = UIManager.getColor("ComboBox.buttonShadow");
+ buttonDarkShadow = UIManager.getColor("ComboBox.buttonDarkShadow");
+ buttonHighlight = UIManager.getColor("ComboBox.buttonHighlight");
}
/**
@@ -303,9 +315,10 @@ public class BasicComboBoxUI extends ComboBoxUI
if (comboBox.getBackground() instanceof UIResource)
comboBox.setBackground(null);
- shadow = null;
- darkShadow = null;
- highlight = null;
+ buttonBackground = null;
+ buttonShadow = null;
+ buttonDarkShadow = null;
+ buttonHighlight = null;
}
/**
@@ -440,7 +453,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
protected ComboBoxEditor createEditor()
{
- return new BasicComboBoxEditor();
+ return new BasicComboBoxEditor.UIResource();
}
/**
@@ -450,25 +463,26 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
protected void installComponents()
{
- // create and install arrow button
- arrowButton = createArrowButton();
- configureArrowButton();
- comboBox.add(arrowButton);
-
- // Set list that will be used by BasicComboBoxRender
- // in order to determine the right colors when rendering
- listBox = new JList();
+ // create drop down list of items
+ popup = createPopup();
+ listBox = popup.getList();
// set editor and renderer for the combo box. Editor is used
// only if combo box becomes editable, otherwise renderer is used
// to paint the selected item; combobox is not editable by default.
comboBox.setRenderer(createRenderer());
- comboBox.setEditor(createEditor());
- editor = comboBox.getEditor().getEditorComponent();
+ // create and install arrow button
+ arrowButton = createArrowButton();
+ configureArrowButton();
+ comboBox.add(arrowButton);
- // create drop down list of items
- popup = createPopup();
+ ComboBoxEditor currentEditor = comboBox.getEditor();
+ if (currentEditor == null || currentEditor instanceof UIResource)
+ {
+ comboBox.setEditor(createEditor());
+ editor = comboBox.getEditor().getEditorComponent();
+ }
comboBox.revalidate();
}
@@ -490,8 +504,14 @@ public class BasicComboBoxUI extends ComboBoxUI
comboBox.setRenderer(null);
- comboBox.setEditor(null);
- editor = null;
+ // if the editor is not an instanceof UIResource, it was not set by the
+ // UI delegate, so don't clear it...
+ ComboBoxEditor currentEditor = comboBox.getEditor();
+ if (currentEditor instanceof UIResource)
+ {
+ comboBox.setEditor(null);
+ editor = null;
+ }
}
/**
@@ -537,16 +557,19 @@ public class BasicComboBoxUI extends ComboBoxUI
{
arrowButton.setEnabled(comboBox.isEnabled());
arrowButton.setFont(comboBox.getFont());
- arrowButton.setMargin(new Insets(0, 0, 0, 0));
}
/**
* Unconfigures the arrow button.
*
* @see #configureArrowButton()
+ *
+ * @specnote The specification says this method is implementation specific
+ * and should not be used or overridden.
*/
public void unconfigureArrowButton()
{
+ // Nothing to do here yet.
}
/**
@@ -558,7 +581,8 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
protected JButton createArrowButton()
{
- return new BasicArrowButton(BasicArrowButton.SOUTH);
+ return new BasicArrowButton(BasicArrowButton.SOUTH, buttonBackground,
+ buttonShadow, buttonDarkShadow, buttonHighlight);
}
/**
@@ -627,6 +651,9 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public Dimension getPreferredSize(JComponent c)
{
+ // note: overriding getMinimumSize() (for example in the MetalComboBoxUI
+ // class) affects the getPreferredSize() result, so it seems logical that
+ // this method is implemented by delegating to the getMinimumSize() method
return getMinimumSize(c);
}
@@ -641,9 +668,8 @@ public class BasicComboBoxUI extends ComboBoxUI
public Dimension getMinimumSize(JComponent c)
{
Dimension d = getDisplaySize();
- Dimension arrowDim = arrowButton.getPreferredSize();
- Dimension result = new Dimension(d.width + arrowDim.width,
- Math.max(d.height, arrowDim.height));
+ int arrowButtonWidth = d.height;
+ Dimension result = new Dimension(d.width + arrowButtonWidth, d.height);
return result;
}
@@ -656,7 +682,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*
* @param c The {@link JComponent} to find the maximum size for
*
- * @return The dimensions of the minimum size.
+ * @return The maximum size (<code>Dimension(32767, 32767)</code>).
*/
public Dimension getMaximumSize(JComponent c)
{
@@ -804,15 +830,24 @@ public class BasicComboBoxUI extends ComboBoxUI
}
/**
- * Returns default size for the combo box that doesn't contain any elements
- * in it
+ * Returns the default size for the display area of a combo box that does
+ * not contain any elements. This method returns the width and height of
+ * a single space in the current font, plus a margin of 1 pixel.
*
- * @return Default size of the combo box with no elements in it.
+ * @return The default display size.
+ *
+ * @see #getDisplaySize()
*/
protected Dimension getDefaultSize()
{
- // FIXME: Not implemented properly.
- return new Dimension(100, 5);
+ // There is nothing in the spec to say how this method should be
+ // implemented...so I've done some guessing, written some Mauve tests,
+ // and written something that gives dimensions that are close to the
+ // reference implementation.
+ FontMetrics fm = comboBox.getFontMetrics(comboBox.getFont());
+ int w = fm.charWidth(' ') + 2;
+ int h = fm.getHeight() + 2;
+ return new Dimension(w, h);
}
/**
@@ -823,40 +858,52 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
protected Dimension getDisplaySize()
{
- ComboBoxModel model = comboBox.getModel();
- int numItems = model.getSize();
-
- // if combo box doesn't have any items then simply
- // return its default size
- if (numItems == 0)
+ Object prototype = comboBox.getPrototypeDisplayValue();
+ if (prototype != null)
{
- displaySize = getDefaultSize();
- return displaySize;
+ // calculate result based on prototype
+ ListCellRenderer renderer = comboBox.getRenderer();
+ Component comp = renderer.getListCellRendererComponent(listBox,
+ prototype, -1, false, false);
+ Dimension compSize = comp.getPreferredSize();
+ compSize.width += 2; // add 1 pixel margin around area
+ compSize.height += 2;
+ return compSize;
}
+ else
+ {
+ ComboBoxModel model = comboBox.getModel();
+ int numItems = model.getSize();
- Dimension size = new Dimension(0, 0);
+ // if combo box doesn't have any items then simply
+ // return its default size
+ if (numItems == 0)
+ {
+ displaySize = getDefaultSize();
+ return displaySize;
+ }
- // ComboBox's display size should be equal to the
- // size of the largest item in the combo box.
- ListCellRenderer renderer = comboBox.getRenderer();
+ Dimension size = new Dimension(0, 0);
- // FIXME: use the JComboBox.getPrototypeDisplayValue() if there is
- // one
- for (int i = 0; i < numItems; i++)
- {
- Object item = model.getElementAt(i);
- String s = item.toString();
- Component comp = renderer.getListCellRendererComponent(listBox, item,
- -1, false, false);
+ // ComboBox's display size should be equal to the
+ // size of the largest item in the combo box.
+ ListCellRenderer renderer = comboBox.getRenderer();
- Dimension compSize = comp.getPreferredSize();
- if (compSize.width > size.width)
- size.width = compSize.width;
- if (compSize.height > size.height)
- size.height = compSize.height;
+ for (int i = 0; i < numItems; i++)
+ {
+ Object item = model.getElementAt(i);
+ Component comp = renderer.getListCellRendererComponent(listBox,
+ item, -1, false, false);
+
+ Dimension compSize = comp.getPreferredSize();
+ if (compSize.width + 2 > size.width)
+ size.width = compSize.width + 2;
+ if (compSize.height + 2 > size.height)
+ size.height = compSize.height + 2;
+ }
+ displaySize = size;
+ return displaySize;
}
- displaySize = size;
- return displaySize;
}
/**
@@ -890,6 +937,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public ComboBoxLayoutManager()
{
+ // Nothing to do here.
}
/**
@@ -976,6 +1024,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public FocusHandler()
{
+ // Nothing to do here.
}
/**
@@ -999,6 +1048,7 @@ public class BasicComboBoxUI extends ComboBoxUI
public void focusLost(FocusEvent e)
{
hasFocus = false;
+ setPopupVisible(comboBox, false);
comboBox.repaint();
}
}
@@ -1014,6 +1064,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public ItemHandler()
{
+ // Nothing to do here.
}
/**
@@ -1024,6 +1075,8 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public void itemStateChanged(ItemEvent e)
{
+ if (e.getStateChange() == ItemEvent.SELECTED && comboBox.isEditable())
+ comboBox.getEditor().setItem(e.getItem());
comboBox.repaint();
}
}
@@ -1035,6 +1088,7 @@ public class BasicComboBoxUI extends ComboBoxUI
{
public KeyHandler()
{
+ // Nothing to do here.
}
/**
@@ -1057,6 +1111,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public ListDataHandler()
{
+ // Nothing to do here.
}
/**
@@ -1114,6 +1169,7 @@ public class BasicComboBoxUI extends ComboBoxUI
*/
public PropertyChangeHandler()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/plaf/basic/BasicComboPopup.java b/javax/swing/plaf/basic/BasicComboPopup.java
index 73aac8d4e..7f3fab8f1 100644
--- a/javax/swing/plaf/basic/BasicComboPopup.java
+++ b/javax/swing/plaf/basic/BasicComboPopup.java
@@ -40,6 +40,7 @@ package javax.swing.plaf.basic;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ItemEvent;
@@ -179,7 +180,10 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));
- super.setPopupSize(cbBounds.width, popupHeight);
+ Insets insets1 = getInsets();
+ Insets insets2 = scroller.getInsets();
+ super.setPopupSize(cbBounds.width, popupHeight + insets1.top
+ + insets1.bottom + insets2.top + insets2.bottom);
// Highlight selected item in the combo box's drop down list
if (comboBox.getSelectedIndex() != -1)
@@ -714,7 +718,11 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
protected void updateListBoxSelectionForEvent(MouseEvent anEvent,
boolean shouldScroll)
{
- // FIXME: Need to implement
+ // TODO: We need to handle the shouldScroll parameter somehow.
+ int index = list.locationToIndex(anEvent.getPoint());
+ // Check for valid index.
+ if (index >= 0)
+ list.setSelectedIndex(index);
}
/**
@@ -732,6 +740,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected InvocationMouseHandler()
{
+ // Nothing to do here.
}
/**
@@ -744,7 +753,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
public void mousePressed(MouseEvent e)
{
if (comboBox.isEnabled())
- togglePopup();
+ togglePopup();
}
/**
@@ -768,15 +777,15 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
// then change selection and close popup
if (! (releasedComponent instanceof JComboBox))
{
- // List model contains the item over which mouse is released,
- // since it is updated every time the mouse is moved over a different
- // item in the list. Now that the mouse is released we need to
- // update model of the combo box as well.
- comboBox.setSelectedIndex(list.getSelectedIndex());
-
- if (isAutoScrolling)
- stopAutoScrolling();
- hide();
+ // List model contains the item over which mouse is released,
+ // since it is updated every time the mouse is moved over a different
+ // item in the list. Now that the mouse is released we need to
+ // update model of the combo box as well.
+ comboBox.setSelectedIndex(list.getSelectedIndex());
+
+ if (isAutoScrolling)
+ stopAutoScrolling();
+ hide();
}
}
}
@@ -792,6 +801,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected InvocationMouseMotionHandler()
{
+ // Nothing to do here.
}
/**
@@ -868,6 +878,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
protected ItemHandler()
{
+ // Nothing to do here.
}
/**
@@ -877,6 +888,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
*/
public void itemStateChanged(ItemEvent e)
{
+ // TODO: What should be done here?
}
}
@@ -890,16 +902,20 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
protected ListMouseHandler()
{
+ // Nothing to do here.
}
public void mousePressed(MouseEvent e)
{
+ // TODO: What should be do here?
}
public void mouseReleased(MouseEvent anEvent)
{
int index = list.locationToIndex(anEvent.getPoint());
- comboBox.setSelectedIndex(index);
+ // Check for valid index.
+ if (index >= 0)
+ comboBox.setSelectedIndex(index);
hide();
}
}
@@ -913,15 +929,12 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
protected ListMouseMotionHandler()
{
+ // Nothing to do here.
}
public void mouseMoved(MouseEvent anEvent)
{
- // Highlight list cells over which the mouse is located.
- // This changes list model, but has no effect on combo box's data model
- int index = list.locationToIndex(anEvent.getPoint());
- list.setSelectedIndex(index);
- list.repaint();
+ updateListBoxSelectionForEvent(anEvent, false);
}
}
@@ -934,6 +947,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
protected PropertyChangeHandler()
{
+ // Nothing to do here.
}
public void propertyChange(PropertyChangeEvent e)
@@ -1009,18 +1023,22 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
public ListDataHandler()
{
+ // Nothing to do here.
}
public void contentsChanged(ListDataEvent e)
{
+ // Nothing to do here.
}
public void intervalAdded(ListDataEvent e)
{
+ // Nothing to do here.
}
public void intervalRemoved(ListDataEvent e)
{
+ // Nothing to do here.
}
}
@@ -1032,10 +1050,12 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
protected ListSelectionHandler()
{
+ // Nothing to do here.
}
public void valueChanged(ListSelectionEvent e)
{
+ // Nothing to do here.
}
}
@@ -1046,10 +1066,12 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
public InvocationKeyHandler()
{
+ // Nothing to do here.
}
public void keyReleased(KeyEvent e)
{
+ // Nothing to do here.
}
}
}
diff --git a/javax/swing/plaf/basic/BasicDesktopIconUI.java b/javax/swing/plaf/basic/BasicDesktopIconUI.java
index 561b497f1..3f8730249 100644
--- a/javax/swing/plaf/basic/BasicDesktopIconUI.java
+++ b/javax/swing/plaf/basic/BasicDesktopIconUI.java
@@ -365,6 +365,7 @@ public class BasicDesktopIconUI extends DesktopIconUI
*/
public BasicDesktopIconUI()
{
+ // Nothing to do here.
}
/**
@@ -585,6 +586,7 @@ public class BasicDesktopIconUI extends DesktopIconUI
}
catch (PropertyVetoException pve)
{
+ // We do nothing if the attempt has been vetoed.
}
}
}
diff --git a/javax/swing/plaf/basic/BasicDesktopPaneUI.java b/javax/swing/plaf/basic/BasicDesktopPaneUI.java
index b59261b17..4116858da 100644
--- a/javax/swing/plaf/basic/BasicDesktopPaneUI.java
+++ b/javax/swing/plaf/basic/BasicDesktopPaneUI.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.beans.PropertyVetoException;
@@ -49,10 +50,10 @@ import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.KeyStroke;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.DesktopPaneUI;
+import javax.swing.plaf.UIResource;
/**
* This class is the UI delegate for JDesktopPane for the Basic look and feel.
@@ -74,13 +75,14 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
{
if (desktop.getSelectedFrame() != null)
{
- try
- {
- desktop.getSelectedFrame().setClosed(true);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ desktop.getSelectedFrame().setClosed(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempts has been vetoed.
+ }
}
}
@@ -112,13 +114,14 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
{
if (desktop.getSelectedFrame() != null)
{
- try
- {
- desktop.getSelectedFrame().setMaximum(true);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ desktop.getSelectedFrame().setMaximum(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempts has been vetoed.
+ }
}
}
@@ -150,13 +153,14 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
{
if (desktop.getSelectedFrame() != null)
{
- try
- {
- desktop.getSelectedFrame().setIcon(true);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ desktop.getSelectedFrame().setIcon(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
}
}
@@ -236,16 +240,17 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
JInternalFrame frame = desktop.getSelectedFrame();
if (frame != null)
{
- try
- {
- if (frame.isIcon())
- frame.setIcon(false);
- else if (frame.isMaximum())
- frame.setMaximum(false);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ if (frame.isIcon())
+ frame.setIcon(false);
+ else if (frame.isMaximum())
+ frame.setMaximum(false);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
}
}
@@ -304,6 +309,7 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
*/
public BasicDesktopPaneUI()
{
+ // Nothing to do here.
}
/**
@@ -361,9 +367,9 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- desktop.setBackground(defaults.getColor("desktop"));
+ Color bg = desktop.getBackground();
+ if (bg == null || bg instanceof UIResource)
+ desktop.setBackground(UIManager.getColor("desktop"));
}
/**
@@ -381,7 +387,7 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
protected void installKeyboardActions()
{
// FIXME: create actions and keystrokes.
- registerKeyboardAction();
+ registerKeyboardActions();
}
/**
@@ -405,7 +411,7 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
* This method registers the actions to the appropriate Action and Input
* maps.
*/
- protected void registerKeyboardAction()
+ protected void registerKeyboardActions()
{
// FIXME: Do the binding.
// XXX: the gtk windows tend to intercept a lot of the
diff --git a/javax/swing/plaf/basic/BasicFileChooserUI.java b/javax/swing/plaf/basic/BasicFileChooserUI.java
index 49013e199..9c6396565 100644
--- a/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -48,7 +48,6 @@ import java.awt.Point;
import java.awt.Polygon;
import java.awt.Window;
import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
@@ -60,9 +59,9 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
+
import javax.swing.AbstractAction;
import javax.swing.Action;
-import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JButton;
@@ -92,25 +91,31 @@ import javax.swing.plaf.FileChooserUI;
/**
- * DOCUMENT ME!
+ * A UI delegate for the {@link JFileChooser} component under the
+ * {@link BasicLookAndFeel}.
*/
public class BasicFileChooserUI extends FileChooserUI
{
/**
- * DOCUMENT ME!
+ * A file filter that accepts all files.
*/
protected class AcceptAllFileFilter extends FileFilter
{
+ /**
+ * Creates a new instance.
+ */
public AcceptAllFileFilter()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> always, as all files are accepted by this
+ * filter.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return Always <code>true</code>.
*/
public boolean accept(File f)
{
@@ -118,9 +123,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns a description for this filter.
*
- * @return DOCUMENT ME!
+ * @return A description for the file filter.
*/
public String getDescription()
{
@@ -129,7 +134,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Handles a user action to approve the dialog selection.
+ *
+ * @see BasicFileChooserUI#getApproveSelectionAction()
*/
protected class ApproveSelectionAction extends AbstractAction
{
@@ -138,13 +145,13 @@ public class BasicFileChooserUI extends FileChooserUI
*/
protected ApproveSelectionAction()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * Sets the current selection and closes the dialog.
*
- * @param e
- * DOCUMENT ME!
+ * @param e the action event.
*/
public void actionPerformed(ActionEvent e)
{
@@ -167,22 +174,26 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Provides presentation information about files and directories.
*/
protected class BasicFileView extends FileView
{
- /** DOCUMENT ME! */
+ /** Storage for cached icons. */
protected Hashtable iconCache = new Hashtable();
+ /**
+ * Creates a new instance.
+ */
public BasicFileView()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * Adds an icon to the cache, associating it with the given file/directory.
*
- * @param f DOCUMENT ME!
- * @param i DOCUMENT ME!
+ * @param f the file/directory.
+ * @param i the icon.
*/
public void cacheIcon(File f, Icon i)
{
@@ -190,7 +201,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Clears the icon cache.
*/
public void clearIconCache()
{
@@ -198,11 +209,12 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Retrieves the icon associated with the specified file/directory, if
+ * there is one.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return The cached icon (or <code>null</code>).
*/
public Icon getCachedIcon(File f)
{
@@ -210,11 +222,13 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns a description of the given file/directory. In this
+ * implementation, the description is the same as the name returned by
+ * {@link #getName(File)}.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return A description of the given file/directory.
*/
public String getDescription(File f)
{
@@ -222,11 +236,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns an icon appropriate for the given file or directory.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return An icon.
*/
public Icon getIcon(File f)
{
@@ -242,11 +256,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the name for the given file/directory.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return The name of the file/directory.
*/
public String getName(File f)
{
@@ -254,11 +268,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns a localised description for the type of file/directory.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return A type description for the given file/directory.
*/
public String getTypeDescription(File f)
{
@@ -269,11 +283,12 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns {@link Boolean#TRUE} if the given file/directory is hidden,
+ * and {@link Boolean#FALSE} otherwise.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return {@link Boolean#TRUE} or {@link Boolean#FALSE}.
*/
public Boolean isHidden(File f)
{
@@ -282,21 +297,24 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Handles an action to cancel the file chooser.
+ *
+ * @see BasicFileChooserUI#getCancelSelectionAction()
*/
protected class CancelSelectionAction extends AbstractAction
{
/**
- * Creates a new CancelSelectionAction object.
+ * Creates a new <code>CancelSelectionAction</code> object.
*/
protected CancelSelectionAction()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * Cancels the selection and closes the dialog.
*
- * @param e DOCUMENT ME!
+ * @param e the action event (ignored).
*/
public void actionPerformed(ActionEvent e)
{
@@ -306,21 +324,25 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * An action to handle changes to the parent directory (for example, via
+ * a click on the "up folder" button).
+ *
+ * @see BasicFileChooserUI#getChangeToParentDirectoryAction()
*/
protected class ChangeToParentDirectoryAction extends AbstractAction
{
/**
- * Creates a new ChangeToParentDirectoryAction object.
+ * Creates a new <code>ChangeToParentDirectoryAction</code> object.
*/
protected ChangeToParentDirectoryAction()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * Handles the action event.
*
- * @param e DOCUMENT ME!
+ * @param e the action event.
*/
public void actionPerformed(ActionEvent e)
{
@@ -331,11 +353,13 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * A mouse listener that handles double-click events.
+ *
+ * @see BasicFileChooserUI#createDoubleClickListener(JFileChooser, JList)
*/
protected class DoubleClickListener extends MouseAdapter
{
- /** DOCUMENT ME! */
+ /** A timer. */
private Timer timer = null;
/** DOCUMENT ME! */
@@ -359,10 +383,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Handles a mouse click event.
*
- * @param e
- * DOCUMENT ME!
+ * @param e the event.
*/
public void mouseClicked(MouseEvent e)
{
@@ -408,10 +431,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Handles a mouse entered event (NOT IMPLEMENTED).
*
- * @param e
- * DOCUMENT ME!
+ * @param e the mouse event.
*/
public void mouseEntered(MouseEvent e)
{
@@ -420,21 +442,26 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * An action that changes the file chooser to display the user's home
+ * directory.
+ *
+ * @see BasicFileChooserUI#getGoHomeAction()
*/
protected class GoHomeAction extends AbstractAction
{
/**
- * Creates a new GoHomeAction object.
+ * Creates a new <code>GoHomeAction</code> object.
*/
protected GoHomeAction()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * Sets the directory to the user's home directory, and repaints the
+ * file chooser component.
*
- * @param e DOCUMENT ME!
+ * @param e the action event (ignored).
*/
public void actionPerformed(ActionEvent e)
{
@@ -446,21 +473,24 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * An action that handles the creation of a new folder/directory.
+ *
+ * @see BasicFileChooserUI#getNewFolderAction()
*/
protected class NewFolderAction extends AbstractAction
{
/**
- * Creates a new NewFolderAction object.
+ * Creates a new <code>NewFolderAction</code> object.
*/
protected NewFolderAction()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * Handles the event by creating a new folder.
*
- * @param e DOCUMENT ME!
+ * @param e the action event (ignored).
*/
public void actionPerformed(ActionEvent e)
{
@@ -479,15 +509,18 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * A listener for selection events in the file list.
+ *
+ * @see BasicFileChooserUI#createListSelectionListener(JFileChooser)
*/
protected class SelectionListener implements ListSelectionListener
{
/**
- * Creates a new SelectionListener object.
+ * Creates a new <code>SelectionListener</code> object.
*/
protected SelectionListener()
{
+ // Nothing to do here.
}
/**
@@ -510,6 +543,8 @@ public class BasicFileChooserUI extends FileChooserUI
/**
* DOCUMENT ME!
+ *
+ * @see BasicFileChooserUI#getUpdateAction()
*/
protected class UpdateAction extends AbstractAction
{
@@ -518,28 +553,30 @@ public class BasicFileChooserUI extends FileChooserUI
*/
protected UpdateAction()
{
+ // Nothing to do here.
}
/**
- * DOCUMENT ME!
+ * NOT YET IMPLEMENTED.
*
- * @param e DOCUMENT ME!
+ * @param e the action event.
*/
public void actionPerformed(ActionEvent e)
{
+ // FIXME: implement this
}
}
- /** DOCUMENT ME! */
+ /** The localised mnemonic for the cancel button. */
protected int cancelButtonMnemonic;
- /** DOCUMENT ME! */
+ /** The localised text for the cancel button. */
protected String cancelButtonText;
- /** DOCUMENT ME! */
+ /** The localised tool tip text for the cancel button. */
protected String cancelButtonToolTipText;
- /** DOCUMENT ME! */
+ /** An icon representing a computer. */
protected Icon computerIcon = new Icon()
{
public int getIconHeight()
@@ -554,10 +591,11 @@ public class BasicFileChooserUI extends FileChooserUI
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ // FIXME: is this not implemented, or is the icon intentionally blank?
}
};
- /** DOCUMENT ME! */
+ /** An icon for the "details view" button. */
protected Icon detailsViewIcon = new Icon()
{
public int getIconHeight()
@@ -586,7 +624,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
};
- /** DOCUMENT ME! */
+ /** An icon representing a directory. */
protected Icon directoryIcon = new Icon()
{
public int getIconHeight()
@@ -625,16 +663,16 @@ public class BasicFileChooserUI extends FileChooserUI
}
};
- /** DOCUMENT ME! */
+ /** The localised Mnemonic for the open button. */
protected int directoryOpenButtonMnemonic;
- /** DOCUMENT ME! */
+ /** The localised text for the open button. */
protected String directoryOpenButtonText;
- /** DOCUMENT ME! */
+ /** The localised tool tip text for the open button. */
protected String directoryOpenButtonToolTipText;
- /** DOCUMENT ME! */
+ /** An icon representing a file. */
protected Icon fileIcon = new Icon()
{
public int getIconHeight()
@@ -674,7 +712,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
};
- /** DOCUMENT ME! */
+ /** An icon representing a floppy drive. */
protected Icon floppyDriveIcon = new Icon()
{
public int getIconHeight()
@@ -689,10 +727,11 @@ public class BasicFileChooserUI extends FileChooserUI
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ // FIXME: is this not implemented, or is the icon intentionally blank?
}
};
- /** DOCUMENT ME! */
+ /** An icon representing a hard drive. */
protected Icon hardDriveIcon = new Icon()
{
public int getIconHeight()
@@ -707,19 +746,20 @@ public class BasicFileChooserUI extends FileChooserUI
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ // FIXME: is this not implemented, or is the icon intentionally blank?
}
};
- /** DOCUMENT ME! */
+ /** The localised mnemonic for the "help" button. */
protected int helpButtonMnemonic;
- /** DOCUMENT ME! */
+ /** The localised text for the "help" button. */
protected String helpButtonText;
- /** DOCUMENT ME! */
+ /** The localised tool tip text for the help button. */
protected String helpButtonToolTipText;
- /** DOCUMENT ME! */
+ /** An icon representing the user's home folder. */
protected Icon homeFolderIcon = new Icon()
{
public int getIconHeight()
@@ -759,7 +799,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
};
- /** DOCUMENT ME! */
+ /** An icon for the "list view" button. */
protected Icon listViewIcon = new Icon()
{
public int getIconHeight()
@@ -801,37 +841,37 @@ public class BasicFileChooserUI extends FileChooserUI
}
};
- /** DOCUMENT ME! */
+ /** An icon for the "new folder" button. */
protected Icon newFolderIcon = directoryIcon;
- /** DOCUMENT ME! */
+ /** The localised mnemonic for the "open" button. */
protected int openButtonMnemonic;
- /** DOCUMENT ME! */
+ /** The localised text for the "open" button. */
protected String openButtonText;
- /** DOCUMENT ME! */
+ /** The localised tool tip text for the "open" button. */
protected String openButtonToolTipText;
- /** DOCUMENT ME! */
+ /** The localised mnemonic for the "save" button. */
protected int saveButtonMnemonic;
- /** DOCUMENT ME! */
+ /** The localised text for the "save" button. */
protected String saveButtonText;
- /** DOCUMENT ME! */
+ /** The localised tool tip text for the save button. */
protected String saveButtonToolTipText;
- /** DOCUMENT ME! */
+ /** The localised mnemonic for the "update" button. */
protected int updateButtonMnemonic;
- /** DOCUMENT ME! */
+ /** The localised text for the "update" button. */
protected String updateButtonText;
- /** DOCUMENT ME! */
+ /** The localised tool tip text for the "update" button. */
protected String updateButtonToolTipText;
- /** DOCUMENT ME! */
+ /** An icon for the "up folder" button. */
protected Icon upFolderIcon = new Icon()
{
public int getIconHeight()
@@ -882,71 +922,74 @@ public class BasicFileChooserUI extends FileChooserUI
// -- begin private, but package local since used in inner classes --
+ /** The file chooser component represented by this UI delegate. */
JFileChooser filechooser;
- /** DOCUMENT ME! */
+ /** The file list. */
JList filelist;
- /** DOCUMENT ME! */
+ /** The combo box used to display/select file filters. */
JComboBox filters;
- /** DOCUMENT ME! */
+ /** The model for the directory list. */
BasicDirectoryModel model;
- /** DOCUMENT ME! */
+ /** The file filter for all files. */
FileFilter acceptAll = new AcceptAllFileFilter();
- /** DOCUMENT ME! */
+ /** The default file view. */
FileView fv = new BasicFileView();
- /** DOCUMENT ME! */
+ /** The icon size. */
static final int ICON_SIZE = 24;
- /** DOCUMENT ME! */
+ /** A combo box for display/selection of parent directories. */
JComboBox parents;
- /** DOCUMENT ME! */
+ /** The current file name. */
String filename;
- /** DOCUMENT ME! */
+ /** The accept (open/save) button. */
JButton accept;
- /** DOCUMENT ME! */
+ /** The cancel button. */
JButton cancel;
- /** DOCUMENT ME! */
+ /** The button to move up to the parent directory. */
JButton upFolderButton;
- /** DOCUMENT ME! */
+ /** The button to create a new directory. */
JButton newFolderButton;
- /** DOCUMENT ME! */
+ /** The button to move to the user's home directory. */
JButton homeFolderButton;
- /** DOCUMENT ME! */
+ /** An optional accessory panel. */
JPanel accessoryPanel;
- /** DOCUMENT ME! */
+ /** A property change listener. */
PropertyChangeListener propertyChangeListener;
- /** DOCUMENT ME! */
+ /** The text describing the filter for "all files". */
String acceptAllFileFilterText;
- /** DOCUMENT ME! */
+ /** The text describing a directory type. */
String dirDescText;
- /** DOCUMENT ME! */
+ /** The text describing a file type. */
String fileDescText;
- /** DOCUMENT ME! */
+ /** Is a directory selected? */
boolean dirSelected = false;
- /** DOCUMENT ME! */
+ /** The current directory. */
File currDir = null;
+ // FIXME: describe what is contained in the bottom panel
+ /** The bottom panel. */
JPanel bottomPanel;
- /** DOCUMENT ME! */
+ /** The close panel. */
JPanel closePanel;
/** Text box that displays file name */
@@ -997,6 +1040,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
}
+ /**
+ * Closes the dialog.
+ */
void closeDialog()
{
Window owner = SwingUtilities.windowForComponent(filechooser);
@@ -1005,9 +1051,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * Creates a new BasicFileChooserUI object.
+ * Creates a new <code>BasicFileChooserUI</code> object.
*
- * @param b DOCUMENT ME!
+ * @param b the file chooser component.
*/
public BasicFileChooserUI(JFileChooser b)
{
@@ -1015,11 +1061,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns a UI delegate for the given component.
*
- * @param c DOCUMENT ME!
+ * @param c the component (should be a {@link JFileChooser}).
*
- * @return DOCUMENT ME!
+ * @return A new UI delegate.
*/
public static ComponentUI createUI(JComponent c)
{
@@ -1027,10 +1073,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Installs the UI for the specified component.
*
- * @param c
- * DOCUMENT ME!
+ * @param c the component (should be a {@link JFileChooser}).
*/
public void installUI(JComponent c)
{
@@ -1051,10 +1096,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Uninstalls this UI from the given component.
*
- * @param c
- * DOCUMENT ME!
+ * @param c the component (should be a {@link JFileChooser}).
*/
public void uninstallUI(JComponent c)
{
@@ -1161,9 +1205,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and install the subcomponents for the file chooser.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
public void installComponents(JFileChooser fc)
{
@@ -1285,9 +1329,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Uninstalls the components from the file chooser.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
public void uninstallComponents(JFileChooser fc)
{
@@ -1303,9 +1347,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Installs the listeners required by this UI delegate.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void installListeners(JFileChooser fc)
{
@@ -1325,9 +1369,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Uninstalls the listeners previously installed by this UI delegate.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void uninstallListeners(JFileChooser fc)
{
@@ -1336,9 +1380,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Installs the defaults for this UI delegate.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void installDefaults(JFileChooser fc)
{
@@ -1347,9 +1391,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Uninstalls the defaults previously added by this UI delegate.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void uninstallDefaults(JFileChooser fc)
{
@@ -1358,9 +1402,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Installs the icons for this UI delegate (NOT YET IMPLEMENTED).
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void installIcons(JFileChooser fc)
{
@@ -1368,9 +1412,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Uninstalls the icons previously added by this UI delegate (NOT YET
+ * IMPLEMENTED).
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void uninstallIcons(JFileChooser fc)
{
@@ -1378,9 +1423,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Installs the strings used by this UI delegate.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void installStrings(JFileChooser fc)
{
@@ -1408,9 +1453,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Uninstalls the strings previously added by this UI delegate.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
protected void uninstallStrings(JFileChooser fc)
{
@@ -1436,7 +1481,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates a new directory model.
*/
protected void createModel()
{
@@ -1444,9 +1489,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the directory model.
*
- * @return DOCUMENT ME!
+ * @return The directory model.
*/
public BasicDirectoryModel getModel()
{
@@ -1454,11 +1499,12 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates a listener to handle changes to the properties of the given
+ * file chooser component.
*
- * @param fc
- * DOCUMENT ME!
- * @return DOCUMENT ME!
+ * @param fc the file chooser component.
+ *
+ * @return A new listener.
*/
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
{
@@ -1575,9 +1621,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the current file name.
*
- * @return DOCUMENT ME!
+ * @return The current file name.
*/
public String getFileName()
{
@@ -1585,9 +1631,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the current directory name.
*
- * @return DOCUMENT ME!
+ * @return The directory name.
+ *
+ * @see #setDirectoryName(String)
*/
public String getDirectoryName()
{
@@ -1596,9 +1644,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Sets the file name.
*
- * @param filename DOCUMENT ME!
+ * @param filename the file name.
+ *
+ * @see #getFileName()
*/
public void setFileName(String filename)
{
@@ -1606,9 +1656,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Sets the directory name (NOT IMPLEMENTED).
*
- * @param dirname DOCUMENT ME!
+ * @param dirname the directory name.
+ *
+ * @see #getDirectoryName()
*/
public void setDirectoryName(String dirname)
{
@@ -1616,9 +1668,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Rescans the current directory.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*/
public void rescanCurrentDirectory(JFileChooser fc)
{
@@ -1627,10 +1679,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * NOT YET IMPLEMENTED.
*
- * @param fc DOCUMENT ME!
- * @param f DOCUMENT ME!
+ * @param fc the file chooser.
+ * @param f the file.
*/
public void ensureFileIsVisible(JFileChooser fc, File f)
{
@@ -1638,9 +1690,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the {@link JFileChooser} component that this UI delegate
+ * represents.
*
- * @return DOCUMENT ME!
+ * @return The component represented by this UI delegate.
*/
public JFileChooser getFileChooser()
{
@@ -1648,9 +1701,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the optional accessory panel.
*
- * @return DOCUMENT ME!
+ * @return The optional accessory panel.
*/
public JPanel getAccessoryPanel()
{
@@ -1658,11 +1711,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and returns an approve (open or save) button for the dialog.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*
- * @return DOCUMENT ME!
+ * @return The button.
*/
public JButton getApproveButton(JFileChooser fc)
{
@@ -1673,11 +1726,14 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the tool tip text for the approve (open/save) button. This first
+ * checks the file chooser to see if a value has been explicitly set - if
+ * not, a default value appropriate for the type of file chooser is
+ * returned.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser.
*
- * @return DOCUMENT ME!
+ * @return The tool tip text.
*/
public String getApproveButtonToolTipText(JFileChooser fc)
{
@@ -1690,7 +1746,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Clears the icon cache.
*/
public void clearIconCache()
{
@@ -1699,11 +1755,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates a new listener to handle selections in the file list.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser component.
*
- * @return DOCUMENT ME!
+ * @return A new instance of {@link SelectionListener}.
*/
public ListSelectionListener createListSelectionListener(JFileChooser fc)
{
@@ -1711,12 +1767,12 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates a new listener to handle double-click events.
*
- * @param fc DOCUMENT ME!
- * @param list DOCUMENT ME!
+ * @param fc the file chooser component.
+ * @param list the list.
*
- * @return DOCUMENT ME!
+ * @return A new instance of {@link DoubleClickListener}.
*/
protected MouseListener createDoubleClickListener(JFileChooser fc, JList list)
{
@@ -1724,9 +1780,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if a directory is selected, and
+ * <code>false</code> otherwise.
*
- * @return DOCUMENT ME!
+ * @return A boolean.
*/
protected boolean isDirectorySelected()
{
@@ -1734,9 +1791,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Sets the flag that indicates whether the current directory is selected.
*
- * @param selected DOCUMENT ME!
+ * @param selected the new flag value.
*/
protected void setDirectorySelected(boolean selected)
{
@@ -1744,9 +1801,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the current directory.
*
- * @return DOCUMENT ME!
+ * @return The current directory.
*/
protected File getDirectory()
{
@@ -1754,9 +1811,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Sets the current directory.
*
- * @param f DOCUMENT ME!
+ * @param f the directory.
*/
protected void setDirectory(File f)
{
@@ -1764,11 +1821,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the "accept all" file filter.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser component.
*
- * @return DOCUMENT ME!
+ * @return The "accept all" file filter.
*/
public FileFilter getAcceptAllFileFilter(JFileChooser fc)
{
@@ -1776,25 +1833,29 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the file view for the file chooser. This returns either the
+ * file view that has been explicitly set for the {@link JFileChooser}, or
+ * a default file view.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser component.
*
- * @return DOCUMENT ME!
+ * @return The file view.
+ *
+ * @see JFileChooser#getFileView()
*/
public FileView getFileView(JFileChooser fc)
{
- if (fc.getFileView() != null)
- return fc.getFileView();
return fv;
}
/**
- * DOCUMENT ME!
+ * Returns the dialog title.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser (<code>null</code> not permitted).
*
- * @return DOCUMENT ME!
+ * @return The dialog title.
+ *
+ * @see JFileChooser#getDialogTitle()
*/
public String getDialogTitle(JFileChooser fc)
{
@@ -1819,11 +1880,13 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the approve button mnemonic.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser (<code>null</code> not permitted).
*
- * @return DOCUMENT ME!
+ * @return The approve button mnemonic.
+ *
+ * @see JFileChooser#getApproveButtonMnemonic()
*/
public int getApproveButtonMnemonic(JFileChooser fc)
{
@@ -1836,11 +1899,13 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Returns the approve button text.
*
- * @param fc DOCUMENT ME!
+ * @param fc the file chooser (<code>null</code> not permitted).
*
- * @return DOCUMENT ME!
+ * @return The approve button text.
+ *
+ * @see JFileChooser#getApproveButtonText()
*/
public String getApproveButtonText(JFileChooser fc)
{
@@ -1853,9 +1918,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and returns a new action that will be used with the "new folder"
+ * button.
*
- * @return DOCUMENT ME!
+ * @return A new instance of {@link GoHomeAction}.
*/
public Action getNewFolderAction()
{
@@ -1863,9 +1929,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and returns a new action that will be used with the "home folder"
+ * button.
*
- * @return DOCUMENT ME!
+ * @return A new instance of {@link GoHomeAction}.
*/
public Action getGoHomeAction()
{
@@ -1873,9 +1940,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and returns a new action that will be used with the "up folder"
+ * button.
*
- * @return DOCUMENT ME!
+ * @return A new instance of {@link ChangeToParentDirectoryAction}.
*/
public Action getChangeToParentDirectoryAction()
{
@@ -1883,9 +1951,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and returns a new action that will be used with the "approve"
+ * button.
*
- * @return DOCUMENT ME!
+ * @return A new instance of {@link ApproveSelectionAction}.
*/
public Action getApproveSelectionAction()
{
@@ -1893,9 +1962,10 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and returns a new action that will be used with the "cancel"
+ * button.
*
- * @return DOCUMENT ME!
+ * @return A new instance of {@link CancelSelectionAction}.
*/
public Action getCancelSelectionAction()
{
@@ -1903,9 +1973,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Creates and returns a new instance of {@link UpdateAction}.
*
- * @return DOCUMENT ME!
+ * @return An action.
*/
public Action getUpdateAction()
{
diff --git a/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java b/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
index efef5d6d7..9c7f1c4c5 100644
--- a/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
+++ b/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
@@ -49,6 +49,7 @@ public class BasicFormattedTextFieldUI extends BasicTextFieldUI
{
public BasicFormattedTextFieldUI()
{
+ // Nothing to do here.
}
public static ComponentUI createUI(JComponent c)
diff --git a/javax/swing/plaf/basic/BasicGraphicsUtils.java b/javax/swing/plaf/basic/BasicGraphicsUtils.java
index 757ac47c9..068de345b 100644
--- a/javax/swing/plaf/basic/BasicGraphicsUtils.java
+++ b/javax/swing/plaf/basic/BasicGraphicsUtils.java
@@ -71,6 +71,7 @@ public class BasicGraphicsUtils
*/
public BasicGraphicsUtils()
{
+ // Nothing to do here.
}
diff --git a/javax/swing/plaf/basic/BasicIconFactory.java b/javax/swing/plaf/basic/BasicIconFactory.java
index 56a67b029..6debd6495 100644
--- a/javax/swing/plaf/basic/BasicIconFactory.java
+++ b/javax/swing/plaf/basic/BasicIconFactory.java
@@ -41,7 +41,6 @@ package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
-import java.awt.Polygon;
import java.io.Serializable;
import javax.swing.Icon;
@@ -241,34 +240,33 @@ public class BasicIconFactory implements Serializable
{
return new DummyIcon();
}
+
+ /**
+ * Returns a new instance of a 4 x 8 icon showing a small black triangle that
+ * points to the right. This is displayed in menu items that have a
+ * sub menu.
+ *
+ * @return The icon.
+ */
public static Icon getMenuArrowIcon()
{
return new Icon()
{
public int getIconHeight()
{
- return 12;
+ return 8;
}
-
public int getIconWidth()
{
- return 12;
+ return 4;
}
-
public void paintIcon(Component c, Graphics g, int x, int y)
{
- g.translate(x, y);
-
Color saved = g.getColor();
-
g.setColor(Color.BLACK);
-
- g.fillPolygon(new Polygon(new int[] { 3, 9, 3 },
- new int[] { 2, 6, 10 },
- 3));
-
+ for (int i = 0; i < 4; i++)
+ g.drawLine(x + i, y + i, x + i, y + 7 - i);
g.setColor(saved);
- g.translate(-x, -y);
}
};
}
diff --git a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index eded1c7fa..aced2769a 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -100,13 +100,14 @@ public class BasicInternalFrameTitlePane extends JComponent
{
if (frame.isClosable())
{
- try
- {
- frame.setClosed(true);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ frame.setClosed(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
}
}
}
@@ -138,13 +139,14 @@ public class BasicInternalFrameTitlePane extends JComponent
{
if (frame.isIconifiable() && ! frame.isIcon())
{
- try
- {
- frame.setIcon(true);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ frame.setIcon(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
}
}
}
@@ -175,13 +177,14 @@ public class BasicInternalFrameTitlePane extends JComponent
{
try
{
- if (frame.isMaximizable() && ! frame.isMaximum())
- frame.setMaximum(true);
- else if (frame.isMaximum())
- frame.setMaximum(false);
+ if (frame.isMaximizable() && ! frame.isMaximum())
+ frame.setMaximum(true);
+ else if (frame.isMaximum())
+ frame.setMaximum(false);
}
catch (PropertyVetoException pve)
{
+ // We do nothing if the attempt has been vetoed.
}
}
}
@@ -240,13 +243,14 @@ public class BasicInternalFrameTitlePane extends JComponent
{
if (frame.isMaximum())
{
- try
- {
- frame.setMaximum(false);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ frame.setMaximum(false);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if the attempt has been vetoed.
+ }
}
}
}
@@ -481,6 +485,7 @@ public class BasicInternalFrameTitlePane extends JComponent
*/
public void removeLayoutComponent(Component c)
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/basic/BasicInternalFrameUI.java b/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 5f20fecff..6bc3aace3 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -56,20 +56,17 @@ import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
-import javax.swing.BorderFactory;
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
-import javax.swing.border.BevelBorder;
-import javax.swing.border.Border;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import javax.swing.event.MouseInputAdapter;
@@ -448,6 +445,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void addLayoutComponent(String name, Component c)
{
+ // Nothing to do here.
}
/**
@@ -637,6 +635,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void removeLayoutComponent(Component c)
{
+ // Nothing to do here.
}
}
@@ -950,7 +949,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
if (frame.isSelected())
activateFrame(frame);
else
- getDesktopManager().deactivateFrame(frame);
+ deactivateFrame(frame);
}
else if (evt.getPropertyName().equals(JInternalFrame.ROOT_PANE_PROPERTY)
|| evt.getPropertyName().equals(
@@ -1138,6 +1137,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public BasicInternalFrameUI(JInternalFrame b)
{
+ // Nothing to do here.
}
/**
@@ -1204,10 +1204,8 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- Border border = defaults.getBorder("InternalFrame.border");
- frame.setBorder(border);
- frame.setFrameIcon(defaults.getIcon("InternalFrame.icon"));
+ LookAndFeel.installBorder(frame, "InternalFrame.border");
+ frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));
// InternalFrames are invisible by default.
frame.setVisible(false);
}
@@ -1705,6 +1703,16 @@ public class BasicInternalFrameUI extends InternalFrameUI
}
/**
+ * This is a convenience method that deactivates the JInternalFrame.
+ *
+ * @param f the JInternalFrame to deactivate
+ */
+ protected void deactivateFrame(JInternalFrame f)
+ {
+ getDesktopManager().deactivateFrame(f);
+ }
+
+ /**
* This method returns a new ComponentListener for the JDesktopPane.
*
* @return A new ComponentListener.
diff --git a/javax/swing/plaf/basic/BasicLabelUI.java b/javax/swing/plaf/basic/BasicLabelUI.java
index bb9ce6cb1..c8f677fa0 100644
--- a/javax/swing/plaf/basic/BasicLabelUI.java
+++ b/javax/swing/plaf/basic/BasicLabelUI.java
@@ -50,9 +50,8 @@ import java.beans.PropertyChangeListener;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JLabel;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.LabelUI;
@@ -60,9 +59,7 @@ import javax.swing.plaf.LabelUI;
* This is the Basic Look and Feel class for the JLabel. One BasicLabelUI
* object is used to paint all JLabels that utilize the Basic Look and Feel.
*/
-public class BasicLabelUI
- extends LabelUI
- implements PropertyChangeListener
+public class BasicLabelUI extends LabelUI implements PropertyChangeListener
{
/** The labelUI that is shared by all labels. */
protected static BasicLabelUI labelUI;
@@ -345,11 +342,8 @@ public class BasicLabelUI
*/
protected void installDefaults(JLabel c)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- c.setForeground(defaults.getColor("Label.foreground"));
- c.setBackground(defaults.getColor("Label.background"));
- c.setFont(defaults.getFont("Label.font"));
+ LookAndFeel.installColorsAndFont(c, "Label.background", "Label.foreground",
+ "Label.font");
//XXX: There are properties we don't use called disabledForeground
//and disabledShadow.
}
@@ -417,8 +411,6 @@ public class BasicLabelUI
*/
public void propertyChange(PropertyChangeEvent e)
{
- JLabel c = (JLabel) e.getSource();
- c.revalidate();
- c.repaint();
+ // What to do here?
}
}
diff --git a/javax/swing/plaf/basic/BasicListUI.java b/javax/swing/plaf/basic/BasicListUI.java
index 841bd670f..1616d5e4f 100644
--- a/javax/swing/plaf/basic/BasicListUI.java
+++ b/javax/swing/plaf/basic/BasicListUI.java
@@ -44,25 +44,31 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
import javax.swing.CellRendererPane;
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JViewport;
+import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.ListSelectionModel;
+import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ListDataEvent;
@@ -71,6 +77,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InputMapUIResource;
import javax.swing.plaf.ListUI;
/**
@@ -125,8 +132,9 @@ public class BasicListUI extends ListUI
* Helper method to repaint the focused cell's
* lost or acquired focus state.
*/
- void repaintCellFocus()
+ protected void repaintCellFocus()
{
+ // TODO: Implement this properly.
}
}
@@ -183,141 +191,228 @@ public class BasicListUI extends ListUI
*/
public void valueChanged(ListSelectionEvent e)
{
+ // TODO: Implement this properly.
}
}
/**
- * A helper class which listens for {@link KeyEvents}s
- * from the {@link JList}.
+ * This class is used to mimmic the behaviour of the JDK when registering
+ * keyboard actions. It is the same as the private class used in JComponent
+ * for the same reason. This class receives an action event and dispatches
+ * it to the true receiver after altering the actionCommand property of the
+ * event.
*/
- private class KeyHandler extends KeyAdapter
+ private static class ActionListenerProxy
+ extends AbstractAction
{
- public KeyHandler()
+ ActionListener target;
+ String bindingCommandName;
+
+ public ActionListenerProxy(ActionListener li,
+ String cmd)
+ {
+ target = li;
+ bindingCommandName = cmd;
+ }
+
+ public void actionPerformed(ActionEvent e)
{
+ ActionEvent derivedEvent = new ActionEvent(e.getSource(),
+ e.getID(),
+ bindingCommandName,
+ e.getModifiers());
+ target.actionPerformed(derivedEvent);
}
-
- public void keyPressed( KeyEvent evt )
+ }
+
+ class ListAction extends AbstractAction
+ {
+ public void actionPerformed (ActionEvent e)
{
- int lead = BasicListUI.this.list.getLeadSelectionIndex();
- int max = BasicListUI.this.list.getModel().getSize() - 1;
+ int lead = list.getLeadSelectionIndex();
+ int max = list.getModel().getSize() - 1;
+ DefaultListSelectionModel selModel = (DefaultListSelectionModel)list.getSelectionModel();
+ String command = e.getActionCommand();
// Do nothing if list is empty
if (max == -1)
return;
-
- // Process the key event. Bindings can be found in
- // javax.swing.plaf.basic.BasicLookAndFeel.java
- if ((evt.getKeyCode() == KeyEvent.VK_DOWN)
- || (evt.getKeyCode() == KeyEvent.VK_KP_DOWN))
+
+ if (command.equals("selectNextRow"))
{
- if (evt.getModifiers() == 0)
- {
- BasicListUI.this.list.clearSelection();
- BasicListUI.this.list.setSelectedIndex(Math.min(lead+1,max));
- }
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ selectNextIndex();
+ }
+ else if (command.equals("selectPreviousRow"))
+ {
+ selectPreviousIndex();
+ }
+ else if (command.equals("clearSelection"))
+ {
+ list.clearSelection();
+ }
+ else if (command.equals("selectAll"))
+ {
+ list.setSelectionInterval(0, max);
+ // this next line is to restore the lead selection index to the old
+ // position, because select-all should not change the lead index
+ list.addSelectionInterval(lead, lead);
+ }
+ else if (command.equals("selectLastRow"))
+ {
+ list.setSelectedIndex(list.getModel().getSize() - 1);
+ }
+ else if (command.equals("selectLastRowChangeLead"))
+ {
+ selModel.moveLeadSelectionIndex(list.getModel().getSize() - 1);
+ }
+ else if (command.equals("scrollDownExtendSelection"))
+ {
+ int target;
+ if (lead == list.getLastVisibleIndex())
{
- BasicListUI.this.list.getSelectionModel().
- setLeadSelectionIndex(Math.min(lead+1,max));
+ target = Math.min
+ (max, lead + (list.getLastVisibleIndex() -
+ list.getFirstVisibleIndex() + 1));
}
+ else
+ target = list.getLastVisibleIndex();
+ selModel.setLeadSelectionIndex(target);
}
- else if ((evt.getKeyCode() == KeyEvent.VK_UP)
- || (evt.getKeyCode() == KeyEvent.VK_KP_UP))
+ else if (command.equals("scrollDownChangeLead"))
{
- if (evt.getModifiers() == 0)
+ int target;
+ if (lead == list.getLastVisibleIndex())
{
- BasicListUI.this.list.clearSelection();
- BasicListUI.this.list.setSelectedIndex(Math.max(lead-1,0));
+ target = Math.min
+ (max, lead + (list.getLastVisibleIndex() -
+ list.getFirstVisibleIndex() + 1));
}
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ else
+ target = list.getLastVisibleIndex();
+ selModel.moveLeadSelectionIndex(target);
+ }
+ else if (command.equals("scrollUpExtendSelection"))
+ {
+ int target;
+ if (lead == list.getFirstVisibleIndex())
{
- BasicListUI.this.list.getSelectionModel().
- setLeadSelectionIndex(Math.max(lead-1,0));
+ target = Math.max
+ (0, lead - (list.getLastVisibleIndex() -
+ list.getFirstVisibleIndex() + 1));
}
+ else
+ target = list.getFirstVisibleIndex();
+ selModel.setLeadSelectionIndex(target);
}
- else if (evt.getKeyCode() == KeyEvent.VK_PAGE_UP)
+ else if (command.equals("scrollUpChangeLead"))
{
int target;
- if (lead == BasicListUI.this.list.getFirstVisibleIndex())
+ if (lead == list.getFirstVisibleIndex())
{
target = Math.max
- (0, lead - (BasicListUI.this.list.getLastVisibleIndex() -
- BasicListUI.this.list.getFirstVisibleIndex() + 1));
+ (0, lead - (list.getLastVisibleIndex() -
+ list.getFirstVisibleIndex() + 1));
}
else
+ target = list.getFirstVisibleIndex();
+ selModel.moveLeadSelectionIndex(target);
+ }
+ else if (command.equals("selectNextRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(Math.min(lead + 1,max));
+ }
+ else if (command.equals("selectFirstRow"))
+ {
+ list.setSelectedIndex(0);
+ }
+ else if (command.equals("selectFirstRowChangeLead"))
+ {
+ selModel.moveLeadSelectionIndex(0);
+ }
+ else if (command.equals("selectFirstRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(0);
+ }
+ else if (command.equals("selectPreviousRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(Math.max(0,lead - 1));
+ }
+ else if (command.equals("scrollUp"))
+ {
+ int target;
+ if (lead == list.getFirstVisibleIndex())
{
- target = BasicListUI.this.list.getFirstVisibleIndex();
+ target = Math.max
+ (0, lead - (list.getLastVisibleIndex() -
+ list.getFirstVisibleIndex() + 1));
}
- if (evt.getModifiers() == 0)
- BasicListUI.this.list.setSelectedIndex(target);
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- BasicListUI.this.list.getSelectionModel().
- setLeadSelectionIndex(target);
+ else
+ target = list.getFirstVisibleIndex();
+ list.setSelectedIndex(target);
}
- else if (evt.getKeyCode() == KeyEvent.VK_PAGE_DOWN)
+ else if (command.equals("selectLastRowExtendSelection"))
+ {
+ selModel.setLeadSelectionIndex(list.getModel().getSize() - 1);
+ }
+ else if (command.equals("scrollDown"))
{
int target;
- if (lead == BasicListUI.this.list.getLastVisibleIndex())
+ if (lead == list.getLastVisibleIndex())
{
target = Math.min
- (max, lead + (BasicListUI.this.list.getLastVisibleIndex() -
- BasicListUI.this.list.getFirstVisibleIndex() + 1));
+ (max, lead + (list.getLastVisibleIndex() -
+ list.getFirstVisibleIndex() + 1));
}
else
+ target = list.getLastVisibleIndex();
+ list.setSelectedIndex(target);
+ }
+ else if (command.equals("selectNextRowChangeLead"))
+ {
+ if (selModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ selectNextIndex();
+ else
+ {
+ selModel.moveLeadSelectionIndex(Math.min(max, lead + 1));
+ }
+ }
+ else if (command.equals("selectPreviousRowChangeLead"))
+ {
+ if (selModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ selectPreviousIndex();
+ else
{
- target = BasicListUI.this.list.getLastVisibleIndex();
+ selModel.moveLeadSelectionIndex(Math.max(0, lead - 1));
}
- if (evt.getModifiers() == 0)
- BasicListUI.this.list.setSelectedIndex(target);
- else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
- BasicListUI.this.list.getSelectionModel().
- setLeadSelectionIndex(target);
- }
- else if (evt.getKeyCode() == KeyEvent.VK_BACK_SLASH
- && (evt.getModifiers() == InputEvent.CTRL_MASK))
+ }
+ else if (command.equals("addToSelection"))
{
- BasicListUI.this.list.clearSelection();
+ list.addSelectionInterval(lead, lead);
}
- else if ((evt.getKeyCode() == KeyEvent.VK_HOME)
- || evt.getKeyCode() == KeyEvent.VK_END)
+ else if (command.equals("extendTo"))
{
- if (evt.getModifiers() != 0 &&
- evt.getModifiers() != InputEvent.SHIFT_MASK)
- return;
- // index is either 0 for HOME, or last cell for END
- int index = (evt.getKeyCode() == KeyEvent.VK_HOME) ? 0 : max;
-
- if (!evt.isShiftDown() ||(BasicListUI.this.list.getSelectionMode()
- == ListSelectionModel.SINGLE_SELECTION))
- BasicListUI.this.list.setSelectedIndex(index);
- else if (BasicListUI.this.list.getSelectionMode() ==
- ListSelectionModel.SINGLE_INTERVAL_SELECTION)
- BasicListUI.this.list.setSelectionInterval
- (BasicListUI.this.list.getAnchorSelectionIndex(), index);
- else
- BasicListUI.this.list.getSelectionModel().
- setLeadSelectionIndex(index);
+ selModel.setSelectionInterval(selModel.getAnchorSelectionIndex(),
+ lead);
}
- else if ((evt.getKeyCode() == KeyEvent.VK_A || evt.getKeyCode()
- == KeyEvent.VK_SLASH) && (evt.getModifiers() ==
- InputEvent.CTRL_MASK))
+ else if (command.equals("toggleAndAnchor"))
{
- BasicListUI.this.list.setSelectionInterval(0, max);
- // this next line is to restore the lead selection index to the old
- // position, because select-all should not change the lead index
- BasicListUI.this.list.addSelectionInterval(lead, lead);
+ if (!list.isSelectedIndex(lead))
+ list.addSelectionInterval(lead, lead);
+ else
+ list.removeSelectionInterval(lead, lead);
+ selModel.setAnchorSelectionIndex(lead);
}
- else if (evt.getKeyCode() == KeyEvent.VK_SPACE &&
- (evt.getModifiers() == InputEvent.CTRL_MASK))
+ else
{
- BasicListUI.this.list.getSelectionModel().
- setLeadSelectionIndex(Math.min(lead+1,max));
+ // DEBUG: uncomment the following line to print out
+ // key bindings that aren't implemented yet
+
+ // System.out.println ("not implemented: "+e.getActionCommand());
}
-
- BasicListUI.this.list.ensureIndexIsVisible
- (BasicListUI.this.list.getLeadSelectionIndex());
+
+ list.ensureIndexIsVisible(list.getLeadSelectionIndex());
}
}
-
+
/**
* A helper class which listens for {@link MouseEvent}s
* from the {@link JList}.
@@ -333,48 +428,46 @@ public class BasicListUI extends ListUI
public void mouseClicked(MouseEvent event)
{
Point click = event.getPoint();
- int index = BasicListUI.this.locationToIndex(list, click);
+ int index = locationToIndex(list, click);
if (index == -1)
return;
if (event.isShiftDown())
{
- if (BasicListUI.this.list.getSelectionMode() ==
- ListSelectionModel.SINGLE_SELECTION)
- BasicListUI.this.list.setSelectedIndex(index);
- else if (BasicListUI.this.list.getSelectionMode() ==
+ if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)
+ list.setSelectedIndex(index);
+ else if (list.getSelectionMode() ==
ListSelectionModel.SINGLE_INTERVAL_SELECTION)
// COMPAT: the IBM VM is compatible with the following line of code.
// However, compliance with Sun's VM would correspond to replacing
// getAnchorSelectionIndex() with getLeadSelectionIndex().This is
// both unnatural and contradictory to the way they handle other
// similar UI interactions.
- BasicListUI.this.list.setSelectionInterval
- (BasicListUI.this.list.getAnchorSelectionIndex(), index);
+ list.setSelectionInterval(list.getAnchorSelectionIndex(), index);
else
// COMPAT: both Sun and IBM are compatible instead with:
- // BasicListUI.this.list.setSelectionInterval
- // (BasicListUI.this.list.getLeadSelectionIndex(),index);
+ // list.setSelectionInterval
+ // (list.getLeadSelectionIndex(),index);
// Note that for IBM this is contradictory to what they did in
// the above situation for SINGLE_INTERVAL_SELECTION.
// The most natural thing to do is the following:
- BasicListUI.this.list.getSelectionModel().
- setLeadSelectionIndex(index);
+ if (list.isSelectedIndex(list.getAnchorSelectionIndex()))
+ list.getSelectionModel().setLeadSelectionIndex(index);
+ else
+ list.addSelectionInterval(list.getAnchorSelectionIndex(), index);
}
else if (event.isControlDown())
{
- if (BasicListUI.this.list.getSelectionMode() ==
- ListSelectionModel.SINGLE_SELECTION)
- BasicListUI.this.list.setSelectedIndex(index);
- else if (BasicListUI.this.list.isSelectedIndex(index))
- BasicListUI.this.list.removeSelectionInterval(index,index);
+ if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)
+ list.setSelectedIndex(index);
+ else if (list.isSelectedIndex(index))
+ list.removeSelectionInterval(index,index);
else
- BasicListUI.this.list.addSelectionInterval(index,index);
+ list.addSelectionInterval(index,index);
}
else
- BasicListUI.this.list.setSelectedIndex(index);
+ list.setSelectedIndex(index);
- BasicListUI.this.list.ensureIndexIsVisible
- (BasicListUI.this.list.getLeadSelectionIndex());
+ list.ensureIndexIsVisible(list.getLeadSelectionIndex());
}
/**
@@ -385,6 +478,7 @@ public class BasicListUI extends ListUI
*/
public void mousePressed(MouseEvent event)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -395,6 +489,7 @@ public class BasicListUI extends ListUI
*/
public void mouseReleased(MouseEvent event)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -405,6 +500,7 @@ public class BasicListUI extends ListUI
*/
public void mouseEntered(MouseEvent event)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -415,6 +511,7 @@ public class BasicListUI extends ListUI
*/
public void mouseExited(MouseEvent event)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -425,6 +522,7 @@ public class BasicListUI extends ListUI
*/
public void mouseDragged(MouseEvent event)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -435,6 +533,7 @@ public class BasicListUI extends ListUI
*/
public void mouseMoved(MouseEvent event)
{
+ // TODO: What should be done here, if anything?
}
}
@@ -459,11 +558,62 @@ public class BasicListUI extends ListUI
if (e.getNewValue() != null && e.getNewValue() instanceof ListModel)
((ListModel) e.getNewValue()).addListDataListener(BasicListUI.this.listDataListener);
}
+ // Update the updateLayoutStateNeeded flag.
+ if (e.getPropertyName().equals("model"))
+ updateLayoutStateNeeded += modelChanged;
+ else if (e.getPropertyName().equals("selectionModel"))
+ updateLayoutStateNeeded += selectionModelChanged;
+ else if (e.getPropertyName().equals("font"))
+ updateLayoutStateNeeded += fontChanged;
+ else if (e.getPropertyName().equals("fixedCellWidth"))
+ updateLayoutStateNeeded += fixedCellWidthChanged;
+ else if (e.getPropertyName().equals("fixedCellHeight"))
+ updateLayoutStateNeeded += fixedCellHeightChanged;
+ else if (e.getPropertyName().equals("prototypeCellValue"))
+ updateLayoutStateNeeded += prototypeCellValueChanged;
+ else if (e.getPropertyName().equals("cellRenderer"))
+ updateLayoutStateNeeded += cellRendererChanged;
+
BasicListUI.this.damageLayout();
}
}
/**
+ * A constant to indicate that the model has changed.
+ */
+ protected static final int modelChanged = 1;
+
+ /**
+ * A constant to indicate that the selection model has changed.
+ */
+ protected static final int selectionModelChanged = 2;
+
+ /**
+ * A constant to indicate that the font has changed.
+ */
+ protected static final int fontChanged = 4;
+
+ /**
+ * A constant to indicate that the fixedCellWidth has changed.
+ */
+ protected static final int fixedCellWidthChanged = 8;
+
+ /**
+ * A constant to indicate that the fixedCellHeight has changed.
+ */
+ protected static final int fixedCellHeightChanged = 16;
+
+ /**
+ * A constant to indicate that the prototypeCellValue has changed.
+ */
+ protected static final int prototypeCellValueChanged = 32;
+
+ /**
+ * A constant to indicate that the cellRenderer has changed.
+ */
+ protected static final int cellRendererChanged = 64;
+
+ /**
* Creates a new BasicListUI for the component.
*
* @param c The component to create a UI for
@@ -487,9 +637,6 @@ public class BasicListUI extends ListUI
/** The mouse listener listening to the list. */
protected MouseInputListener mouseInputListener;
- /** The key listener listening to the list */
- private KeyHandler keyListener;
-
/** The property change listener listening to the list. */
protected PropertyChangeListener propertyChangeListener;
@@ -514,9 +661,18 @@ public class BasicListUI extends ListUI
protected int[] cellHeights;
/**
- * A simple counter. When nonzero, indicates that the UI class is out of
+ * A bitmask that indicates which properties of the JList have changed.
+ * When nonzero, indicates that the UI class is out of
* date with respect to the underlying list, and must recalculate the
* list layout before painting or performing size calculations.
+ *
+ * @see #modelChanged
+ * @see #selectionModelChanged
+ * @see #fontChanged
+ * @see #fixedCellWidthChanged
+ * @see #fixedCellHeightChanged
+ * @see #prototypeCellValueChanged
+ * @see #cellRendererChanged
*/
protected int updateLayoutStateNeeded;
@@ -524,6 +680,9 @@ public class BasicListUI extends ListUI
* The {@link CellRendererPane} that is used for painting.
*/
protected CellRendererPane rendererPane;
+
+ /** The action bound to KeyStrokes. */
+ ListAction action;
/**
* Calculate the height of a particular row. If there is a fixed {@link
@@ -694,13 +853,6 @@ public class BasicListUI extends ListUI
*/
public BasicListUI()
{
- focusListener = new FocusHandler();
- listDataListener = new ListDataHandler();
- listSelectionListener = new ListSelectionHandler();
- mouseInputListener = new MouseInputHandler();
- keyListener = new KeyHandler();
- propertyChangeListener = new PropertyChangeHandler();
- componentListener = new ComponentHandler();
updateLayoutStateNeeded = 1;
rendererPane = new CellRendererPane();
}
@@ -713,11 +865,10 @@ public class BasicListUI extends ListUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- list.setForeground(defaults.getColor("List.foreground"));
- list.setBackground(defaults.getColor("List.background"));
- list.setSelectionForeground(defaults.getColor("List.selectionForeground"));
- list.setSelectionBackground(defaults.getColor("List.selectionBackground"));
+ LookAndFeel.installColorsAndFont(list, "List.background",
+ "List.foreground", "List.font");
+ list.setSelectionForeground(UIManager.getColor("List.selectionForeground"));
+ list.setSelectionBackground(UIManager.getColor("List.selectionBackground"));
list.setOpaque(true);
}
@@ -742,14 +893,28 @@ public class BasicListUI extends ListUI
*/
protected void installListeners()
{
+ if (focusListener == null)
+ focusListener = createFocusListener();
list.addFocusListener(focusListener);
+ if (listDataListener == null)
+ listDataListener = createListDataListener();
list.getModel().addListDataListener(listDataListener);
+ if (listSelectionListener == null)
+ listSelectionListener = createListSelectionListener();
list.addListSelectionListener(listSelectionListener);
+ if (mouseInputListener == null)
+ mouseInputListener = createMouseInputListener();
list.addMouseListener(mouseInputListener);
- list.addKeyListener(keyListener);
list.addMouseMotionListener(mouseInputListener);
+ if (propertyChangeListener == null)
+ propertyChangeListener = createPropertyChangeListener();
list.addPropertyChangeListener(propertyChangeListener);
+
+ // FIXME: Are these two really needed? At least they are not documented.
+ //keyListener = new KeyHandler();
list.addComponentListener(componentListener);
+ componentListener = new ComponentHandler();
+ //list.addKeyListener(keyListener);
}
/**
@@ -761,16 +926,41 @@ public class BasicListUI extends ListUI
list.getModel().removeListDataListener(listDataListener);
list.removeListSelectionListener(listSelectionListener);
list.removeMouseListener(mouseInputListener);
- list.removeKeyListener(keyListener);
+ //list.removeKeyListener(keyListener);
list.removeMouseMotionListener(mouseInputListener);
list.removePropertyChangeListener(propertyChangeListener);
}
-
+
/**
* Installs keyboard actions for this UI in the {@link JList}.
*/
protected void installKeyboardActions()
{
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ InputMap focusInputMap = (InputMap)defaults.get("List.focusInputMap");
+ InputMapUIResource parentInputMap = new InputMapUIResource();
+ // FIXME: The JDK uses a LazyActionMap for parentActionMap
+ ActionMap parentActionMap = new ActionMap();
+ action = new ListAction();
+ Object keys[] = focusInputMap.allKeys();
+ // Register key bindings in the UI InputMap-ActionMap pair
+ for (int i = 0; i < keys.length; i++)
+ {
+ KeyStroke stroke = (KeyStroke)keys[i];
+ String actionString = (String) focusInputMap.get(stroke);
+ parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(),
+ stroke.getModifiers()),
+ actionString);
+
+ parentActionMap.put (actionString,
+ new ActionListenerProxy(action, actionString));
+ }
+ // Register the new InputMap-ActionMap as the parents of the list's
+ // InputMap and ActionMap
+ parentInputMap.setParent(list.getInputMap().getParent());
+ parentActionMap.setParent(list.getActionMap().getParent());
+ list.getInputMap().setParent(parentInputMap);
+ list.getActionMap().setParent(parentActionMap);
}
/**
@@ -778,6 +968,7 @@ public class BasicListUI extends ListUI
*/
protected void uninstallKeyboardActions()
{
+ // TODO: Implement this properly.
}
/**
@@ -1045,4 +1236,82 @@ public class BasicListUI extends ListUI
}
return loc;
}
+
+ /**
+ * Creates and returns the focus listener for this UI.
+ *
+ * @return the focus listener for this UI
+ */
+ protected FocusListener createFocusListener()
+ {
+ return new FocusHandler();
+ }
+
+ /**
+ * Creates and returns the list data listener for this UI.
+ *
+ * @return the list data listener for this UI
+ */
+ protected ListDataListener createListDataListener()
+ {
+ return new ListDataHandler();
+ }
+
+ /**
+ * Creates and returns the list selection listener for this UI.
+ *
+ * @return the list selection listener for this UI
+ */
+ protected ListSelectionListener createListSelectionListener()
+ {
+ return new ListSelectionHandler();
+ }
+
+ /**
+ * Creates and returns the mouse input listener for this UI.
+ *
+ * @return the mouse input listener for this UI
+ */
+ protected MouseInputListener createMouseInputListener()
+ {
+ return new MouseInputHandler();
+ }
+
+ /**
+ * Creates and returns the property change listener for this UI.
+ *
+ * @return the property change listener for this UI
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * Selects the next list item and force it to be visible.
+ */
+ protected void selectNextIndex()
+ {
+ int index = list.getSelectionModel().getLeadSelectionIndex();
+ if (index < list.getModel().getSize() - 1)
+ {
+ index++;
+ list.setSelectedIndex(index);
+ }
+ list.ensureIndexIsVisible(index);
+ }
+
+ /**
+ * Selects the previous list item and force it to be visible.
+ */
+ protected void selectPreviousIndex()
+ {
+ int index = list.getSelectionModel().getLeadSelectionIndex();
+ if (index > 0)
+ {
+ index--;
+ list.setSelectedIndex(index);
+ }
+ list.ensureIndexIsVisible(index);
+ }
}
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index 0c21d4256..64a9b2d08 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -273,7 +273,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Button.foreground", new ColorUIResource(Color.BLACK),
"Button.highlight", new ColorUIResource(Color.WHITE),
"Button.light", new ColorUIResource(Color.LIGHT_GRAY),
- "Button.margin", new InsetsUIResource(2, 2, 2, 2),
+ "Button.margin", new InsetsUIResource(2, 14, 2, 14),
"Button.shadow", new ColorUIResource(Color.GRAY),
"Button.textIconGap", new Integer(4),
"Button.textShiftOffset", new Integer(0),
@@ -364,7 +364,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"ComboBox.background", new ColorUIResource(Color.white),
"ComboBox.buttonBackground", new ColorUIResource(light),
- "ComboBox.buttonDarkShadow", new ColorUIResource(shadow),
+ "ComboBox.buttonDarkShadow", new ColorUIResource(darkShadow),
"ComboBox.buttonHighlight", new ColorUIResource(highLight),
"ComboBox.buttonShadow", new ColorUIResource(shadow),
"ComboBox.disabledBackground", new ColorUIResource(light),
@@ -467,6 +467,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"FocusManagerClassName", "TODO",
"FormattedTextField.background", new ColorUIResource(light),
"FormattedTextField.caretForeground", new ColorUIResource(Color.black),
+ "FormattedTextField.font",
+ new FontUIResource("SansSerif", Font.PLAIN, 12),
"FormattedTextField.foreground", new ColorUIResource(Color.black),
"FormattedTextField.inactiveBackground", new ColorUIResource(light),
"FormattedTextField.inactiveForeground", new ColorUIResource(Color.gray),
@@ -532,25 +534,69 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"List.background", new ColorUIResource(Color.white),
"List.border", new BasicBorders.MarginBorder(),
"List.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
- "PAGE_UP", "scrollUp",
- "ctrl \\", "clearSelection",
- "PAGE_DOWN", "scrollDown",
- "shift PAGE_DOWN","scrollDownExtendSelection",
+ "ctrl DOWN", "selectNextRowChangeLead",
+ "shift UP", "selectPreviousRowExtendSelection",
+ "ctrl RIGHT", "selectNextColumnChangeLead",
+ "shift ctrl LEFT", "selectPreviousColumnExtendSelection",
+ "shift KP_UP", "selectPreviousRowChangeLead",
+ "DOWN", "selectNextRow",
+ "ctrl UP", "selectPreviousRowChangeLead",
+ "ctrl LEFT", "selectPreviousColumnChangeLead",
+ "CUT", "cut",
"END", "selectLastRow",
- "HOME", "selectFirstRow",
- "shift END", "selectLastRowExtendSelection",
+ "shift PAGE_UP","scrollUpExtendSelection",
+ "KP_UP", "selectPreviousRow",
+ "shift ctrl UP", "selectPreviousRowExtendSelection",
+ "ctrl HOME", "selectFirstRowChangeLead",
+ "shift LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl END", "selectLastRowChangeLead",
+ "ctrl PAGE_DOWN", "scrollDownChangeLead",
+ "shift ctrl RIGHT", "selectNextColumnExtendSelection",
+ "LEFT", "selectPreviousColumn",
+ "ctrl PAGE_UP", "scrollUpChangeLead",
+ "KP_LEFT", "selectPreviousColumn",
+ "shift KP_RIGHT", "selectNextColumnExtendSelection",
+ "SPACE", "addToSelection",
+ "ctrl SPACE", "toggleAndAnchor",
+ "shift SPACE", "extendTo",
+ "shift ctrl SPACE", "moveSelectionTo",
+ "shift ctrl DOWN", "selectNextRowExtendSelection",
+ "ctrl BACK_SLASH", "clearSelection",
"shift HOME", "selectFirstRowExtendSelection",
- "UP", "selectPreviousRow",
- "ctrl /", "selectAll",
- "ctrl A", "selectAll",
- "DOWN", "selectNextRow",
- "shift UP", "selectPreviousRowExtendSelection",
- "ctrl SPACE", "selectNextRowExtendSelection",
+ "RIGHT", "selectNextColumn",
+ "shift ctrl PAGE_UP", "scrollUpExtendSelection",
"shift DOWN", "selectNextRowExtendSelection",
- "KP_UP", "selectPreviousRow",
- "shift PAGE_UP","scrollUpExtendSelection",
- "KP_DOWN", "selectNextRow"
+ "PAGE_DOWN", "scrollDown",
+ "shift ctrl KP_UP", "selectPreviousRowExtendSelection",
+ "shift KP_LEFT", "selectPreviousColumnExtendSelection",
+ "ctrl X", "cut",
+ "shift ctrl PAGE_DOWN", "scrollDownExtendSelection",
+ "ctrl SLASH", "selectAll",
+ "ctrl C", "copy",
+ "ctrl KP_RIGHT", "selectNextColumnChangeLead",
+ "shift END", "selectLastRowExtendSelection",
+ "shift ctrl KP_DOWN", "selectNextRowExtendSelection",
+ "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
+ "HOME", "selectFirstRow",
+ "ctrl V", "paste",
+ "KP_DOWN", "selectNextRow",
+ "ctrl KP_DOWN", "selectNextRowChangeLead",
+ "shift RIGHT", "selectNextColumnExtendSelection",
+ "ctrl A", "selectAll",
+ "shift ctrl END", "selectLastRowExtendSelection",
+ "COPY", "copy",
+ "ctrl KP_UP", "selectPreviousRowChangeLead",
+ "shift ctrl KP_LEFT", "selectPreviousColumnExtendSelection",
+ "shift KP_DOWN", "selectNextRowExtendSelection",
+ "UP", "selectPreviousRow",
+ "shift ctrl HOME", "selectFirstRowExtendSelection",
+ "shift PAGE_DOWN", "scrollDownExtendSelection",
+ "KP_RIGHT", "selectNextColumn",
+ "shift ctrl KP_RIGHT", "selectNextColumnExtendSelection",
+ "PAGE_UP", "scrollUp",
+ "PASTE", "paste"
}),
+ "List.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"List.foreground", new ColorUIResource(Color.black),
"List.selectionBackground", new ColorUIResource(0, 0, 128),
"List.selectionForeground", new ColorUIResource(Color.white),
@@ -602,7 +648,6 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"MenuItem.background", new ColorUIResource(light),
"MenuItem.border", new BasicBorders.MarginBorder(),
"MenuItem.borderPainted", Boolean.FALSE,
- "MenuItem.checkIcon", BasicIconFactory.getMenuItemCheckIcon(),
"MenuItem.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"MenuItem.foreground", new ColorUIResource(darkShadow),
"MenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
@@ -625,7 +670,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"OptionPane.messageAreaBorder",
new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0),
"OptionPane.messageForeground", new ColorUIResource(darkShadow),
- "OptionPane.minimumSize", new DimensionUIResource(262, 90),
+ "OptionPane.minimumSize",
+ new DimensionUIResource(BasicOptionPaneUI.MinimumWidth,
+ BasicOptionPaneUI.MinimumHeight),
"OptionPane.noButtonText", "No",
"OptionPane.okButtonText", "OK",
// XXX Don't use gif
@@ -848,6 +895,24 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"TabbedPane.tabRunOverlay", new Integer(2),
"TabbedPane.textIconGap", new Integer(4),
"Table.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
+ "ctrl DOWN", "selectNextRowChangeLead",
+ "ctrl RIGHT", "selectNextColumnChangeLead",
+ "ctrl UP", "selectPreviousRowChangeLead",
+ "ctrl LEFT", "selectPreviousColumnChangeLead",
+ "CUT", "cut",
+ "SPACE", "addToSelection",
+ "ctrl SPACE", "toggleAndAnchor",
+ "shift SPACE", "extendTo",
+ "shift ctrl SPACE", "moveSelectionTo",
+ "ctrl X", "cut",
+ "ctrl C", "copy",
+ "ctrl KP_RIGHT", "selectNextColumnChangeLead",
+ "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
+ "ctrl V", "paste",
+ "ctrl KP_DOWN", "selectNextRowChangeLead",
+ "COPY", "copy",
+ "ctrl KP_UP", "selectPreviousRowChangeLead",
+ "PASTE", "paste",
"shift PAGE_DOWN","scrollDownExtendSelection",
"PAGE_DOWN", "scrollDownChangeSelection",
"END", "selectLastColumn",
@@ -898,22 +963,22 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ctrl SLASH", "selectAll",
"ctrl shift KP_DOWN", "selectNextRowExtendSelection",
}),
- "Table.background", new ColorUIResource(light),
- "Table.focusCellBackground", new ColorUIResource(light),
- "Table.focusCellForeground", new ColorUIResource(darkShadow),
+ "Table.background", new ColorUIResource(new ColorUIResource(255, 255, 255)),
+ "Table.focusCellBackground", new ColorUIResource(new ColorUIResource(255, 255, 255)),
+ "Table.focusCellForeground", new ColorUIResource(new ColorUIResource(0, 0, 0)),
"Table.focusCellHighlightBorder",
new BorderUIResource.LineBorderUIResource(
new ColorUIResource(255, 255, 0)),
"Table.font", new FontUIResource("Dialog", Font.PLAIN, 12),
- "Table.foreground", new ColorUIResource(darkShadow),
- "Table.gridColor", new ColorUIResource(Color.gray),
+ "Table.foreground", new ColorUIResource(new ColorUIResource(0, 0, 0)),
+ "Table.gridColor", new ColorUIResource(new ColorUIResource(128, 128, 128)),
"Table.scrollPaneBorder", new BorderUIResource.BevelBorderUIResource(0),
- "Table.selectionBackground", new ColorUIResource(Color.black),
- "Table.selectionForeground", new ColorUIResource(Color.white),
- "TableHeader.background", new ColorUIResource(light),
+ "Table.selectionBackground", new ColorUIResource(new ColorUIResource(0, 0, 128)),
+ "Table.selectionForeground", new ColorUIResource(new ColorUIResource(255, 255, 255)),
+ "TableHeader.background", new ColorUIResource(new ColorUIResource(192, 192, 192)),
"TableHeader.cellBorder", new BorderUIResource.BevelBorderUIResource(0),
"TableHeader.font", new FontUIResource("Dialog", Font.PLAIN, 12),
- "TableHeader.foreground", new ColorUIResource(darkShadow),
+ "TableHeader.foreground", new ColorUIResource(new ColorUIResource(0, 0, 0)),
"TextArea.background", new ColorUIResource(light),
"TextArea.border",
@@ -1040,7 +1105,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Tree.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
"ESCAPE", "cancel"
}),
- "Tree.background", new ColorUIResource(light),
+ "Tree.background", new ColorUIResource(new Color(255, 255, 255)),
"Tree.changeSelectionWithFocus", Boolean.TRUE,
// "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.png")),
// "Tree.collapsedIcon", new IconUIResource(new ImageIcon("icons/TreeCollapsed.png")),
@@ -1090,20 +1155,20 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"PAGE_UP", "scrollUpChangeSelection",
"ctrl PAGE_DOWN", "scrollDownChangeLead"
}),
- "Tree.font", new FontUIResource(new Font("Helvetica", Font.PLAIN, 12)),
+ "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"Tree.foreground", new ColorUIResource(Color.black),
"Tree.hash", new ColorUIResource(new Color(128, 128, 128)),
"Tree.leftChildIndent", new Integer(7),
"Tree.rightChildIndent", new Integer(13),
- "Tree.rowHeight", new Integer(20), // FIXME
+ "Tree.rowHeight", new Integer(16),
"Tree.scrollsOnExpand", Boolean.TRUE,
"Tree.selectionBackground", new ColorUIResource(Color.black),
- "Tree.nonSelectionBackground", new ColorUIResource(new Color(239, 235, 231)),
+ "Tree.nonSelectionBackground", new ColorUIResource(new Color(255, 255, 255)),
"Tree.selectionBorderColor", new ColorUIResource(Color.black),
"Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(Color.black),
"Tree.selectionForeground", new ColorUIResource(new Color(255, 255, 255)),
- "Tree.textBackground", new ColorUIResource(new Color(255, 255, 255)),
- "Tree.textForeground", new ColorUIResource(Color.black),
+ "Tree.textBackground", new ColorUIResource(new Color(192, 192, 192)),
+ "Tree.textForeground", new ColorUIResource(new Color(0, 0, 0)),
"Viewport.background", new ColorUIResource(light),
"Viewport.foreground", new ColorUIResource(Color.black),
"Viewport.font", new FontUIResource("Dialog", Font.PLAIN, 12)
diff --git a/javax/swing/plaf/basic/BasicMenuBarUI.java b/javax/swing/plaf/basic/BasicMenuBarUI.java
index 6b9cad89c..daa9b0d6b 100644
--- a/javax/swing/plaf/basic/BasicMenuBarUI.java
+++ b/javax/swing/plaf/basic/BasicMenuBarUI.java
@@ -38,9 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
@@ -50,10 +47,10 @@ import java.beans.PropertyChangeListener;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
+import javax.swing.JMenu;
import javax.swing.JMenuBar;
+import javax.swing.LookAndFeel;
import javax.swing.MenuElement;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MouseInputListener;
@@ -169,12 +166,9 @@ public class BasicMenuBarUI extends MenuBarUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- menuBar.setBackground(defaults.getColor("MenuBar.background"));
- menuBar.setBorder(defaults.getBorder("MenuBar.border"));
- menuBar.setFont(defaults.getFont("MenuBar.font"));
- menuBar.setForeground(defaults.getColor("MenuBar.foreground"));
+ LookAndFeel.installBorder(menuBar, "MenuBar.border");
+ LookAndFeel.installColorsAndFont(menuBar, "MenuBar.background",
+ "MenuBar.foreground", "MenuBar.font");
menuBar.setOpaque(true);
}
@@ -262,6 +256,7 @@ public class BasicMenuBarUI extends MenuBarUI
{
public void stateChanged(ChangeEvent event)
{
+ // TODO: What should be done here, if anything?
}
}
@@ -326,7 +321,11 @@ public class BasicMenuBarUI extends MenuBarUI
MenuElement[] me = menuBar.getSubElements();
for (int i = 0; i < me.length; i++)
- menuBar.getMenu(i).setSelected(false);
+ {
+ JMenu menu = menuBar.getMenu(i);
+ if (menu != null)
+ menu.setSelected(false);
+ }
}
/**
@@ -336,6 +335,7 @@ public class BasicMenuBarUI extends MenuBarUI
*/
public void mousePressed(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -345,6 +345,7 @@ public class BasicMenuBarUI extends MenuBarUI
*/
public void mouseReleased(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -354,6 +355,7 @@ public class BasicMenuBarUI extends MenuBarUI
*/
public void mouseExited(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -363,6 +365,7 @@ public class BasicMenuBarUI extends MenuBarUI
*/
public void mouseDragged(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -372,6 +375,7 @@ public class BasicMenuBarUI extends MenuBarUI
*/
public void mouseMoved(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -381,6 +385,7 @@ public class BasicMenuBarUI extends MenuBarUI
*/
public void mouseEntered(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
}
}
diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java
index 488844336..f8f577a76 100644
--- a/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -48,16 +48,19 @@ import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.util.ArrayList;
+import javax.swing.ButtonModel;
import javax.swing.Icon;
+import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingConstants;
@@ -109,7 +112,7 @@ public class BasicMenuItemUI extends MenuItemUI
* Number of spaces between icon and text.
*/
protected int defaultTextIconGap = 4;
-
+
/**
* Color of the text when menu item is disabled
*/
@@ -156,16 +159,21 @@ public class BasicMenuItemUI extends MenuItemUI
private String acceleratorDelimiter;
/**
- * PropertyChangeListener to listen for property changes in the menu item
+ * ItemListener to listen for item changes in the menu item
*/
- private PropertyChangeListener propertyChangeListener;
+ private ItemListener itemListener;
/**
* Number of spaces between accelerator and menu item's label.
*/
- private int defaultAcceleratorLabelGap = 4;
+ private int defaultAcceleratorLabelGap = 10;
/**
+ * Number of spaces between the text and the arrow icon.
+ */
+ private int defaultTextArrowIconGap = 10;
+
+ /**
* Creates a new BasicMenuItemUI object.
*/
public BasicMenuItemUI()
@@ -173,7 +181,7 @@ public class BasicMenuItemUI extends MenuItemUI
mouseInputListener = createMouseInputListener(menuItem);
menuDragMouseListener = createMenuDragMouseListener(menuItem);
menuKeyListener = createMenuKeyListener(menuItem);
- propertyChangeListener = new PropertyChangeHandler();
+ itemListener = new ItemHandler();
}
/**
@@ -325,7 +333,7 @@ public class BasicMenuItemUI extends MenuItemUI
m.getToolkit().getFontMetrics(acceleratorFont));
// add width of accelerator's text
- d.width = d.width + rect.width + defaultAcceleratorLabelGap;
+ d.width += rect.width + defaultAcceleratorLabelGap;
// adjust the heigth of the preferred size if necessary
if (d.height < rect.height)
@@ -342,7 +350,7 @@ public class BasicMenuItemUI extends MenuItemUI
if (arrowIcon != null && (c instanceof JMenu))
{
- d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap;
+ d.width = d.width + arrowIcon.getIconWidth() + defaultTextArrowIconGap;
if (arrowIcon.getIconHeight() > d.height)
d.height = arrowIcon.getIconHeight();
@@ -390,23 +398,22 @@ public class BasicMenuItemUI extends MenuItemUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- menuItem.setBackground(defaults.getColor("MenuItem.background"));
- menuItem.setBorder(defaults.getBorder("MenuItem.border"));
- menuItem.setFont(defaults.getFont("MenuItem.font"));
- menuItem.setForeground(defaults.getColor("MenuItem.foreground"));
- menuItem.setMargin(defaults.getInsets("MenuItem.margin"));
- menuItem.setOpaque(true);
- acceleratorFont = defaults.getFont("MenuItem.acceleratorFont");
- acceleratorForeground = defaults.getColor("MenuItem.acceleratorForeground");
- acceleratorSelectionForeground = defaults.getColor("MenuItem.acceleratorSelectionForeground");
- selectionBackground = defaults.getColor("MenuItem.selectionBackground");
- selectionForeground = defaults.getColor("MenuItem.selectionForeground");
- acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter");
-
+ String prefix = getPropertyPrefix();
+ LookAndFeel.installBorder(menuItem, prefix + ".border");
+ LookAndFeel.installColorsAndFont(menuItem, prefix + ".background",
+ prefix + ".foreground", prefix + ".font");
+ menuItem.setMargin(UIManager.getInsets(prefix + ".margin"));
+ acceleratorFont = UIManager.getFont(prefix + ".acceleratorFont");
+ acceleratorForeground = UIManager.getColor(prefix + ".acceleratorForeground");
+ acceleratorSelectionForeground = UIManager.getColor(prefix + ".acceleratorSelectionForeground");
+ selectionBackground = UIManager.getColor(prefix + ".selectionBackground");
+ selectionForeground = UIManager.getColor(prefix + ".selectionForeground");
+ acceleratorDelimiter = UIManager.getString(prefix + ".acceleratorDelimiter");
+ checkIcon = UIManager.getIcon(prefix + ".checkIcon");
+
menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
menuItem.setHorizontalAlignment(SwingConstants.LEADING);
+ menuItem.setOpaque(true);
}
/**
@@ -426,7 +433,7 @@ public class BasicMenuItemUI extends MenuItemUI
menuItem.addMouseMotionListener(mouseInputListener);
menuItem.addMenuDragMouseListener(menuDragMouseListener);
menuItem.addMenuKeyListener(menuKeyListener);
- menuItem.addPropertyChangeListener(propertyChangeListener);
+ menuItem.addItemListener(itemListener);
}
/**
@@ -533,7 +540,9 @@ public class BasicMenuItemUI extends MenuItemUI
// Menu item is considered to be highlighted when it is selected.
// But we don't want to paint the background of JCheckBoxMenuItems
- if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed()
+ ButtonModel mod = m.getModel();
+ if ((m.isSelected() && checkIcon == null) || (mod != null &&
+ mod.isArmed())
&& (m.getParent() instanceof MenuElement))
{
if (m.isContentAreaFilled())
@@ -572,9 +581,8 @@ public class BasicMenuItemUI extends MenuItemUI
{
int width = arrowIcon.getIconWidth();
int height = arrowIcon.getIconHeight();
-
- arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap,
- vr.y + 2);
+ int offset = (vr.height - height) / 2;
+ arrowIcon.paintIcon(m, g, vr.width - width, vr.y + offset);
}
}
@@ -633,8 +641,9 @@ public class BasicMenuItemUI extends MenuItemUI
{
// Menu item is considered to be highlighted when it is selected.
// But not if it's a JCheckBoxMenuItem
+ ButtonModel mod = menuItem.getModel();
if ((menuItem.isSelected() && checkIcon == null)
- || menuItem.getModel().isArmed()
+ || (mod != null && mod.isArmed())
&& (menuItem.getParent() instanceof MenuElement))
g.setColor(selectionForeground);
else
@@ -712,7 +721,7 @@ public class BasicMenuItemUI extends MenuItemUI
menuItem.removeMouseListener(mouseInputListener);
menuItem.removeMenuDragMouseListener(menuDragMouseListener);
menuItem.removeMenuKeyListener(menuKeyListener);
- menuItem.removePropertyChangeListener(propertyChangeListener);
+ menuItem.removeItemListener(itemListener);
}
/**
@@ -828,6 +837,7 @@ public class BasicMenuItemUI extends MenuItemUI
*/
protected MouseInputHandler()
{
+ // Nothing to do here.
}
/**
@@ -942,7 +952,7 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* This class handles mouse dragged events.
*/
- protected class MenuDragMouseHandler implements MenuDragMouseListener
+ private class MenuDragMouseHandler implements MenuDragMouseListener
{
/**
* Tbis method is invoked when mouse is dragged over the menu item.
@@ -973,11 +983,11 @@ public class BasicMenuItemUI extends MenuItemUI
* Tbis method is invoked when mouse exits the menu item while it is being
* dragged
*
- * @param e
- * The MenuDragMouseEvent
+ * @param e the MenuDragMouseEvent
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -1003,7 +1013,7 @@ public class BasicMenuItemUI extends MenuItemUI
* This class handles key events occuring when menu item is visible on the
* screen.
*/
- protected class MenuKeyHandler implements MenuKeyListener
+ private class MenuKeyHandler implements MenuKeyListener
{
/**
* This method is invoked when key has been pressed
@@ -1013,6 +1023,7 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuKeyPressed(MenuKeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -1023,6 +1034,7 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuKeyReleased(MenuKeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -1034,22 +1046,30 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuKeyTyped(MenuKeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
}
-
+
/**
- * Helper class that listens for changes to the properties of the {@link
+ * Helper class that listens for item changes to the properties of the {@link
* JMenuItem}.
*/
- protected class PropertyChangeHandler implements PropertyChangeListener
+ private class ItemHandler implements ItemListener
{
/**
- * This method is called when one of the menu item's properties change.
+ * This method is called when one of the menu item changes.
*
- * @param evt A {@link PropertyChangeEvent}.
+ * @param evt A {@link ItemEvent}.
*/
- public void propertyChange(PropertyChangeEvent evt)
+ public void itemStateChanged(ItemEvent evt)
{
+ boolean state = false;
+ if (menuItem instanceof JCheckBoxMenuItem)
+ {
+ if (evt.getStateChange() == ItemEvent.SELECTED)
+ state = true;
+ ((JCheckBoxMenuItem) menuItem).setState(state);
+ }
menuItem.revalidate();
menuItem.repaint();
}
diff --git a/javax/swing/plaf/basic/BasicMenuUI.java b/javax/swing/plaf/basic/BasicMenuUI.java
index 30be592ee..827cbb0f5 100644
--- a/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/javax/swing/plaf/basic/BasicMenuUI.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
@@ -46,8 +47,8 @@ import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import javax.swing.LookAndFeel;
import javax.swing.MenuSelectionManager;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -92,7 +93,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
protected ChangeListener createChangeListener(JComponent c)
{
- return new ChangeHandler();
+ return new ChangeHandler((JMenu) c, this);
}
/**
@@ -180,12 +181,6 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public Dimension getMaximumSize(JComponent c)
{
- // If this menu is in a popup menu, treat it like a regular JMenuItem
- if (!((JMenu)c).isTopLevelMenu())
- {
- JMenuItem menuItem = new JMenuItem(((JMenu)c).getText(), ((JMenu)c).getIcon());
- return menuItem.getMaximumSize();
- }
return c.getPreferredSize();
}
@@ -205,20 +200,17 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- menuItem.setBackground(defaults.getColor("Menu.background"));
- menuItem.setBorder(defaults.getBorder("Menu.border"));
- menuItem.setFont(defaults.getFont("Menu.font"));
- menuItem.setForeground(defaults.getColor("Menu.foreground"));
- menuItem.setMargin(defaults.getInsets("Menu.margin"));
- acceleratorFont = defaults.getFont("Menu.acceleratorFont");
- acceleratorForeground = defaults.getColor("Menu.acceleratorForeground");
- acceleratorSelectionForeground = defaults.getColor("Menu.acceleratorSelectionForeground");
- selectionBackground = defaults.getColor("Menu.selectionBackground");
- selectionForeground = defaults.getColor("Menu.selectionForeground");
- arrowIcon = defaults.getIcon("Menu.arrowIcon");
- oldBorderPainted = defaults.getBoolean("Menu.borderPainted");
+ LookAndFeel.installBorder(menuItem, "Menu.border");
+ LookAndFeel.installColorsAndFont(menuItem, "Menu.background",
+ "Menu.foreground", "Menu.font");
+ menuItem.setMargin(UIManager.getInsets("Menu.margin"));
+ acceleratorFont = UIManager.getFont("Menu.acceleratorFont");
+ acceleratorForeground = UIManager.getColor("Menu.acceleratorForeground");
+ acceleratorSelectionForeground = UIManager.getColor("Menu.acceleratorSelectionForeground");
+ selectionBackground = UIManager.getColor("Menu.selectionBackground");
+ selectionForeground = UIManager.getColor("Menu.selectionForeground");
+ arrowIcon = UIManager.getIcon("Menu.arrowIcon");
+ oldBorderPainted = UIManager.getBoolean("Menu.borderPainted");
menuItem.setOpaque(true);
}
@@ -245,6 +237,7 @@ public class BasicMenuUI extends BasicMenuItemUI
protected void setupPostTimer(JMenu menu)
{
+ // TODO: Implement this properly.
}
/**
@@ -356,6 +349,7 @@ public class BasicMenuUI extends BasicMenuItemUI
public void mouseMoved(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
public void mousePressed(MouseEvent e)
@@ -421,10 +415,13 @@ public class BasicMenuUI extends BasicMenuItemUI
public void menuDeselected(MenuEvent e)
{
JMenu menu = (JMenu) menuItem;
- if (menu.isTopLevelMenu())
- ((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
- else
- ((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
+ if (menu.getParent() != null)
+ {
+ if (menu.isTopLevelMenu())
+ ((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
+ else
+ ((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
+ }
}
/**
@@ -456,6 +453,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void propertyChange(PropertyChangeEvent e)
{
+ // TODO: Implement this properly.
}
}
@@ -464,9 +462,40 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public class ChangeHandler implements ChangeListener
{
+ /**
+ * Not used.
+ */
+ public boolean isSelected;
+
+ /**
+ * Not used.
+ */
+ public JMenu menu;
+
+ /**
+ * Not used.
+ */
+ public BasicMenuUI ui;
+
+ /**
+ * Not used.
+ */
+ public Component wasFocused;
+
+ /**
+ * Not used.
+ */
+ public ChangeHandler(JMenu m, BasicMenuUI ui)
+ {
+ // Not used.
+ }
+
+ /**
+ * Not used.
+ */
public void stateChanged(ChangeEvent e)
{
- // FIXME: It seems that this class is not used anywhere
+ // Not used.
}
}
@@ -506,6 +535,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -516,6 +546,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
}
@@ -532,6 +563,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuKeyPressed(MenuKeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -541,6 +573,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuKeyReleased(MenuKeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -551,6 +584,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public void menuKeyTyped(MenuKeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
}
}
diff --git a/javax/swing/plaf/basic/BasicOptionPaneUI.java b/javax/swing/plaf/basic/BasicOptionPaneUI.java
index aa648d74d..6b37d315f 100644
--- a/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -70,8 +70,8 @@ import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
@@ -141,13 +141,14 @@ public class BasicOptionPaneUI extends OptionPaneUI
optionPane);
if (inf != null)
{
- try
- {
- inf.setClosed(true);
- }
- catch (PropertyVetoException pve)
- {
- }
+ try
+ {
+ inf.setClosed(true);
+ }
+ catch (PropertyVetoException pve)
+ {
+ // We do nothing if attempt has been vetoed.
+ }
}
}
}
@@ -405,16 +406,30 @@ public class BasicOptionPaneUI extends OptionPaneUI
|| e.getPropertyName().equals(JOptionPane.WANTS_INPUT_PROPERTY)
|| e.getPropertyName().equals(JOptionPane.SELECTION_VALUES_PROPERTY))
{
- optionPane.removeAll();
- messageAreaContainer = createMessageArea();
- optionPane.add(messageAreaContainer);
- optionPane.add(buttonContainer);
+ optionPane.remove(messageAreaContainer);
+ messageAreaContainer = createMessageArea();
+ optionPane.add(messageAreaContainer);
+ Container newButtons = createButtonArea();
+ optionPane.remove(buttonContainer);
+ optionPane.add(newButtons);
+ buttonContainer = newButtons;
+ optionPane.add(buttonContainer);
}
optionPane.invalidate();
optionPane.repaint();
}
}
+ /**
+ * The minimum width for JOptionPanes.
+ */
+ public static final int MinimumWidth = 262;
+
+ /**
+ * The minimum height for JOptionPanes.
+ */
+ public static final int MinimumHeight = 90;
+
/** Whether the JOptionPane contains custom components. */
protected boolean hasCustomComponents = false;
@@ -433,12 +448,6 @@ public class BasicOptionPaneUI extends OptionPaneUI
/** The component that receives input when the JOptionPane needs it. */
protected JComponent inputComponent;
- /** The minimum height of the JOptionPane. */
- public static int minimumHeight;
-
- /** The minimum width of the JOptionPane. */
- public static int minimumWidth;
-
/** The minimum dimensions of the JOptionPane. */
protected Dimension minimumSize;
@@ -518,6 +527,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ // Nothing to do here.
}
}
@@ -637,6 +647,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
public BasicOptionPaneUI()
{
+ // Nothing to do here.
}
/**
@@ -941,11 +952,17 @@ public class BasicOptionPaneUI extends OptionPaneUI
{
case JOptionPane.YES_NO_OPTION:
return new Object[] { YES_STRING, NO_STRING };
- case JOptionPane.DEFAULT_OPTION:
case JOptionPane.YES_NO_CANCEL_OPTION:
return new Object[] { YES_STRING, NO_STRING, CANCEL_STRING };
case JOptionPane.OK_CANCEL_OPTION:
return new Object[] { OK_STRING, CANCEL_STRING };
+ case JOptionPane.DEFAULT_OPTION:
+ return (optionPane.getWantsInput() ) ?
+ new Object[] { OK_STRING, CANCEL_STRING } :
+ ( optionPane.getMessageType() == JOptionPane.QUESTION_MESSAGE ) ?
+ new Object[] { YES_STRING, NO_STRING, CANCEL_STRING } :
+ // ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, PLAIN_MESSAGE
+ new Object[] { OK_STRING };
}
return null;
}
@@ -1142,21 +1159,17 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- optionPane.setFont(defaults.getFont("OptionPane.font"));
- optionPane.setBackground(defaults.getColor("OptionPane.background"));
- optionPane.setForeground(defaults.getColor("OptionPane.foreground"));
- optionPane.setBorder(defaults.getBorder("OptionPane.border"));
+ LookAndFeel.installColorsAndFont(optionPane, "OptionPane.background",
+ "OptionPane.foreground",
+ "OptionPane.font");
+ LookAndFeel.installBorder(optionPane, "OptionPane.border");
optionPane.setOpaque(true);
- messageBorder = defaults.getBorder("OptionPane.messageAreaBorder");
- messageForeground = defaults.getColor("OptionPane.messageForeground");
- buttonBorder = defaults.getBorder("OptionPane.buttonAreaBorder");
+ messageBorder = UIManager.getBorder("OptionPane.messageAreaBorder");
+ messageForeground = UIManager.getColor("OptionPane.messageForeground");
+ buttonBorder = UIManager.getBorder("OptionPane.buttonAreaBorder");
- minimumSize = defaults.getDimension("OptionPane.minimumSize");
- minimumWidth = minimumSize.width;
- minimumHeight = minimumSize.height;
+ minimumSize = UIManager.getDimension("OptionPane.minimumSize");
// FIXME: Image icons don't seem to work properly right now.
// Once they do, replace the synthetic icons with these ones.
diff --git a/javax/swing/plaf/basic/BasicPanelUI.java b/javax/swing/plaf/basic/BasicPanelUI.java
index b715c57b3..783cec473 100644
--- a/javax/swing/plaf/basic/BasicPanelUI.java
+++ b/javax/swing/plaf/basic/BasicPanelUI.java
@@ -40,8 +40,7 @@ package javax.swing.plaf.basic;
import javax.swing.JComponent;
import javax.swing.JPanel;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
+import javax.swing.LookAndFeel;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PanelUI;
@@ -64,8 +63,29 @@ public class BasicPanelUI extends PanelUI
public void installDefaults(JPanel p)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- p.setBackground(defaults.getColor("Panel.background"));
+ LookAndFeel.installColorsAndFont(p, "Panel.background", "Panel.foreground",
+ "Panel.font");
p.setOpaque(true);
}
+
+ /**
+ * Uninstalls this UI from the JPanel.
+ *
+ * @param c the JPanel from which to uninstall this UI
+ */
+ public void uninstallUI(JComponent c)
+ {
+ uninstallDefaults((JPanel) c);
+ }
+
+ /**
+ * Uninstalls the UI defaults that have been install through
+ * {@link #installDefaults}.
+ *
+ * @param p the panel from which to uninstall the UI defaults
+ */
+ protected void uninstallDefaults(JPanel p)
+ {
+ // Nothing to do here.
+ }
}
diff --git a/javax/swing/plaf/basic/BasicPasswordFieldUI.java b/javax/swing/plaf/basic/BasicPasswordFieldUI.java
index 089162ce3..76dcfc435 100644
--- a/javax/swing/plaf/basic/BasicPasswordFieldUI.java
+++ b/javax/swing/plaf/basic/BasicPasswordFieldUI.java
@@ -49,6 +49,7 @@ public class BasicPasswordFieldUI extends BasicTextFieldUI
{
public BasicPasswordFieldUI()
{
+ // Nothing to do here.
}
public View create(Element elem)
diff --git a/javax/swing/plaf/basic/BasicPopupMenuUI.java b/javax/swing/plaf/basic/BasicPopupMenuUI.java
index 247117bc9..46bcd3679 100644
--- a/javax/swing/plaf/basic/BasicPopupMenuUI.java
+++ b/javax/swing/plaf/basic/BasicPopupMenuUI.java
@@ -53,12 +53,11 @@ import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
+import javax.swing.LookAndFeel;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.RootPaneContainer;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
import javax.swing.event.MouseInputListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
@@ -131,12 +130,9 @@ public class BasicPopupMenuUI extends PopupMenuUI
*/
public void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- popupMenu.setBackground(defaults.getColor("PopupMenu.background"));
- popupMenu.setBorder(defaults.getBorder("PopupMenu.border"));
- popupMenu.setFont(defaults.getFont("PopupMenu.font"));
- popupMenu.setForeground(defaults.getColor("PopupMenu.foreground"));
+ LookAndFeel.installColorsAndFont(popupMenu, "PopupMenu.background",
+ "PopupMenu.foreground", "PopupMenu.font");
+ LookAndFeel.installBorder(popupMenu, "PopupMenu.border");
popupMenu.setOpaque(true);
}
diff --git a/javax/swing/plaf/basic/BasicProgressBarUI.java b/javax/swing/plaf/basic/BasicProgressBarUI.java
index d00628f53..744ddf712 100644
--- a/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -56,10 +56,10 @@ import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.JProgressBar;
+import javax.swing.LookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -712,21 +712,19 @@ public class BasicProgressBarUI extends ProgressBarUI
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- progressBar.setFont(defaults.getFont("ProgressBar.font"));
- progressBar.setForeground(defaults.getColor("ProgressBar.foreground"));
- progressBar.setBackground(defaults.getColor("ProgressBar.background"));
- progressBar.setBorder(defaults.getBorder("ProgressBar.border"));
+ LookAndFeel.installColorsAndFont(progressBar, "ProgressBar.background",
+ "ProgressBar.foreground",
+ "ProgressBar.font");
+ LookAndFeel.installBorder(progressBar, "ProgressBar.border");
progressBar.setOpaque(true);
- selectionForeground = defaults.getColor("ProgressBar.selectionForeground");
- selectionBackground = defaults.getColor("ProgressBar.selectionBackground");
- cellLength = defaults.getInt("ProgressBar.cellLength");
- cellSpacing = defaults.getInt("ProgressBar.cellSpacing");
+ selectionForeground = UIManager.getColor("ProgressBar.selectionForeground");
+ selectionBackground = UIManager.getColor("ProgressBar.selectionBackground");
+ cellLength = UIManager.getInt("ProgressBar.cellLength");
+ cellSpacing = UIManager.getInt("ProgressBar.cellSpacing");
- int repaintInterval = defaults.getInt("ProgressBar.repaintInterval");
- int cycleTime = defaults.getInt("ProgressBar.cycleTime");
+ int repaintInterval = UIManager.getInt("ProgressBar.repaintInterval");
+ int cycleTime = UIManager.getInt("ProgressBar.cycleTime");
if (cycleTime % repaintInterval != 0
&& (cycleTime / repaintInterval) % 2 != 0)
diff --git a/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java b/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
index fa74a008b..8af5ff7f9 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
@@ -59,8 +59,6 @@ public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
public BasicRadioButtonMenuItemUI()
{
super();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- checkIcon = defaults.getIcon("RadioButtonMenuItem.checkIcon");
}
/**
@@ -98,5 +96,7 @@ public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
MenuElement[] path,
MenuSelectionManager manager)
{
+ // TODO: May not be implemented properly.
+ item.processMouseEvent(e, path, manager);
}
}
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
index fbd21241a..f3698e859 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;
@@ -93,6 +95,10 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
b.setIcon(icon);
if (b.getSelectedIcon() == null)
b.setSelectedIcon(icon);
+ if (b.getDisabledIcon() == null)
+ b.setDisabledIcon(icon);
+ if (b.getDisabledSelectedIcon() == null)
+ b.setDisabledSelectedIcon(icon);
}
/**
@@ -139,10 +145,14 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
g.setFont(f);
Icon currentIcon = null;
- if (b.isSelected())
+ if (b.isSelected() && b.isEnabled())
currentIcon = b.getSelectedIcon();
- else
+ else if (!b.isSelected() && b.isEnabled())
currentIcon = b.getIcon();
+ else if (b.isSelected() && !b.isEnabled())
+ currentIcon = b.getDisabledSelectedIcon();
+ else // (!b.isSelected() && !b.isEnabled())
+ currentIcon = b.getDisabledIcon();
SwingUtilities.calculateInnerArea(b, vr);
String text = SwingUtilities.layoutCompoundLabel
@@ -157,6 +167,25 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
}
if (text != null)
paintText(g, b, tr, text);
- paintFocus(g, b, vr, tr, ir);
+ // TODO: Figure out what is the size parameter?
+ if (b.hasFocus() && b.isFocusPainted() && b.isEnabled())
+ paintFocus(g, tr, null);
+ }
+
+ /**
+ * Paints the focus indicator for JRadioButtons.
+ *
+ * @param g the graphics context
+ * @param tr the rectangle for the text label
+ * @param size the size (??)
+ */
+ // TODO: Figure out what for is the size parameter.
+ protected void paintFocus(Graphics g, Rectangle tr, Dimension size)
+ {
+ Color focusColor = UIManager.getColor(getPropertyPrefix() + ".focus");
+ Color saved = g.getColor();
+ g.setColor(focusColor);
+ g.drawRect(tr.x, tr.y, tr.width, tr.height);
+ g.setColor(saved);
}
}
diff --git a/javax/swing/plaf/basic/BasicRootPaneUI.java b/javax/swing/plaf/basic/BasicRootPaneUI.java
index d97f7baea..2a698e8a1 100644
--- a/javax/swing/plaf/basic/BasicRootPaneUI.java
+++ b/javax/swing/plaf/basic/BasicRootPaneUI.java
@@ -42,6 +42,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
+import javax.swing.JRootPane;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.RootPaneUI;
@@ -56,11 +57,127 @@ public class BasicRootPaneUI extends RootPaneUI
public void installUI(JComponent c)
{
- c.setBackground(UIManager.getColor("control"));
super.installUI(c);
+ if (c instanceof JRootPane)
+ {
+ JRootPane rp = (JRootPane) c;
+ installDefaults(rp);
+ installComponents(rp);
+ installListeners(rp);
+ installKeyboardActions(rp);
+ }
+ }
+
+ /**
+ * Installs the look and feel defaults for JRootPane.
+ *
+ * @param rp the root pane to install the defaults to
+ */
+ protected void installDefaults(JRootPane rp)
+ {
+ // Is this ok?
+ rp.setBackground(UIManager.getColor("control"));
+ }
+
+ /**
+ * Installs additional look and feel components to the root pane.
+ *
+ * @param rp the root pane to install the components to
+ */
+ protected void installComponents(JRootPane rp)
+ {
+ // All components are initialized in the JRootPane constructor, and since
+ // the createXXXPane methods are protected, I see no reasonable way,
+ // and no need to initialize them here. This method is here anyway
+ // for compatibility and to provide the necessary hooks to subclasses.
+ }
+
+ /**
+ * Installs any look and feel specific listeners on the root pane.
+ *
+ * @param rp the root pane to install the listeners to
+ */
+ protected void installListeners(JRootPane rp)
+ {
+ rp.addPropertyChangeListener(this);
+ }
+
+ /**
+ * Installs look and feel keyboard actions on the root pane.
+ *
+ * @param rp the root pane to install the keyboard actions to
+ */
+ protected void installKeyboardActions(JRootPane rp)
+ {
+ // We currently do not install any keyboard actions here.
+ // This method is here anyway for compatibility and to provide
+ // the necessary hooks to subclasses.
}
public void propertyChange(PropertyChangeEvent event)
{
+ // TODO: Implement this properly.
+ }
+
+ /**
+ * Uninstalls this UI from the root pane. This calls
+ * {@link #uninstallDefaults}, {@link #uninstallComponents},
+ * {@link #uninstallListeners}, {@link #uninstallKeyboardActions}
+ * in this order.
+ *
+ * @param c the root pane to uninstall the UI from
+ */
+ public void uninstallUI(JComponent c)
+ {
+ super.uninstallUI(c);
+ if (c instanceof JRootPane)
+ {
+ JRootPane rp = (JRootPane) c;
+ uninstallDefaults(rp);
+ uninstallComponents(rp);
+ uninstallListeners(rp);
+ uninstallKeyboardActions(rp);
+ }
+ }
+
+ /**
+ * Uninstalls the look and feel defaults that have been installed in
+ * {@link #installDefaults}.
+ *
+ * @param rp the root pane to uninstall the defaults from
+ */
+ protected void uninstallDefaults(JRootPane rp)
+ {
+ // We do nothing here.
+ }
+
+ /**
+ * Uninstalls look and feel components from the root pane.
+ *
+ * @param rp the root pane to uninstall the components from
+ */
+ protected void uninstallComponents(JRootPane rp)
+ {
+ // We do nothing here.
+ }
+
+ /**
+ * Uninstalls any look and feel specific listeners from the root pane.
+ *
+ * @param rp the root pane to uninstall the listeners from
+ */
+ protected void uninstallListeners(JRootPane rp)
+ {
+ rp.removePropertyChangeListener(this);
+ }
+
+ /**
+ * Uninstalls look and feel keyboard actions from the root pane.
+ *
+ * @param rp the root pane to uninstall the keyboard actions from
+ */
+ protected void uninstallKeyboardActions(JRootPane rp)
+ {
+ // We do nothing here.
}
}
diff --git a/javax/swing/plaf/basic/BasicScrollBarUI.java b/javax/swing/plaf/basic/BasicScrollBarUI.java
index 58d8fc1f7..2f5eaf391 100644
--- a/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -58,6 +58,7 @@ import javax.swing.BoundedRangeModel;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
+import javax.swing.LookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
@@ -80,6 +81,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected class ArrowButtonListener extends MouseAdapter
{
+
/**
* Move the thumb in the direction specified by the button's arrow. If
* this button is held down, then it should keep moving the thumb.
@@ -91,9 +93,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
scrollTimer.stop();
scrollListener.setScrollByBlock(false);
if (e.getSource() == incrButton)
- scrollListener.setDirection(POSITIVE_SCROLL);
- else
- scrollListener.setDirection(NEGATIVE_SCROLL);
+ scrollListener.setDirection(POSITIVE_SCROLL);
+ else if (e.getSource() == decrButton)
+ scrollListener.setDirection(NEGATIVE_SCROLL);
+ scrollTimer.setDelay(100);
scrollTimer.start();
}
@@ -105,6 +108,11 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
public void mouseReleased(MouseEvent e)
{
scrollTimer.stop();
+ scrollTimer.setDelay(300);
+ if (e.getSource() == incrButton)
+ scrollByUnit(POSITIVE_SCROLL);
+ else if (e.getSource() == decrButton)
+ scrollByUnit(NEGATIVE_SCROLL);
}
}
@@ -120,9 +128,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public void stateChanged(ChangeEvent e)
{
- // System.err.println(this + ".stateChanged()");
calculatePreferredSize();
- getThumbBounds();
+ updateThumbRect();
scrollbar.repaint();
}
}
@@ -141,31 +148,27 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
{
if (e.getPropertyName().equals("model"))
{
- ((BoundedRangeModel) e.getOldValue()).removeChangeListener(modelListener);
- scrollbar.getModel().addChangeListener(modelListener);
- getThumbBounds();
+ ((BoundedRangeModel) e.getOldValue()).removeChangeListener(modelListener);
+ scrollbar.getModel().addChangeListener(modelListener);
+ updateThumbRect();
}
else if (e.getPropertyName().equals("orientation"))
{
- incrButton.removeMouseListener(buttonListener);
- decrButton.removeMouseListener(buttonListener);
- int orientation = scrollbar.getOrientation();
- switch (orientation)
- {
- case (JScrollBar.HORIZONTAL):
- incrButton = createIncreaseButton(EAST);
- decrButton = createDecreaseButton(WEST);
- break;
- default:
- incrButton = createIncreaseButton(SOUTH);
- decrButton = createDecreaseButton(NORTH);
- break;
- }
- incrButton.addMouseListener(buttonListener);
- decrButton.addMouseListener(buttonListener);
- calculatePreferredSize();
+ uninstallListeners();
+ uninstallComponents();
+ uninstallDefaults();
+ installDefaults();
+ installComponents();
+ installListeners();
+ }
+ else if (e.getPropertyName().equals("enabled"))
+ {
+ Boolean b = (Boolean) e.getNewValue();
+ if (incrButton != null)
+ incrButton.setEnabled(b.booleanValue());
+ if (decrButton != null)
+ decrButton.setEnabled(b.booleanValue());
}
- scrollbar.repaint();
}
}
@@ -242,7 +245,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
scrollbar.repaint();
return;
}
- scrollByBlock(direction);
+ scrollByBlock(direction);
}
else
scrollByUnit(direction);
@@ -316,9 +319,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
else
value = valueForYPosition(currentMouseY);
- if (value == scrollbar.getValue())
- return;
-
if (! thumbRect.contains(e.getPoint()))
{
scrollTimer.stop();
@@ -333,6 +333,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
trackHighlight = DECREASE_HIGHLIGHT;
scrollListener.setDirection(NEGATIVE_SCROLL);
}
+ scrollTimer.setDelay(100);
scrollTimer.start();
}
else
@@ -343,8 +344,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
// "lower" edge of the thumb. The value at which
// the cursor is at must be greater or equal
// to that value.
+
+ scrollListener.setScrollByBlock(false);
scrollbar.setValueIsAdjusting(true);
- offset = value - scrollbar.getValue();
+ offset = value - scrollbar.getValue();
}
scrollbar.repaint();
}
@@ -357,11 +360,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public void mouseReleased(MouseEvent e)
{
- trackHighlight = NO_HIGHLIGHT;
scrollTimer.stop();
+ scrollTimer.setDelay(300);
+ currentMouseX = e.getX();
+ currentMouseY = e.getY();
- if (scrollbar.getValueIsAdjusting())
- scrollbar.setValueIsAdjusting(false);
+ if (shouldScroll(POSITIVE_SCROLL))
+ scrollByBlock(POSITIVE_SCROLL);
+ else if (shouldScroll(NEGATIVE_SCROLL))
+ scrollByBlock(NEGATIVE_SCROLL);
+
+ trackHighlight = NO_HIGHLIGHT;
+ scrollListener.setScrollByBlock(false);
+ scrollbar.setValueIsAdjusting(true);
scrollbar.repaint();
}
@@ -381,6 +392,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
else
value = valueForYPosition(currentMouseY);
+ if (thumbRect.contains(currentMouseX, currentMouseY))
+ return false;
+
if (direction == POSITIVE_SCROLL)
return (value > scrollbar.getValue());
else
@@ -517,11 +531,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected JButton createIncreaseButton(int orientation)
{
- if (incrButton == null)
- incrButton = new BasicArrowButton(orientation);
- else
- ((BasicArrowButton) incrButton).setDirection(orientation);
- return incrButton;
+ return new BasicArrowButton(orientation);
}
/**
@@ -534,11 +544,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected JButton createDecreaseButton(int orientation)
{
- if (decrButton == null)
- decrButton = new BasicArrowButton(orientation);
- else
- ((BasicArrowButton) decrButton).setDirection(orientation);
- return decrButton;
+ return new BasicArrowButton(orientation);
}
/**
@@ -602,7 +608,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public Dimension getMaximumSize(JComponent c)
{
- return getPreferredSize(c);
+ return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
/**
@@ -644,7 +650,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
void calculatePreferredSize()
{
- // System.err.println(this + ".calculatePreferredSize()");
int height;
int width;
height = width = 0;
@@ -707,48 +712,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected Rectangle getThumbBounds()
{
- int max = scrollbar.getMaximum();
- int min = scrollbar.getMinimum();
- int value = scrollbar.getValue();
- int extent = scrollbar.getVisibleAmount();
-
- // System.err.println(this + ".getThumbBounds()");
- if (max == min)
- {
- thumbRect.x = trackRect.x;
- thumbRect.y = trackRect.y;
- if (scrollbar.getOrientation() == HORIZONTAL)
- {
- thumbRect.width = getMinimumThumbSize().width;
- thumbRect.height = trackRect.height;
- }
- else
- {
- thumbRect.width = trackRect.width;
- thumbRect.height = getMinimumThumbSize().height;
- }
- return thumbRect;
- }
-
- if (scrollbar.getOrientation() == HORIZONTAL)
- {
- thumbRect.x = trackRect.x;
- thumbRect.x += (value - min) * trackRect.width / (max - min);
- thumbRect.y = trackRect.y;
-
- thumbRect.width = Math.max(extent * trackRect.width / (max - min),
- getMinimumThumbSize().width);
- thumbRect.height = trackRect.height;
- }
- else
- {
- thumbRect.x = trackRect.x;
- thumbRect.y = trackRect.y + value * trackRect.height / (max - min);
-
- thumbRect.width = trackRect.width;
- thumbRect.height = Math.max(extent * trackRect.height / (max - min),
- getMinimumThumbSize().height);
- }
return thumbRect;
}
@@ -760,22 +723,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected Rectangle getTrackBounds()
{
- SwingUtilities.calculateInnerArea(scrollbar, trackRect);
-
- if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
- {
- trackRect.width -= incrButton.getPreferredSize().getWidth();
- trackRect.width -= decrButton.getPreferredSize().getWidth();
-
- trackRect.x += decrButton.getPreferredSize().getWidth();
- }
- else
- {
- trackRect.height -= incrButton.getPreferredSize().getHeight();
- trackRect.height -= decrButton.getPreferredSize().getHeight();
-
- trackRect.y += incrButton.getPreferredSize().getHeight();
- }
return trackRect;
}
@@ -785,6 +732,18 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void installComponents()
{
+ if (incrButton != null)
+ scrollbar.add(incrButton);
+ if (decrButton != null)
+ scrollbar.add(decrButton);
+ }
+
+ /**
+ * This method installs the defaults for the scrollbar specified by the
+ * Basic Look and Feel.
+ */
+ protected void installDefaults()
+ {
int orientation = scrollbar.getOrientation();
switch (orientation)
{
@@ -797,31 +756,20 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
decrButton = createDecreaseButton(NORTH);
break;
}
- scrollbar.add(incrButton);
- scrollbar.add(decrButton);
- }
- /**
- * This method installs the defaults for the scrollbar specified by the
- * Basic Look and Feel.
- */
- protected void installDefaults()
- {
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- scrollbar.setForeground(defaults.getColor("ScrollBar.foreground"));
- scrollbar.setBackground(defaults.getColor("ScrollBar.background"));
- scrollbar.setBorder(defaults.getBorder("ScrollBar.border"));
+ LookAndFeel.installColors(scrollbar, "ScrollBar.background",
+ "ScrollBar.foreground");
+ LookAndFeel.installBorder(scrollbar, "ScrollBar.border");
scrollbar.setOpaque(true);
scrollbar.setLayout(this);
- thumbColor = defaults.getColor("ScrollBar.thumb");
- thumbDarkShadowColor = defaults.getColor("ScrollBar.thumbDarkShadow");
- thumbHighlightColor = defaults.getColor("ScrollBar.thumbHighlight");
- thumbLightShadowColor = defaults.getColor("ScrollBar.thumbShadow");
+ thumbColor = UIManager.getColor("ScrollBar.thumb");
+ thumbDarkShadowColor = UIManager.getColor("ScrollBar.thumbDarkShadow");
+ thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight");
+ thumbLightShadowColor = UIManager.getColor("ScrollBar.thumbShadow");
- maximumThumbSize = defaults.getDimension("ScrollBar.maximumThumbSize");
- minimumThumbSize = defaults.getDimension("ScrollBar.minimumThumbSize");
+ maximumThumbSize = UIManager.getDimension("ScrollBar.maximumThumbSize");
+ minimumThumbSize = UIManager.getDimension("ScrollBar.minimumThumbSize");
}
/**
@@ -873,11 +821,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
trackRect = new Rectangle();
thumbRect = new Rectangle();
- scrollTimer = new Timer(50, null);
- scrollTimer.setRepeats(true);
+ scrollTimer = new Timer(300, null);
+ installDefaults();
installComponents();
- installDefaults();
configureScrollBarColors();
installListeners();
@@ -908,17 +855,20 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void layoutHScrollbar(JScrollBar sb)
{
- // All we have to do is layout the 2 buttons?
Rectangle vr = new Rectangle();
SwingUtilities.calculateInnerArea(scrollbar, vr);
- // Update the rectangles.
- getTrackBounds();
- getThumbBounds();
-
Dimension incrDims = incrButton.getPreferredSize();
Dimension decrDims = decrButton.getPreferredSize();
+
+ // calculate and update the track bounds
+ SwingUtilities.calculateInnerArea(scrollbar, trackRect);
+ trackRect.width -= incrDims.getWidth();
+ trackRect.width -= decrDims.getWidth();
+ trackRect.x += decrDims.getWidth();
+ updateThumbRect();
+
decrButton.setBounds(vr.x, vr.y, decrDims.width, trackRect.height);
incrButton.setBounds(trackRect.x + trackRect.width, vr.y, incrDims.width,
trackRect.height);
@@ -934,12 +884,16 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
Rectangle vr = new Rectangle();
SwingUtilities.calculateInnerArea(scrollbar, vr);
- // Update rectangles
- getTrackBounds();
- getThumbBounds();
-
Dimension incrDims = incrButton.getPreferredSize();
Dimension decrDims = decrButton.getPreferredSize();
+
+ // Update rectangles
+ SwingUtilities.calculateInnerArea(scrollbar, trackRect);
+ trackRect.height -= incrDims.getHeight();
+ trackRect.height -= decrDims.getHeight();
+ trackRect.y += decrDims.getHeight();
+
+ updateThumbRect();
decrButton.setBounds(vr.x, vr.y, trackRect.width, decrDims.height);
incrButton.setBounds(vr.x, trackRect.y + trackRect.height,
@@ -947,6 +901,58 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
}
/**
+ * Updates the thumb rect.
+ */
+ void updateThumbRect()
+ {
+ int max = scrollbar.getMaximum();
+ int min = scrollbar.getMinimum();
+ int value = scrollbar.getValue();
+ int extent = scrollbar.getVisibleAmount();
+ if (max - extent <= min)
+ {
+ if (scrollbar.getOrientation() == JScrollBar.HORIZONTAL)
+ {
+ thumbRect.x = trackRect.x;
+ thumbRect.y = trackRect.y;
+ thumbRect.width = getMinimumThumbSize().width;
+ thumbRect.height = trackRect.height;
+ }
+ else
+ {
+ thumbRect.x = trackRect.x;
+ thumbRect.y = trackRect.y;
+ thumbRect.width = trackRect.width;
+ thumbRect.height = getMinimumThumbSize().height;
+ }
+ }
+ else
+ {
+ if (scrollbar.getOrientation() == JScrollBar.HORIZONTAL)
+ {
+ thumbRect.x = trackRect.x;
+ thumbRect.width = Math.max(extent * trackRect.width / (max - min),
+ getMinimumThumbSize().width);
+ int availableWidth = trackRect.width - thumbRect.width;
+ thumbRect.x += (value - min) * availableWidth / (max - min - extent);
+ thumbRect.y = trackRect.y;
+ thumbRect.height = trackRect.height;
+ }
+ else
+ {
+ thumbRect.x = trackRect.x;
+ thumbRect.height = Math.max(extent * trackRect.height / (max - min),
+ getMinimumThumbSize().height);
+ int availableHeight = trackRect.height - thumbRect.height;
+ thumbRect.y = trackRect.y
+ + (value - min) * availableHeight / (max - min - extent);
+ thumbRect.width = trackRect.width;
+ }
+ }
+
+ }
+
+ /**
* This method returns the minimum size required for the layout.
*
* @param scrollbarContainer The Container that is laid out.
@@ -1124,10 +1130,10 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void uninstallComponents()
{
- scrollbar.remove(incrButton);
- scrollbar.remove(decrButton);
- incrButton = null;
- decrButton = null;
+ if (incrButton != null)
+ scrollbar.remove(incrButton);
+ if (decrButton != null)
+ scrollbar.remove(decrButton);
}
/**
@@ -1138,7 +1144,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
{
scrollbar.setForeground(null);
scrollbar.setBackground(null);
- scrollbar.setBorder(null);
+ LookAndFeel.uninstallBorder(scrollbar);
+ incrButton = null;
+ decrButton = null;
}
/**
@@ -1155,17 +1163,22 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void uninstallListeners()
{
- scrollTimer.removeActionListener(scrollListener);
+ if (scrollTimer != null)
+ scrollTimer.removeActionListener(scrollListener);
- scrollbar.getModel().removeChangeListener(modelListener);
- scrollbar.removePropertyChangeListener(propertyChangeListener);
-
- decrButton.removeMouseListener(buttonListener);
- incrButton.removeMouseListener(buttonListener);
-
- scrollbar.removeMouseListener(trackListener);
- scrollbar.removeMouseMotionListener(trackListener);
+ if (scrollbar != null)
+ {
+ scrollbar.getModel().removeChangeListener(modelListener);
+ scrollbar.removePropertyChangeListener(propertyChangeListener);
+ scrollbar.removeMouseListener(trackListener);
+ scrollbar.removeMouseMotionListener(trackListener);
+ }
+ if (decrButton != null)
+ decrButton.removeMouseListener(buttonListener);
+ if (incrButton != null)
+ incrButton.removeMouseListener(buttonListener);
+
propertyChangeListener = null;
modelListener = null;
buttonListener = null;
@@ -1182,8 +1195,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public void uninstallUI(JComponent c)
{
- uninstallDefaults();
uninstallListeners();
+ uninstallDefaults();
uninstallComponents();
scrollTimer = null;
diff --git a/javax/swing/plaf/basic/BasicScrollPaneUI.java b/javax/swing/plaf/basic/BasicScrollPaneUI.java
index bd1576f37..277b25a00 100644
--- a/javax/swing/plaf/basic/BasicScrollPaneUI.java
+++ b/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -40,13 +40,21 @@ package javax.swing.plaf.basic;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
+import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
+import javax.swing.JViewport;
+import javax.swing.LookAndFeel;
import javax.swing.ScrollPaneConstants;
import javax.swing.ScrollPaneLayout;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ScrollPaneUI;
@@ -54,9 +62,192 @@ public class BasicScrollPaneUI extends ScrollPaneUI
implements ScrollPaneConstants
{
+ /**
+ * Listens for changes in the state of the horizontal scrollbar's model and
+ * updates the scrollpane accordingly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ public class HSBChangeListener implements ChangeListener
+ {
+
+ /**
+ * Receives notification when the state of the horizontal scrollbar
+ * model has changed.
+ *
+ * @param event the change event
+ */
+ public void stateChanged(ChangeEvent event)
+ {
+ JScrollBar hsb = scrollpane.getHorizontalScrollBar();
+ JViewport vp = scrollpane.getViewport();
+ Point viewPosition = vp.getViewPosition();
+ int xpos = hsb.getValue();
+
+ if (xpos != viewPosition.x)
+ {
+ viewPosition.x = xpos;
+ vp.setViewPosition(viewPosition);
+ }
+
+ viewPosition.y = 0;
+ JViewport columnHeader = scrollpane.getColumnHeader();
+ if (columnHeader != null
+ && !columnHeader.getViewPosition().equals(viewPosition))
+ columnHeader.setViewPosition(viewPosition);
+ }
+
+ }
+
+ /**
+ * Listens for changes in the state of the vertical scrollbar's model and
+ * updates the scrollpane accordingly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ public class VSBChangeListener implements ChangeListener
+ {
+
+ /**
+ * Receives notification when the state of the vertical scrollbar
+ * model has changed.
+ *
+ * @param event the change event
+ */
+ public void stateChanged(ChangeEvent event)
+ {
+ JScrollBar vsb = scrollpane.getVerticalScrollBar();
+ JViewport vp = scrollpane.getViewport();
+ Point viewPosition = vp.getViewPosition();
+ int ypos = vsb.getValue();
+ if (ypos != viewPosition.y)
+ {
+ viewPosition.y = ypos;
+ vp.setViewPosition(viewPosition);
+ }
+
+ viewPosition.x = 0;
+ JViewport rowHeader = scrollpane.getRowHeader();
+ if (rowHeader != null
+ && !rowHeader.getViewPosition().equals(viewPosition))
+ rowHeader.setViewPosition(viewPosition);
+ }
+
+ }
+
+ /**
+ * Listens for changes of the viewport's extent size and updates the
+ * scrollpane accordingly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ public class ViewportChangeHandler implements ChangeListener
+ {
+
+ /**
+ * Receives notification when the view's size, position or extent size
+ * changes. When the extents size has changed, this method calls
+ * {@link BasicScrollPaneUI#syncScrollPaneWithViewport()} to adjust the
+ * scrollbars extents as well.
+ *
+ * @param event the change event
+ */
+ public void stateChanged(ChangeEvent event)
+ {
+ JViewport vp = scrollpane.getViewport();
+ JScrollBar hsb = scrollpane.getHorizontalScrollBar();
+ JScrollBar vsb = scrollpane.getVerticalScrollBar();
+ syncScrollPaneWithViewport();
+ }
+
+ }
+
+ /**
+ * Listens for property changes on the scrollpane and update the view
+ * accordingly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ public class PropertyChangeHandler implements PropertyChangeListener
+ {
+
+ /**
+ * Receives notification when any of the scrollpane's bound property
+ * changes. This method calls the appropriate update method on the
+ * <code>ScrollBarUI</code>.
+ *
+ * @param e the property change event
+ *
+ * @see BasicScrollPaneUI#updateColumnHeader(PropertyChangeEvent)
+ * @see BasicScrollPaneUI#updateRowHeader(PropertyChangeEvent)
+ * @see BasicScrollPaneUI#updateScrollBarDisplayPolicy(PropertyChangeEvent)
+ * @see BasicScrollPaneUI#updateViewport(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals("viewport"))
+ updateViewport(e);
+ else if (e.getPropertyName().equals("rowHeader"))
+ updateRowHeader(e);
+ else if (e.getPropertyName().equals("columnHeader"))
+ updateColumnHeader(e);
+ else if (e.getPropertyName().equals("horizontalScrollBarPolicy")
+ || e.getPropertyName().equals("verticalScrollBarPolicy"))
+ updateScrollBarDisplayPolicy(e);
+ }
+
+ }
+
+ /**
+ * Listens for mouse wheel events and update the scrollpane accordingly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ *
+ * @since 1.4
+ */
+ protected class MouseWheelHandler implements MouseWheelListener
+ {
+
+ /**
+ * Receives notification whenever the mouse wheel is moved.
+ *
+ * @param event the mouse wheel event
+ */
+ public void mouseWheelMoved(MouseWheelEvent event)
+ {
+ // TODO: Implement this properly.
+ }
+
+ }
+
/** The Scrollpane for which the UI is provided by this class. */
protected JScrollPane scrollpane;
+ /**
+ * The horizontal scrollbar listener.
+ */
+ protected ChangeListener hsbChangeListener;
+
+ /**
+ * The vertical scrollbar listener.
+ */
+ protected ChangeListener vsbChangeListener;
+
+ /**
+ * The viewport listener.
+ */
+ protected ChangeListener viewportChangeListener;
+
+ /**
+ * The scrollpane property change listener.
+ */
+ protected PropertyChangeListener spPropertyChangeListener;
+
+ /**
+ * The mousewheel listener for the scrollpane.
+ */
+ MouseWheelListener mouseWheelListener;
+
public static ComponentUI createUI(final JComponent c)
{
return new BasicScrollPaneUI();
@@ -65,11 +256,10 @@ public class BasicScrollPaneUI extends ScrollPaneUI
protected void installDefaults(JScrollPane p)
{
scrollpane = p;
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- p.setForeground(defaults.getColor("ScrollPane.foreground"));
- p.setBackground(defaults.getColor("ScrollPane.background"));
- p.setFont(defaults.getFont("ScrollPane.font"));
- p.setBorder(defaults.getBorder("ScrollPane.border"));
+ LookAndFeel.installColorsAndFont(p, "ScrollPane.background",
+ "ScrollPane.foreground",
+ "ScrollPane.font");
+ LookAndFeel.installBorder(p, "ScrollPane.border");
p.setOpaque(true);
}
@@ -85,16 +275,141 @@ public class BasicScrollPaneUI extends ScrollPaneUI
public void installUI(final JComponent c)
{
super.installUI(c);
- this.installDefaults((JScrollPane)c);
+ installDefaults((JScrollPane) c);
+ installListeners((JScrollPane) c);
+ installKeyboardActions((JScrollPane) c);
+ }
+
+ /**
+ * Installs the listeners on the scrollbars, the viewport and the scrollpane.
+ *
+ * @param sp the scrollpane on which to install the listeners
+ */
+ protected void installListeners(JScrollPane sp)
+ {
+ if (spPropertyChangeListener == null)
+ spPropertyChangeListener = createPropertyChangeListener();
+ sp.addPropertyChangeListener(spPropertyChangeListener);
+
+ if (hsbChangeListener == null)
+ hsbChangeListener = createHSBChangeListener();
+ sp.getHorizontalScrollBar().getModel().addChangeListener(hsbChangeListener);
+
+ if (vsbChangeListener == null)
+ vsbChangeListener = createVSBChangeListener();
+ sp.getVerticalScrollBar().getModel().addChangeListener(vsbChangeListener);
+
+ if (viewportChangeListener == null)
+ viewportChangeListener = createViewportChangeListener();
+ sp.getViewport().addChangeListener(viewportChangeListener);
+
+ if (mouseWheelListener == null)
+ mouseWheelListener = createMouseWheelListener();
+ sp.addMouseWheelListener(mouseWheelListener);
+ }
+
+ /**
+ * Installs additional keyboard actions on the scrollpane. This is a hook
+ * method provided to subclasses in order to install their own keyboard
+ * actions.
+ *
+ * @param sp the scrollpane to install keyboard actions on
+ */
+ protected void installKeyboardActions(JScrollPane sp)
+ {
+ // TODO: Is this only a hook method or should we actually do something
+ // here? If the latter, than figure out what and implement this.
+ }
+
+ /**
+ * Creates and returns the change listener for the horizontal scrollbar.
+ *
+ * @return the change listener for the horizontal scrollbar
+ */
+ protected ChangeListener createHSBChangeListener()
+ {
+ return new HSBChangeListener();
+ }
+
+ /**
+ * Creates and returns the change listener for the vertical scrollbar.
+ *
+ * @return the change listener for the vertical scrollbar
+ */
+ protected ChangeListener createVSBChangeListener()
+ {
+ return new VSBChangeListener();
+ }
+
+ /**
+ * Creates and returns the change listener for the viewport.
+ *
+ * @return the change listener for the viewport
+ */
+ protected ChangeListener createViewportChangeListener()
+ {
+ return new ViewportChangeHandler();
+ }
+
+ /**
+ * Creates and returns the property change listener for the scrollpane.
+ *
+ * @return the property change listener for the scrollpane
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * Creates and returns the mouse wheel listener for the scrollpane.
+ *
+ * @return the mouse wheel listener for the scrollpane
+ */
+ protected MouseWheelListener createMouseWheelListener()
+ {
+ return new MouseWheelHandler();
}
public void uninstallUI(final JComponent c)
{
super.uninstallUI(c);
this.uninstallDefaults((JScrollPane)c);
+ uninstallListeners((JScrollPane) c);
+ installKeyboardActions((JScrollPane) c);
+ }
+
+ /**
+ * Uninstalls all the listeners that have been installed in
+ * {@link #installListeners(JScrollPane)}.
+ *
+ * @param c the scrollpane from which to uninstall the listeners
+ */
+ protected void uninstallListeners(JComponent c)
+ {
+ JScrollPane sp = (JScrollPane) c;
+ sp.removePropertyChangeListener(spPropertyChangeListener);
+ sp.getHorizontalScrollBar().getModel()
+ .removeChangeListener(hsbChangeListener);
+ sp.getVerticalScrollBar().getModel()
+ .removeChangeListener(vsbChangeListener);
+ sp.getViewport().removeChangeListener(viewportChangeListener);
+ sp.removeMouseWheelListener(mouseWheelListener);
+ }
+
+ /**
+ * Uninstalls all keyboard actions from the JScrollPane that have been
+ * installed by {@link #installKeyboardActions}. This is a hook method
+ * provided to subclasses to add their own keyboard actions.
+ *
+ * @param sp the scrollpane to uninstall keyboard actions from
+ */
+ protected void uninstallKeyboardActions(JScrollPane sp)
+ {
+ // TODO: Is this only a hook method or should we actually do something
+ // here? If the latter, than figure out what and implement this.
}
-
public Dimension getMinimumSize(JComponent c)
{
JScrollPane p = (JScrollPane ) c;
@@ -107,6 +422,76 @@ public class BasicScrollPaneUI extends ScrollPaneUI
// do nothing; the normal painting-of-children algorithm, along with
// ScrollPaneLayout, does all the relevant work.
}
+
+ /**
+ * Synchronizes the scrollbars with the viewport's extents.
+ */
+ protected void syncScrollPaneWithViewport()
+ {
+ JViewport vp = scrollpane.getViewport();
+
+ // Update the horizontal scrollbar.
+ JScrollBar hsb = scrollpane.getHorizontalScrollBar();
+ hsb.setMaximum(vp.getViewSize().width);
+ hsb.setValue(vp.getViewPosition().x);
+ hsb.setVisibleAmount(vp.getExtentSize().width);
+
+ // Update the vertical scrollbar.
+ JScrollBar vsb = scrollpane.getVerticalScrollBar();
+ vsb.setMaximum(vp.getViewSize().height);
+ vsb.setValue(vp.getViewPosition().y);
+ vsb.setVisibleAmount(vp.getExtentSize().height);
+ }
+
+ /**
+ * Receives notification when the <code>columnHeader</code> property has
+ * changed on the scrollpane.
+ *
+ * @param ev the property change event
+ */
+ protected void updateColumnHeader(PropertyChangeEvent ev)
+ {
+ // TODO: Find out what should be done here. Or is this only a hook?
+ }
+
+ /**
+ * Receives notification when the <code>rowHeader</code> property has changed
+ * on the scrollpane.
+ *
+ * @param ev the property change event
+ */
+ protected void updateRowHeader(PropertyChangeEvent ev)
+ {
+ // TODO: Find out what should be done here. Or is this only a hook?
+ }
+
+ /**
+ * Receives notification when the <code>scrollBarDisplayPolicy</code>
+ * property has changed on the scrollpane.
+ *
+ * @param ev the property change event
+ */
+ protected void updateScrollBarDisplayPolicy(PropertyChangeEvent ev)
+ {
+ // TODO: Find out what should be done here. Or is this only a hook?
+ }
+
+ /**
+ * Receives notification when the <code>viewport</code> property has changed
+ * on the scrollpane.
+ *
+ * This method sets removes the viewportChangeListener from the old viewport
+ * and adds it to the new viewport.
+ *
+ * @param ev the property change event
+ */
+ protected void updateViewport(PropertyChangeEvent ev)
+ {
+ JViewport oldViewport = (JViewport) ev.getOldValue();
+ oldViewport.removeChangeListener(viewportChangeListener);
+ JViewport newViewport = (JViewport) ev.getNewValue();
+ oldViewport.addChangeListener(viewportChangeListener);
+ }
}
diff --git a/javax/swing/plaf/basic/BasicSeparatorUI.java b/javax/swing/plaf/basic/BasicSeparatorUI.java
index 38c9c7a28..97caa3af7 100644
--- a/javax/swing/plaf/basic/BasicSeparatorUI.java
+++ b/javax/swing/plaf/basic/BasicSeparatorUI.java
@@ -41,13 +41,11 @@ package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
-import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.JComponent;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SeparatorUI;
@@ -121,10 +119,8 @@ public class BasicSeparatorUI extends SeparatorUI
*/
protected void installDefaults(JSeparator s)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- shadow = defaults.getColor("Separator.shadow");
- highlight = defaults.getColor("Separator.highlight");
+ shadow = UIManager.getColor("Separator.shadow");
+ highlight = UIManager.getColor("Separator.highlight");
s.setOpaque(false);
}
@@ -165,8 +161,8 @@ public class BasicSeparatorUI extends SeparatorUI
/**
* The separator is made of two lines. The top line will be
- * the highlight color (or left line if it's vertical). The bottom
- * or right line will be the shadow color. The two lines will
+ * the shadow color (or left line if it's vertical). The bottom
+ * or right line will be the highlight color. The two lines will
* be centered inside the bounds box. If the separator is horizontal,
* then it will be vertically centered, or if it's vertical, it will
* be horizontally centered.
@@ -180,9 +176,6 @@ public class BasicSeparatorUI extends SeparatorUI
SwingUtilities.calculateInnerArea(c, r);
Color saved = g.getColor();
- int midAB = r.width / 2 + r.x;
- int midAD = r.height / 2 + r.y;
-
JSeparator s;
if (c instanceof JSeparator)
s = (JSeparator) c;
@@ -190,21 +183,24 @@ public class BasicSeparatorUI extends SeparatorUI
return;
if (s.getOrientation() == JSeparator.HORIZONTAL)
- {
- g.setColor(highlight);
- g.drawLine(r.x, midAD, r.x + r.width, midAD);
-
- g.setColor(shadow);
- g.drawLine(r.x, midAD + 1, r.x + r.width, midAD + 1);
- }
- else
- {
- g.setColor(highlight);
- g.drawLine(midAB, r.y, midAB, r.y + r.height);
-
- g.setColor(shadow);
- g.drawLine(midAB + 1, r.y, midAB + 1, r.y + r.height);
- }
+ {
+ int midAB = r.height / 2;
+ g.setColor(shadow);
+ g.drawLine(r.x, r.y + midAB - 1, r.x + r.width, r.y + midAB - 1);
+
+ g.setColor(highlight);
+ g.fillRect(r.x, r.y + midAB, r.x + r.width, r.y + midAB);
+ }
+ else
+ {
+ int midAD = r.height / 2 + r.y;
+ g.setColor(shadow);
+ g.drawLine(r.x, r.y, r.x, r.y + r.height);
+
+ g.setColor(highlight);
+ g.fillRect(r.x + midAD, r.y + r.height, r.x + midAD, r.y + r.height);
+ }
+ g.setColor(saved);
}
/**
@@ -217,28 +213,14 @@ public class BasicSeparatorUI extends SeparatorUI
*/
public Dimension getPreferredSize(JComponent c)
{
- Dimension dims = new Dimension(0, 0);
- Insets insets = c.getInsets();
-
+ Dimension pref = new Dimension(2, 0);
if (c instanceof JSeparator)
{
JSeparator s = (JSeparator) c;
-
if (s.getOrientation() == JSeparator.HORIZONTAL)
- {
- dims.height = 2;
- dims.width = 40;
- }
- else
- {
- dims.width = 2;
- dims.height = 40;
- }
+ pref = new Dimension(0, 2);
}
- dims.width += insets.left + insets.right;
- dims.height += insets.top + insets.bottom;
-
- return dims;
+ return pref;
}
/**
@@ -251,7 +233,7 @@ public class BasicSeparatorUI extends SeparatorUI
*/
public Dimension getMinimumSize(JComponent c)
{
- return getPreferredSize(c);
+ return new Dimension(0, 0);
}
/**
@@ -264,6 +246,7 @@ public class BasicSeparatorUI extends SeparatorUI
*/
public Dimension getMaximumSize(JComponent c)
{
- return getPreferredSize(c);
+ return new Dimension(Short.MAX_VALUE,
+ Short.MAX_VALUE);
}
}
diff --git a/javax/swing/plaf/basic/BasicSliderUI.java b/javax/swing/plaf/basic/BasicSliderUI.java
index 0b4058429..26f580519 100644
--- a/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/javax/swing/plaf/basic/BasicSliderUI.java
@@ -60,13 +60,14 @@ import java.beans.PropertyChangeListener;
import java.util.Dictionary;
import java.util.Enumeration;
+import javax.swing.AbstractAction;
import javax.swing.BoundedRangeModel;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JSlider;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -470,6 +471,34 @@ public class BasicSliderUI extends SliderUI
}
}
+ /**
+ * This class is no longer used as of JDK1.3.
+ */
+ public class ActionScroller extends AbstractAction
+ {
+ /**
+ * Not used.
+ *
+ * @param slider not used
+ * @param dir not used
+ * @param block not used
+ */
+ public ActionScroller(JSlider slider, int dir, boolean block)
+ {
+ // Not used.
+ }
+
+ /**
+ * Not used.
+ *
+ * @param event not used
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ // Not used.
+ }
+ }
+
/** Listener for changes from the model. */
protected ChangeListener changeListener;
@@ -680,16 +709,14 @@ public class BasicSliderUI extends SliderUI
*/
protected void installDefaults(JSlider slider)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- slider.setForeground(defaults.getColor("Slider.foreground"));
- slider.setBackground(defaults.getColor("Slider.background"));
- shadowColor = defaults.getColor("Slider.shadow");
- highlightColor = defaults.getColor("Slider.highlight");
- focusColor = defaults.getColor("Slider.focus");
- slider.setBorder(defaults.getBorder("Slider.border"));
+ LookAndFeel.installColors(slider, "Slider.background",
+ "Slider.foreground");
+ LookAndFeel.installBorder(slider, "Slider.border");
+ shadowColor = UIManager.getColor("Slider.shadow");
+ highlightColor = UIManager.getColor("Slider.highlight");
+ focusColor = UIManager.getColor("Slider.focus");
+ focusInsets = UIManager.getInsets("Slider.focusInsets");
slider.setOpaque(true);
- focusInsets = defaults.getInsets("Slider.focusInsets");
}
/**
@@ -1465,7 +1492,7 @@ public class BasicSliderUI extends SliderUI
// FIXME: Move this to propertyChangeEvent handler, when we get those.
leftToRightCache = slider.getComponentOrientation() != ComponentOrientation.RIGHT_TO_LEFT;
// FIXME: This next line is only here because the above line is here.
- calculateThumbLocation();
+ calculateGeometry();
if (slider.getPaintTrack())
paintTrack(g);
@@ -1958,7 +1985,7 @@ public class BasicSliderUI extends SliderUI
public void paintThumb(Graphics g)
{
Color saved_color = g.getColor();
-
+
Point a = new Point(thumbRect.x, thumbRect.y);
Point b = new Point(a);
Point c = new Point(a);
diff --git a/javax/swing/plaf/basic/BasicSpinnerUI.java b/javax/swing/plaf/basic/BasicSpinnerUI.java
index 97ab97b89..3b7399eaf 100644
--- a/javax/swing/plaf/basic/BasicSpinnerUI.java
+++ b/javax/swing/plaf/basic/BasicSpinnerUI.java
@@ -53,9 +53,8 @@ import java.beans.PropertyChangeListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JSpinner;
+import javax.swing.LookAndFeel;
import javax.swing.Timer;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SpinnerUI;
@@ -167,16 +166,9 @@ public class BasicSpinnerUI extends SpinnerUI
*/
protected void installDefaults()
{
- /* most of it copied from BasicLabelUI, I don't know what keys are
- available, so someone may want to update this. Hence: TODO
- */
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- /*
- spinner.setForeground(defaults.getColor("Spinner.foreground"));
- spinner.setBackground(defaults.getColor("Spinner.background"));
- spinner.setFont(defaults.getFont("Spinner.font"));
- spinner.setBorder(defaults.getBorder("Spinner.border"));
- */
+ LookAndFeel.installColorsAndFont(spinner, "Spinner.background",
+ "Spinner.foreground", "Spinner.font");
+ LookAndFeel.installBorder(spinner, "Spinner.border");
spinner.setLayout(createLayout());
spinner.setOpaque(true);
}
diff --git a/javax/swing/plaf/basic/BasicSplitPaneDivider.java b/javax/swing/plaf/basic/BasicSplitPaneDivider.java
index b8674ed2f..69ed2be7c 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneDivider.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneDivider.java
@@ -802,6 +802,7 @@ public class BasicSplitPaneDivider extends Container
*/
protected DividerLayout()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java
index ef8e22823..f9b558eab 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -58,7 +58,7 @@ import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.JSplitPane;
import javax.swing.KeyStroke;
-import javax.swing.UIDefaults;
+import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SplitPaneUI;
@@ -404,7 +404,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
protected void setComponentToSize(Component c, int size, int location,
Insets insets, Dimension containerSize)
- {
+ {
int w = size;
int h = containerSize.height - insets.top - insets.bottom;
int x = location;
@@ -637,7 +637,6 @@ public class BasicSplitPaneUI extends SplitPaneUI
int x = insets.left;
int h = size;
int w = containerSize.width - insets.left - insets.right;
-
c.setBounds(x, y, w, h);
}
@@ -817,15 +816,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
int newSize = splitPane.getDividerSize();
int[] tmpSizes = layoutManager.getSizes();
dividerSize = tmpSizes[2];
- Component left = splitPane.getLeftComponent();
- Component right = splitPane.getRightComponent();
- int newSpace = newSize - tmpSizes[2];
-
+ int newSpace = newSize - tmpSizes[2];
tmpSizes[2] = newSize;
tmpSizes[0] += newSpace / 2;
tmpSizes[1] += newSpace / 2;
-
+
layoutManager.setSizes(tmpSizes);
}
else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY))
@@ -942,6 +938,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public BasicSplitPaneUI()
{
+ // Nothing to do here.
}
/**
@@ -991,16 +988,16 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
protected void installDefaults()
{
+ LookAndFeel.installColors(splitPane, "SplitPane.background",
+ "SplitPane.foreground");
+ LookAndFeel.installBorder(splitPane, "SplitPane.border");
divider = createDefaultDivider();
resetLayoutManager();
nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider();
splitPane.add(divider, JSplitPane.DIVIDER);
// There is no need to add the nonContinuousLayoutDivider
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- splitPane.setBackground(defaults.getColor("SplitPane.background"));
- splitPane.setBorder(defaults.getBorder("SplitPane.border"));
- splitPane.setDividerSize(defaults.getInt("SplitPane.dividerSize"));
+ splitPane.setDividerSize(UIManager.getInt("SplitPane.dividerSize"));
splitPane.setOpaque(true);
}
@@ -1301,15 +1298,41 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public void setDividerLocation(JSplitPane jc, int location)
{
+ location = validLocation(location);
+ Container p = jc.getParent();
+ Dimension rightPrefSize = jc.getRightComponent().getPreferredSize();
+ Dimension size = jc.getSize();
+ // check if the size has been set for the splitpane
+ if (size.width == 0 && size.height == 0)
+ size = jc.getPreferredSize();
+
+ if (getOrientation() == 0 && location > size.height)
+ {
+ location = size.height;
+ while (p != null)
+ {
+ p.setSize(p.getWidth(), p.getHeight() + rightPrefSize.height);
+ p = p.getParent();
+ }
+ }
+ else if (location > size.width)
+ {
+ location = size.width;
+ while (p != null)
+ {
+ p.setSize(p.getWidth() + rightPrefSize.width, p.getHeight());
+ p = p.getParent();
+ }
+ }
+
setLastDragLocation(getDividerLocation(splitPane));
splitPane.setLastDividerLocation(getDividerLocation(splitPane));
int[] tmpSizes = layoutManager.getSizes();
- tmpSizes[0] = location
+ tmpSizes[0] = location
- layoutManager.getInitialLocation(splitPane.getInsets());
tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(),
splitPane.getInsets())
- - tmpSizes[0] - tmpSizes[1];
-
+ - tmpSizes[0];
layoutManager.setSizes(tmpSizes);
splitPane.revalidate();
splitPane.repaint();
@@ -1388,6 +1411,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public void paint(Graphics g, JComponent jc)
{
+ // TODO: What should be done here?
}
/**
@@ -1550,10 +1574,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
private int validLocation(int location)
{
- if (location < getMinimumDividerLocation(splitPane))
- return getMinimumDividerLocation(splitPane);
- if (location > getMaximumDividerLocation(splitPane))
- return getMaximumDividerLocation(splitPane);
+ int min = getMinimumDividerLocation(splitPane);
+ int max = getMaximumDividerLocation(splitPane);
+ if (min > 0 && location < min)
+ return min;
+ if (max > 0 && location > max)
+ return max;
return location;
}
}
diff --git a/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
index 232136fc2..ce9ea3ec7 100644
--- a/javax/swing/plaf/basic/BasicTabbedPaneUI.java
+++ b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -64,9 +64,9 @@ import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JViewport;
import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -354,7 +354,6 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
for (int i = 0; i < tabCount; i++)
{
width = calculateTabWidth(tabPlacement, i, fm);
-
if (runWidth + width > max)
{
runWidth = tabAreaInsets.left + insets.left
@@ -1182,6 +1181,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
private class ScrollingViewport extends JViewport implements UIResource
{
+ // TODO: Maybe remove this inner class.
}
/**
@@ -1536,28 +1536,26 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- tabPane.setFont(defaults.getFont("TabbedPane.font"));
- tabPane.setForeground(defaults.getColor("TabbedPane.foreground"));
- tabPane.setBackground(defaults.getColor("TabbedPane.background"));
+ LookAndFeel.installColorsAndFont(tabPane, "TabbedPane.background",
+ "TabbedPane.foreground",
+ "TabbedPane.font");
tabPane.setOpaque(false);
- highlight = defaults.getColor("TabbedPane.highlight");
- lightHighlight = defaults.getColor("TabbedPane.lightHighlight");
+ highlight = UIManager.getColor("TabbedPane.highlight");
+ lightHighlight = UIManager.getColor("TabbedPane.lightHighlight");
- shadow = defaults.getColor("TabbedPane.shadow");
- darkShadow = defaults.getColor("TabbedPane.darkShadow");
+ shadow = UIManager.getColor("TabbedPane.shadow");
+ darkShadow = UIManager.getColor("TabbedPane.darkShadow");
- focus = defaults.getColor("TabbedPane.focus");
+ focus = UIManager.getColor("TabbedPane.focus");
- textIconGap = defaults.getInt("TabbedPane.textIconGap");
- tabRunOverlay = defaults.getInt("TabbedPane.tabRunOverlay");
+ textIconGap = UIManager.getInt("TabbedPane.textIconGap");
+ tabRunOverlay = UIManager.getInt("TabbedPane.tabRunOverlay");
- tabInsets = defaults.getInsets("TabbedPane.tabbedPaneTabInsets");
- selectedTabPadInsets = defaults.getInsets("TabbedPane.tabbedPaneTabPadInsets");
- tabAreaInsets = defaults.getInsets("TabbedPane.tabbedPaneTabAreaInsets");
- contentBorderInsets = defaults.getInsets("TabbedPane.tabbedPaneContentBorderInsets");
+ tabInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabInsets");
+ selectedTabPadInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabPadInsets");
+ tabAreaInsets = UIManager.getInsets("TabbedPane.tabbedPaneTabAreaInsets");
+ contentBorderInsets = UIManager.getInsets("TabbedPane.tabbedPaneContentBorderInsets");
calcRect = new Rectangle();
tabRuns = new int[10];
@@ -1737,11 +1735,15 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// we WANT to paint the outermost run first and then work our way in.
int tabCount = tabPane.getTabCount();
int currRun = 1;
+
+ if (tabCount > runCount)
+ runCount = tabCount;
+
if (tabCount < 1)
return;
-
+
if (runCount > 1)
- currRun = 0;
+ currRun = 0;
for (int i = 0; i < runCount; i++)
{
int first = lastTabInRun(tabCount, getPreviousTabRun(currRun)) + 1;
@@ -1856,7 +1858,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
SwingConstants.CENTER,
SwingConstants.CENTER,
SwingConstants.CENTER,
- SwingConstants.CENTER, tabRect,
+ SwingConstants.RIGHT, tabRect,
iconRect, textRect, textIconGap);
int shiftX = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
diff --git a/javax/swing/plaf/basic/BasicTableHeaderUI.java b/javax/swing/plaf/basic/BasicTableHeaderUI.java
index 700b406d0..ec0467a74 100644
--- a/javax/swing/plaf/basic/BasicTableHeaderUI.java
+++ b/javax/swing/plaf/basic/BasicTableHeaderUI.java
@@ -46,7 +46,7 @@ import java.awt.event.MouseEvent;
import javax.swing.CellRendererPane;
import javax.swing.JComponent;
-import javax.swing.UIDefaults;
+import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.MouseInputListener;
@@ -57,8 +57,7 @@ import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
-public class BasicTableHeaderUI
- extends TableHeaderUI
+public class BasicTableHeaderUI extends TableHeaderUI
{
public static ComponentUI createUI(JComponent h)
@@ -71,16 +70,42 @@ public class BasicTableHeaderUI
protected CellRendererPane rendererPane;
protected Border cellBorder;
- class MouseInputHandler
- implements MouseInputListener
+ public class MouseInputHandler implements MouseInputListener
{
- public void mouseClicked(MouseEvent e) {}
- public void mouseDragged(MouseEvent e) {}
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
- public void mouseMoved(MouseEvent e) {}
- public void mousePressed(MouseEvent e) {}
- public void mouseReleased(MouseEvent e) {}
+ public void mouseClicked(MouseEvent e)
+ {
+ // TODO: Implement this properly.
+ }
+
+ public void mouseDragged(MouseEvent e)
+ {
+ // TODO: Implement this properly.
+ }
+
+ public void mouseEntered(MouseEvent e)
+ {
+ // TODO: Implement this properly.
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ // TODO: Implement this properly.
+ }
+
+ public void mouseMoved(MouseEvent e)
+ {
+ // TODO: Implement this properly.
+ }
+
+ public void mousePressed(MouseEvent e)
+ {
+ // TODO: Implement this properly.
+ }
+
+ public void mouseReleased(MouseEvent e)
+ {
+ // TODO: Implement this properly.
+ }
}
protected MouseInputListener createMouseInputListener()
@@ -95,15 +120,15 @@ public class BasicTableHeaderUI
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- header.setBackground(defaults.getColor("TableHeader.background"));
- header.setForeground(defaults.getColor("TableHeader.foreground"));
- header.setFont(defaults.getFont("TableHeader.font"));
- cellBorder = defaults.getBorder("TableHeader.cellBorder");
+ LookAndFeel.installColorsAndFont(header, "TableHeader.background",
+ "TableHeader.foreground",
+ "TableHeader.font");
+ cellBorder = UIManager.getBorder("TableHeader.cellBorder");
}
protected void installKeyboardActions()
{
+ // TODO: Implement this properly.
}
protected void installListeners()
@@ -128,6 +153,7 @@ public class BasicTableHeaderUI
protected void uninstallKeyboardActions()
{
+ // TODO: Implement this properly.
}
protected void uninstallListeners()
@@ -157,6 +183,7 @@ public class BasicTableHeaderUI
Rectangle bounds = header.getHeaderRect(i);
if (bounds.intersects(clip))
{
+ Rectangle oldClip = gfx.getClipBounds();
TableColumn col = cmod.getColumn(i);
TableCellRenderer rend = col.getHeaderRenderer();
if (rend == null)
@@ -173,10 +200,12 @@ public class BasicTableHeaderUI
if (comp instanceof JComponent)
((JComponent)comp).setBorder(cellBorder);
gfx.translate(bounds.x, bounds.y);
+ gfx.setClip(0, 0, bounds.width, bounds.height);
comp.setSize(bounds.width, bounds.height);
comp.setLocation(0,0);
comp.paint(gfx);
gfx.translate(-bounds.x, -bounds.y);
+ gfx.setClip(oldClip);
}
}
diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java
index 2308dc279..5946a3bdd 100644
--- a/javax/swing/plaf/basic/BasicTableUI.java
+++ b/javax/swing/plaf/basic/BasicTableUI.java
@@ -49,21 +49,23 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
-import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
-import javax.swing.BorderFactory;
import javax.swing.CellRendererPane;
+import javax.swing.DefaultListSelectionModel;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
+import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
@@ -75,9 +77,9 @@ import javax.swing.plaf.TableUI;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
+import javax.swing.table.TableModel;
-public class BasicTableUI
- extends TableUI
+public class BasicTableUI extends TableUI
{
public static ComponentUI createUI(JComponent comp)
{
@@ -93,23 +95,72 @@ public class BasicTableUI
/** The normal cell border. */
Border cellBorder;
- /** The cell border for selected/highlighted cells. */
- Border highlightCellBorder;
-
/** The action bound to KeyStrokes. */
TableAction action;
- class FocusHandler implements FocusListener
+ /**
+ * Listens for changes to the tables properties.
+ */
+ private PropertyChangeListener propertyChangeListener;
+
+ /**
+ * Handles key events for the JTable. Key events should be handled through
+ * the InputMap/ActionMap mechanism since JDK1.3. This class is only there
+ * for backwards compatibility.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ public class KeyHandler implements KeyListener
+ {
+
+ /**
+ * Receives notification that a key has been pressed and released.
+ *
+ * @param event the key event
+ */
+ public void keyTyped(KeyEvent event)
+ {
+ // Key events should be handled through the InputMap/ActionMap mechanism
+ // since JDK1.3. This class is only there for backwards compatibility.
+ }
+
+ /**
+ * Receives notification that a key has been pressed.
+ *
+ * @param event the key event
+ */
+ public void keyPressed(KeyEvent event)
+ {
+ // Key events should be handled through the InputMap/ActionMap mechanism
+ // since JDK1.3. This class is only there for backwards compatibility.
+ }
+
+ /**
+ * Receives notification that a key has been released.
+ *
+ * @param event the key event
+ */
+ public void keyReleased(KeyEvent event)
+ {
+ // Key events should be handled through the InputMap/ActionMap mechanism
+ // since JDK1.3. This class is only there for backwards compatibility.
+ }
+ }
+
+ public class FocusHandler implements FocusListener
{
public void focusGained(FocusEvent e)
{
+ // TODO: Implement this properly.
}
+
public void focusLost(FocusEvent e)
{
+ // TODO: Implement this properly.
}
}
- class MouseInputHandler implements MouseInputListener
+ public class MouseInputHandler implements MouseInputListener
{
Point begin, curr;
@@ -145,54 +196,123 @@ public class BasicTableUI
public void mouseClicked(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
+
public void mouseDragged(MouseEvent e)
{
- curr = new Point(e.getX(), e.getY());
- updateSelection(e.isControlDown());
+ if (table.isEnabled())
+ {
+ curr = new Point(e.getX(), e.getY());
+ updateSelection(e.isControlDown());
+ }
}
+
public void mouseEntered(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
+
public void mouseExited(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
+
public void mouseMoved(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
+
public void mousePressed(MouseEvent e)
{
- ListSelectionModel rowModel = table.getSelectionModel();
- ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
- int rowLead = rowModel.getLeadSelectionIndex();
- int colLead = colModel.getLeadSelectionIndex();
+ if (table.isEnabled())
+ {
+ ListSelectionModel rowModel = table.getSelectionModel();
+ ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
+ int rowLead = rowModel.getLeadSelectionIndex();
+ int colLead = colModel.getLeadSelectionIndex();
- begin = new Point(e.getX(), e.getY());
- curr = new Point(e.getX(), e.getY());
- //if control is pressed and the cell is already selected, deselect it
- if (e.isControlDown() && table.
- isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin)))
- {
- table.getSelectionModel().
- removeSelectionInterval(table.rowAtPoint(begin),
- table.rowAtPoint(begin));
- table.getColumnModel().getSelectionModel().
- removeSelectionInterval(table.columnAtPoint(begin),
- table.columnAtPoint(begin));
- }
- else
- updateSelection(e.isControlDown());
+ begin = new Point(e.getX(), e.getY());
+ curr = new Point(e.getX(), e.getY());
+ //if control is pressed and the cell is already selected, deselect it
+ if (e.isControlDown() && table.
+ isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin)))
+ {
+ table.getSelectionModel().
+ removeSelectionInterval(table.rowAtPoint(begin),
+ table.rowAtPoint(begin));
+ table.getColumnModel().getSelectionModel().
+ removeSelectionInterval(table.columnAtPoint(begin),
+ table.columnAtPoint(begin));
+ }
+ else
+ updateSelection(e.isControlDown());
- // If we were editing, but the moved to another cell, stop editing
- if (rowLead != rowModel.getLeadSelectionIndex() ||
- colLead != colModel.getLeadSelectionIndex())
- if (table.isEditing())
- table.editingStopped(new ChangeEvent(e));
+ // If we were editing, but the moved to another cell, stop editing
+ if (rowLead != rowModel.getLeadSelectionIndex() ||
+ colLead != colModel.getLeadSelectionIndex())
+ if (table.isEditing())
+ table.editingStopped(new ChangeEvent(e));
+ }
}
+
public void mouseReleased(MouseEvent e)
{
- begin = null;
- curr = null;
+ if (table.isEnabled())
+ {
+ begin = null;
+ curr = null;
+ }
+ }
+ }
+
+ /**
+ * Listens for changes to the model property of the JTable and adjusts some
+ * settings.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ private class PropertyChangeHandler implements PropertyChangeListener
+ {
+ /**
+ * Receives notification if one of the JTable's properties changes.
+ *
+ * @param ev the property change event
+ */
+ public void propertyChange(PropertyChangeEvent ev)
+ {
+ String propName = ev.getPropertyName();
+ if (propName.equals("model"))
+ {
+ ListSelectionModel rowSel = table.getSelectionModel();
+ rowSel.clearSelection();
+ ListSelectionModel colSel = table.getColumnModel().getSelectionModel();
+ colSel.clearSelection();
+ TableModel model = table.getModel();
+
+ // Adjust lead and anchor selection indices of the row and column
+ // selection models.
+ if (model.getRowCount() > 0)
+ {
+ rowSel.setAnchorSelectionIndex(0);
+ rowSel.setLeadSelectionIndex(0);
+ }
+ else
+ {
+ rowSel.setAnchorSelectionIndex(-1);
+ rowSel.setLeadSelectionIndex(-1);
+ }
+ if (model.getColumnCount() > 0)
+ {
+ colSel.setAnchorSelectionIndex(0);
+ colSel.setLeadSelectionIndex(0);
+ }
+ else
+ {
+ colSel.setAnchorSelectionIndex(-1);
+ colSel.setLeadSelectionIndex(-1);
+ }
+ }
}
}
@@ -206,6 +326,17 @@ public class BasicTableUI
return new MouseInputHandler();
}
+
+ /**
+ * Creates and returns a key listener for the JTable.
+ *
+ * @return a key listener for the JTable
+ */
+ protected KeyListener createKeyListener()
+ {
+ return new KeyHandler();
+ }
+
/**
* Return the maximum size of the table. The maximum height is the row
* height times the number of rows. The maximum width is the sum of
@@ -255,47 +386,13 @@ public class BasicTableUI
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- table.setFont(defaults.getFont("Table.font"));
- table.setGridColor(defaults.getColor("Table.gridColor"));
- table.setForeground(defaults.getColor("Table.foreground"));
- table.setBackground(defaults.getColor("Table.background"));
- table.setSelectionForeground(defaults.getColor("Table.selectionForeground"));
- table.setSelectionBackground(defaults.getColor("Table.selectionBackground"));
+ LookAndFeel.installColorsAndFont(table, "Table.background",
+ "Table.foreground", "Table.font");
+ table.setGridColor(UIManager.getColor("Table.gridColor"));
+ table.setSelectionForeground(UIManager.getColor("Table.selectionForeground"));
+ table.setSelectionBackground(UIManager.getColor("Table.selectionBackground"));
table.setOpaque(true);
-
- highlightCellBorder = defaults.getBorder("Table.focusCellHighlightBorder");
- cellBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
- }
-
- private int convertModifiers(int mod)
- {
- if ((mod & KeyEvent.SHIFT_DOWN_MASK) != 0)
- {
- mod |= KeyEvent.SHIFT_MASK;
- mod &= ~KeyEvent.SHIFT_DOWN_MASK;
- }
- if ((mod & KeyEvent.CTRL_DOWN_MASK) != 0)
- {
- mod |= KeyEvent.CTRL_MASK;
- mod &= ~KeyEvent.CTRL_DOWN_MASK;
- }
- if ((mod & KeyEvent.META_DOWN_MASK) != 0)
- {
- mod |= KeyEvent.META_MASK;
- mod &= ~KeyEvent.META_DOWN_MASK;
- }
- if ((mod & KeyEvent.ALT_DOWN_MASK) != 0)
- {
- mod |= KeyEvent.ALT_MASK;
- mod &= ~KeyEvent.ALT_DOWN_MASK;
- }
- if ((mod & KeyEvent.ALT_GRAPH_DOWN_MASK) != 0)
- {
- mod |= KeyEvent.ALT_GRAPH_MASK;
- mod &= ~KeyEvent.ALT_GRAPH_DOWN_MASK;
- }
- return mod;
+ rendererPane = new CellRendererPane();
}
protected void installKeyboardActions()
@@ -308,23 +405,17 @@ public class BasicTableUI
action = new TableAction();
Object keys[] = ancestorMap.allKeys();
// Register key bindings in the UI InputMap-ActionMap pair
- // Note that we register key bindings with both the old and new modifier
- // masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on.
for (int i = 0; i < keys.length; i++)
{
- parentInputMap.put(KeyStroke.getKeyStroke
- (((KeyStroke)keys[i]).getKeyCode(), convertModifiers
- (((KeyStroke)keys[i]).getModifiers())),
- (String)ancestorMap.get((KeyStroke)keys[i]));
+ KeyStroke stroke = (KeyStroke)keys[i];
+ String actionString = (String) ancestorMap.get(stroke);
- parentInputMap.put(KeyStroke.getKeyStroke
- (((KeyStroke)keys[i]).getKeyCode(),
- ((KeyStroke)keys[i]).getModifiers()),
- (String)ancestorMap.get((KeyStroke)keys[i]));
+ parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(),
+ stroke.getModifiers()),
+ actionString);
- parentActionMap.put
- ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy
- (action, (String)ancestorMap.get((KeyStroke)keys[i])));
+ parentActionMap.put (actionString,
+ new ActionListenerProxy (action, actionString));
}
// Set the UI InputMap-ActionMap pair to be the parents of the
@@ -383,8 +474,8 @@ public class BasicTableUI
*/
public void actionPerformed (ActionEvent e)
{
- ListSelectionModel rowModel = table.getSelectionModel();
- ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
+ DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel();
+ DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel();
int rowLead = rowModel.getLeadSelectionIndex();
int rowMax = table.getModel().getRowCount() - 1;
@@ -392,74 +483,75 @@ public class BasicTableUI
int colLead = colModel.getLeadSelectionIndex();
int colMax = table.getModel().getColumnCount() - 1;
- if (e.getActionCommand().equals("selectPreviousRowExtendSelection"))
+ String command = e.getActionCommand();
+
+ if (command.equals("selectPreviousRowExtendSelection"))
{
rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0));
colModel.setLeadSelectionIndex(colLead);
}
- else if (e.getActionCommand().equals("selectLastColumn"))
+ else if (command.equals("selectLastColumn"))
{
- table.clearSelection();
rowModel.setSelectionInterval(rowLead, rowLead);
colModel.setSelectionInterval(colMax, colMax);
}
- else if (e.getActionCommand().equals("startEditing"))
+ else if (command.equals("startEditing"))
{
if (table.isCellEditable(rowLead, colLead))
table.editCellAt(rowLead,colLead);
}
- else if (e.getActionCommand().equals("selectFirstRowExtendSelection"))
+ else if (command.equals("selectFirstRowExtendSelection"))
{
rowModel.setLeadSelectionIndex(0);
colModel.setLeadSelectionIndex(colLead);
}
- else if (e.getActionCommand().equals("selectFirstColumn"))
+ else if (command.equals("selectFirstColumn"))
{
rowModel.setSelectionInterval(rowLead, rowLead);
colModel.setSelectionInterval(0, 0);
}
- else if (e.getActionCommand().equals("selectFirstColumnExtendSelection"))
+ else if (command.equals("selectFirstColumnExtendSelection"))
{
colModel.setLeadSelectionIndex(0);
rowModel.setLeadSelectionIndex(rowLead);
- }
- else if (e.getActionCommand().equals("selectLastRow"))
+ }
+ else if (command.equals("selectLastRow"))
{
rowModel.setSelectionInterval(rowMax,rowMax);
colModel.setSelectionInterval(colLead, colLead);
}
- else if (e.getActionCommand().equals("selectNextRowExtendSelection"))
+ else if (command.equals("selectNextRowExtendSelection"))
{
rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax));
colModel.setLeadSelectionIndex(colLead);
}
- else if (e.getActionCommand().equals("selectFirstRow"))
+ else if (command.equals("selectFirstRow"))
{
rowModel.setSelectionInterval(0,0);
colModel.setSelectionInterval(colLead, colLead);
}
- else if (e.getActionCommand().equals("selectNextColumnExtendSelection"))
+ else if (command.equals("selectNextColumnExtendSelection"))
{
colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax));
rowModel.setLeadSelectionIndex(rowLead);
}
- else if (e.getActionCommand().equals("selectLastColumnExtendSelection"))
+ else if (command.equals("selectLastColumnExtendSelection"))
{
colModel.setLeadSelectionIndex(colMax);
rowModel.setLeadSelectionIndex(rowLead);
}
- else if (e.getActionCommand().equals("selectPreviousColumnExtendSelection"))
+ else if (command.equals("selectPreviousColumnExtendSelection"))
{
colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0));
rowModel.setLeadSelectionIndex(rowLead);
}
- else if (e.getActionCommand().equals("selectNextRow"))
+ else if (command.equals("selectNextRow"))
{
rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax),
Math.min(rowLead + 1, rowMax));
colModel.setSelectionInterval(colLead,colLead);
}
- else if (e.getActionCommand().equals("scrollUpExtendSelection"))
+ else if (command.equals("scrollUpExtendSelection"))
{
int target;
if (rowLead == getFirstVisibleRowIndex())
@@ -472,13 +564,13 @@ public class BasicTableUI
rowModel.setLeadSelectionIndex(target);
colModel.setLeadSelectionIndex(colLead);
}
- else if (e.getActionCommand().equals("selectPreviousRow"))
+ else if (command.equals("selectPreviousRow"))
{
rowModel.setSelectionInterval(Math.max(rowLead - 1, 0),
Math.max(rowLead - 1, 0));
colModel.setSelectionInterval(colLead,colLead);
}
- else if (e.getActionCommand().equals("scrollRightChangeSelection"))
+ else if (command.equals("scrollRightChangeSelection"))
{
int target;
if (colLead == getLastVisibleColumnIndex())
@@ -491,13 +583,13 @@ public class BasicTableUI
colModel.setSelectionInterval(target, target);
rowModel.setSelectionInterval(rowLead, rowLead);
}
- else if (e.getActionCommand().equals("selectPreviousColumn"))
+ else if (command.equals("selectPreviousColumn"))
{
rowModel.setSelectionInterval(rowLead,rowLead);
colModel.setSelectionInterval(Math.max(colLead - 1, 0),
Math.max(colLead - 1, 0));
}
- else if (e.getActionCommand().equals("scrollLeftChangeSelection"))
+ else if (command.equals("scrollLeftChangeSelection"))
{
int target;
if (colLead == getFirstVisibleColumnIndex())
@@ -510,11 +602,11 @@ public class BasicTableUI
colModel.setSelectionInterval(target, target);
rowModel.setSelectionInterval(rowLead, rowLead);
}
- else if (e.getActionCommand().equals("clearSelection"))
+ else if (command.equals("clearSelection"))
{
table.clearSelection();
}
- else if (e.getActionCommand().equals("cancel"))
+ else if (command.equals("cancel"))
{
// FIXME: implement other parts of "cancel" like undo-ing last
// selection. Right now it just calls editingCancelled if
@@ -522,10 +614,10 @@ public class BasicTableUI
if (table.isEditing())
table.editingCanceled(new ChangeEvent("cancel"));
}
- else if (e.getActionCommand().equals("selectNextRowCell")
- || e.getActionCommand().equals("selectPreviousRowCell")
- || e.getActionCommand().equals("selectNextColumnCell")
- || e.getActionCommand().equals("selectPreviousColumnCell"))
+ else if (command.equals("selectNextRowCell")
+ || command.equals("selectPreviousRowCell")
+ || command.equals("selectNextColumnCell")
+ || command.equals("selectPreviousColumnCell"))
{
// If nothing is selected, select the first cell in the table
if (table.getSelectedRowCount() == 0 &&
@@ -561,13 +653,13 @@ public class BasicTableUI
// when you get to the edges of the table.
if (!multColsSelected && !multRowsSelected)
{
- if (e.getActionCommand().indexOf("Column") != -1)
+ if (command.indexOf("Column") != -1)
advanceSingleSelection(colModel, colMax, rowModel, rowMax,
- (e.getActionCommand().equals
+ (command.equals
("selectPreviousColumnCell")));
else
advanceSingleSelection(rowModel, rowMax, colModel, colMax,
- (e.getActionCommand().equals
+ (command.equals
("selectPreviousRowCell")));
return;
}
@@ -588,25 +680,25 @@ public class BasicTableUI
// If there are multiple rows and columns selected, select the next
// cell and wrap at the edges of the selection.
- if (e.getActionCommand().indexOf("Column") != -1)
+ if (command.indexOf("Column") != -1)
advanceMultipleSelection(colModel, colMinSelected, colMaxSelected,
rowModel, rowMinSelected, rowMaxSelected,
- (e.getActionCommand().equals
+ (command.equals
("selectPreviousColumnCell")), true);
else
advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected,
colModel, colMinSelected, colMaxSelected,
- (e.getActionCommand().equals
+ (command.equals
("selectPreviousRowCell")), false);
}
- else if (e.getActionCommand().equals("selectNextColumn"))
+ else if (command.equals("selectNextColumn"))
{
rowModel.setSelectionInterval(rowLead,rowLead);
colModel.setSelectionInterval(Math.min(colLead + 1, colMax),
Math.min(colLead + 1, colMax));
}
- else if (e.getActionCommand().equals("scrollLeftExtendSelection"))
+ else if (command.equals("scrollLeftExtendSelection"))
{
int target;
if (colLead == getFirstVisibleColumnIndex())
@@ -619,7 +711,7 @@ public class BasicTableUI
colModel.setLeadSelectionIndex(target);
rowModel.setLeadSelectionIndex(rowLead);
}
- else if (e.getActionCommand().equals("scrollDownChangeSelection"))
+ else if (command.equals("scrollDownChangeSelection"))
{
int target;
if (rowLead == getLastVisibleRowIndex())
@@ -632,7 +724,7 @@ public class BasicTableUI
rowModel.setSelectionInterval(target, target);
colModel.setSelectionInterval(colLead, colLead);
}
- else if (e.getActionCommand().equals("scrollRightExtendSelection"))
+ else if (command.equals("scrollRightExtendSelection"))
{
int target;
if (colLead == getLastVisibleColumnIndex())
@@ -645,16 +737,16 @@ public class BasicTableUI
colModel.setLeadSelectionIndex(target);
rowModel.setLeadSelectionIndex(rowLead);
}
- else if (e.getActionCommand().equals("selectAll"))
+ else if (command.equals("selectAll"))
{
table.selectAll();
}
- else if (e.getActionCommand().equals("selectLastRowExtendSelection"))
+ else if (command.equals("selectLastRowExtendSelection"))
{
rowModel.setLeadSelectionIndex(rowMax);
colModel.setLeadSelectionIndex(colLead);
}
- else if (e.getActionCommand().equals("scrollDownExtendSelection"))
+ else if (command.equals("scrollDownExtendSelection"))
{
int target;
if (rowLead == getLastVisibleRowIndex())
@@ -666,8 +758,8 @@ public class BasicTableUI
rowModel.setLeadSelectionIndex(target);
colModel.setLeadSelectionIndex(colLead);
- }
- else if (e.getActionCommand().equals("scrollUpChangeSelection"))
+ }
+ else if (command.equals("scrollUpChangeSelection"))
{
int target;
if (rowLead == getFirstVisibleRowIndex())
@@ -680,22 +772,119 @@ public class BasicTableUI
rowModel.setSelectionInterval(target, target);
colModel.setSelectionInterval(colLead, colLead);
}
+ else if (command.equals("selectNextRowChangeLead"))
+ {
+ if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ {
+ // just "selectNextRow"
+ rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax),
+ Math.min(rowLead + 1, rowMax));
+ colModel.setSelectionInterval(colLead,colLead);
+ }
+ else
+ rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax));
+ }
+ else if (command.equals("selectPreviousRowChangeLead"))
+ {
+ if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ {
+ // just selectPreviousRow
+ rowModel.setSelectionInterval(Math.max(rowLead - 1, 0),
+ Math.min(rowLead -1, 0));
+ colModel.setSelectionInterval(colLead,colLead);
+ }
+ else
+ rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0));
+ }
+ else if (command.equals("selectNextColumnChangeLead"))
+ {
+ if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ {
+ // just selectNextColumn
+ rowModel.setSelectionInterval(rowLead,rowLead);
+ colModel.setSelectionInterval(Math.min(colLead + 1, colMax),
+ Math.min(colLead + 1, colMax));
+ }
+ else
+ colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax));
+ }
+ else if (command.equals("selectPreviousColumnChangeLead"))
+ {
+ if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)
+ {
+ // just selectPreviousColumn
+ rowModel.setSelectionInterval(rowLead,rowLead);
+ colModel.setSelectionInterval(Math.max(colLead - 1, 0),
+ Math.max(colLead - 1, 0));
+
+ }
+ else
+ colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0));
+ }
+ else if (command.equals("addToSelection"))
+ {
+ if (!table.isEditing())
+ {
+ int oldRowAnchor = rowModel.getAnchorSelectionIndex();
+ int oldColAnchor = colModel.getAnchorSelectionIndex();
+ rowModel.addSelectionInterval(rowLead, rowLead);
+ colModel.addSelectionInterval(colLead, colLead);
+ rowModel.setAnchorSelectionIndex(oldRowAnchor);
+ colModel.setAnchorSelectionIndex(oldColAnchor);
+ }
+ }
+ else if (command.equals("extendTo"))
+ {
+ rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(),
+ rowLead);
+ colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(),
+ colLead);
+ }
+ else if (command.equals("toggleAndAnchor"))
+ {
+ if (rowModel.isSelectedIndex(rowLead))
+ rowModel.removeSelectionInterval(rowLead, rowLead);
+ else
+ rowModel.addSelectionInterval(rowLead, rowLead);
+
+ if (colModel.isSelectedIndex(colLead))
+ colModel.removeSelectionInterval(colLead, colLead);
+ else
+ colModel.addSelectionInterval(colLead, colLead);
+
+ rowModel.setAnchorSelectionIndex(rowLead);
+ colModel.setAnchorSelectionIndex(colLead);
+ }
else
{
// If we're here that means we bound this TableAction class
// to a keyboard input but we either want to ignore that input
// or we just haven't implemented its action yet.
+
+ // Uncomment the following line to print the names of unused bindings
+ // when their keys are pressed
+
+ // System.out.println ("not implemented: "+e.getActionCommand());
}
- if (table.isEditing() && e.getActionCommand() != "startEditing")
- table.editingCanceled(new ChangeEvent("update"));
- table.repaint();
-
+ // Any commands whose keyStrokes should be used by the Editor should not
+ // cause editing to be stopped: ie, the SPACE sends "addToSelection" but
+ // if the table is in editing mode, the space should not cause us to stop
+ // editing because it should be used by the Editor.
+ if (table.isEditing() && command != "startEditing"
+ && command != "addToSelection")
+ table.editingStopped(new ChangeEvent("update"));
+
table.scrollRectToVisible
(table.getCellRect(rowModel.getLeadSelectionIndex(),
colModel.getLeadSelectionIndex(), false));
+ table.repaint();
}
+ /**
+ * Returns the column index of the first visible column.
+ * @return the column index of the first visible column.
+ */
int getFirstVisibleColumnIndex()
{
ComponentOrientation or = table.getComponentOrientation();
@@ -922,10 +1111,19 @@ public class BasicTableUI
protected void installListeners()
{
- table.addFocusListener(focusListener);
+ if (focusListener == null)
+ focusListener = createFocusListener();
+ table.addFocusListener(focusListener);
+ if (keyListener == null)
+ keyListener = createKeyListener();
table.addKeyListener(keyListener);
+ if (mouseInputListener == null)
+ mouseInputListener = createMouseInputListener();
table.addMouseListener(mouseInputListener);
table.addMouseMotionListener(mouseInputListener);
+ if (propertyChangeListener == null)
+ propertyChangeListener = new PropertyChangeHandler();
+ table.addPropertyChangeListener(propertyChangeListener);
}
protected void uninstallDefaults()
@@ -950,6 +1148,7 @@ public class BasicTableUI
protected void uninstallKeyboardActions()
{
+ // TODO: Implement this properly.
}
protected void uninstallListeners()
@@ -958,13 +1157,13 @@ public class BasicTableUI
table.removeKeyListener(keyListener);
table.removeMouseListener(mouseInputListener);
table.removeMouseMotionListener(mouseInputListener);
+ table.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
}
public void installUI(JComponent comp)
{
table = (JTable)comp;
- focusListener = createFocusListener();
- mouseInputListener = createMouseInputListener();
installDefaults();
installKeyboardActions();
installListeners();
@@ -977,6 +1176,60 @@ public class BasicTableUI
uninstallDefaults();
}
+ /**
+ * Paints a single cell in the table.
+ *
+ * @param g The graphics context to paint in
+ * @param row The row number to paint
+ * @param col The column number to paint
+ * @param bounds The bounds of the cell to paint, assuming a coordinate
+ * system beginning at <code>(0,0)</code> in the upper left corner of the
+ * table
+ * @param rend A cell renderer to paint with
+ * @param data The data to provide to the cell renderer
+ * @param rowLead The lead selection for the rows of the table.
+ * @param colLead The lead selection for the columns of the table.
+ */
+ void paintCell(Graphics g, int row, int col, Rectangle bounds,
+ TableCellRenderer rend, TableModel data,
+ int rowLead, int colLead)
+ {
+ boolean rowSelAllowed = table.getRowSelectionAllowed();
+ boolean colSelAllowed = table.getColumnSelectionAllowed();
+ boolean isSel = false;
+ if (rowSelAllowed && colSelAllowed || !rowSelAllowed && !colSelAllowed)
+ isSel = table.isCellSelected(row, col);
+ else
+ isSel = table.isRowSelected(row) && table.getRowSelectionAllowed()
+ || table.isColumnSelected(col) && table.getColumnSelectionAllowed();
+
+ // Determine the focused cell. The focused cell is the cell at the
+ // leadSelectionIndices of the row and column selection model.
+ ListSelectionModel rowSel = table.getSelectionModel();
+ ListSelectionModel colSel = table.getColumnModel().getSelectionModel();
+ boolean hasFocus = table.hasFocus() && table.isEnabled()
+ && rowSel.getLeadSelectionIndex() == row
+ && colSel.getLeadSelectionIndex() == col;
+
+ Component comp = rend.getTableCellRendererComponent(table,
+ data.getValueAt(row, col),
+ isSel, hasFocus, row, col);
+
+ rendererPane.paintComponent(g, comp, table, bounds);
+
+ // FIXME: this is manual painting of the Caret, why doesn't the
+ // JTextField take care of this itself?
+ if (comp instanceof JTextField)
+ {
+ Rectangle oldClip = g.getClipBounds();
+ g.translate(bounds.x, bounds.y);
+ g.clipRect(0, 0, bounds.width, bounds.height);
+ ((JTextField)comp).getCaret().paint(g);
+ g.translate(-bounds.x, -bounds.y);
+ g.setClip(oldClip);
+ }
+ }
+
public void paint(Graphics gfx, JComponent ignored)
{
int ncols = table.getColumnCount();
@@ -1002,34 +1255,22 @@ public class BasicTableUI
y = y0;
TableColumn col = cols.getColumn(c);
int width = col.getWidth();
- int modelCol = col.getModelIndex();
-
+ int halfGapWidth = gap.width / 2;
+ int halfGapHeight = gap.height / 2;
for (int r = 0; r < nrows && y < ymax; ++r)
{
- Rectangle bounds = new Rectangle(x, y, width, height);
- if (bounds.intersects(clip))
- {
- TableCellRenderer rend = table.getCellRenderer(r, c);
- Component comp = table.prepareRenderer(rend, r, c);
- gfx.translate(x, y);
- comp.setBounds(new Rectangle(0, 0, width, height));
- // Set correct border on cell renderer.
- // Only the lead selection cell gets a border
- if (comp instanceof JComponent)
- {
- if (table.getSelectionModel().getLeadSelectionIndex() == r
- && table.getColumnModel().getSelectionModel().
- getLeadSelectionIndex() == c)
- ((JComponent) comp).setBorder(highlightCellBorder);
- else
- ((JComponent) comp).setBorder(cellBorder);
- }
- comp.paint(gfx);
- if (comp instanceof JTextField)
- ((JTextField)comp).getCaret().paint(gfx);
- gfx.translate(-x, -y);
+ Rectangle bounds = new Rectangle(x + halfGapWidth,
+ y + halfGapHeight + 1,
+ width - gap.width + 1,
+ height - gap.height);
+ if (bounds.intersects(clip))
+ {
+ paintCell(gfx, r, c, bounds, table.getCellRenderer(r, c),
+ table.getModel(),
+ table.getSelectionModel().getLeadSelectionIndex(),
+ table.getColumnModel().getSelectionModel().getLeadSelectionIndex());
}
- y += height;
+ y += height;
}
x += width;
}
@@ -1040,7 +1281,7 @@ public class BasicTableUI
Color grid = table.getGridColor();
- // paint vertical grid lines
+ // paint vertical grid lines
if (grid != null && table.getShowVerticalLines())
{
x = x0;
@@ -1050,7 +1291,7 @@ public class BasicTableUI
for (int c = 0; c < ncols && x < xmax; ++c)
{
x += cols.getColumn(c).getWidth();
- gfx.drawLine(x - gap.width, y0, x - gap.width, ymax);
+ gfx.drawLine(x, y0, x, ymax);
paintedLine = true;
}
gfx.setColor(save);
diff --git a/javax/swing/plaf/basic/BasicTextAreaUI.java b/javax/swing/plaf/basic/BasicTextAreaUI.java
index 4c69f5707..36854e07f 100644
--- a/javax/swing/plaf/basic/BasicTextAreaUI.java
+++ b/javax/swing/plaf/basic/BasicTextAreaUI.java
@@ -39,12 +39,16 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.beans.PropertyChangeEvent;
+
import javax.swing.JComponent;
+import javax.swing.JTextArea;
import javax.swing.UIDefaults;
import javax.swing.plaf.ComponentUI;
import javax.swing.text.Element;
import javax.swing.text.PlainView;
import javax.swing.text.View;
+import javax.swing.text.WrappedPlainView;
public class BasicTextAreaUI extends BasicTextUI
{
@@ -55,11 +59,30 @@ public class BasicTextAreaUI extends BasicTextUI
public BasicTextAreaUI()
{
+ // Nothing to do here.
}
+ /**
+ * Create the view. Returns a WrappedPlainView if the text area
+ * has lineWrap set to true, otherwise returns a PlainView. If
+ * lineWrap is true has to check whether the wrap style is word
+ * or character and return an appropriate WrappedPlainView.
+ *
+ * @param elem the element to create a View for
+ * @return an appropriate View for the element
+ */
public View create(Element elem)
{
- return new PlainView(elem);
+ JTextArea comp = (JTextArea)getComponent();
+ if (comp.getLineWrap())
+ {
+ if (comp.getWrapStyleWord())
+ return new WrappedPlainView(elem, true);
+ else
+ return new WrappedPlainView(elem, false);
+ }
+ else
+ return new PlainView(elem);
}
/**
@@ -71,4 +94,20 @@ public class BasicTextAreaUI extends BasicTextUI
{
return "TextArea";
}
+
+ /**
+ * Receives notification whenever one of the text component's bound
+ * properties changes. This changes the view to WrappedPlainView
+ * if setLineWrap(true) is called, and back to PlainView if
+ * setLineWrap(false) is called.
+ *
+ * @param ev the property change event
+ */
+ protected void propertyChange(PropertyChangeEvent ev)
+ {
+ JTextArea comp = (JTextArea)getComponent();
+ if (ev.getPropertyName() == "lineWrap"
+ || ev.getPropertyName() == "wrapStyleWord")
+ modelChanged();
+ }
}
diff --git a/javax/swing/plaf/basic/BasicTextFieldUI.java b/javax/swing/plaf/basic/BasicTextFieldUI.java
index 07d1691fb..e1422c438 100644
--- a/javax/swing/plaf/basic/BasicTextFieldUI.java
+++ b/javax/swing/plaf/basic/BasicTextFieldUI.java
@@ -79,8 +79,21 @@ public class BasicTextFieldUI extends BasicTextUI
super.installUI(c);
}
+ /**
+ * Receives notification whenever one of the text component's bound
+ * properties changes. Here we check for the editable and enabled
+ * properties and adjust the background color accordingly.
+ *
+ * @param event the property change event
+ */
protected void propertyChange(PropertyChangeEvent event)
{
- // Does nothing by default.
+ if (event.getPropertyName().equals("editable"))
+ {
+ if (textComponent.isEditable())
+ textComponent.setBackground(background);
+ else
+ textComponent.setBackground(inactiveBackground);
+ }
}
}
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
index 2bbf45d9c..225c4a9dd 100644
--- a/javax/swing/plaf/basic/BasicTextUI.java
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -55,6 +55,7 @@ import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -74,7 +75,6 @@ import javax.swing.text.Element;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import javax.swing.text.Keymap;
-import javax.swing.text.PlainView;
import javax.swing.text.Position;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
@@ -93,11 +93,11 @@ public abstract class BasicTextUI extends TextUI
/**
* A {@link DefaultCaret} that implements {@link UIResource}.
*/
- public static class BasicCaret extends DefaultCaret
- implements UIResource
+ public static class BasicCaret extends DefaultCaret implements UIResource
{
public BasicCaret()
{
+ // Nothing to do here.
}
}
@@ -109,6 +109,7 @@ public abstract class BasicTextUI extends TextUI
{
public BasicHighlighter()
{
+ // Nothing to do here.
}
}
@@ -253,10 +254,10 @@ public abstract class BasicTextUI extends TextUI
*
* This is delegated to the real root view.
*
- * @param pos the position of the character in the model
+ * @param position the position of the character in the model
* @param a the area that is occupied by the view
- * @param bias either {@link Position.Bias.Forward} or
- * {@link Position.Bias.Backward} depending on the preferred
+ * @param bias either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward} depending on the preferred
* direction bias. If <code>null</code> this defaults to
* <code>Position.Bias.Forward</code>
*
@@ -333,7 +334,7 @@ public abstract class BasicTextUI extends TextUI
/**
* Receives notifications when properties of the text component change.
*/
- class UpdateHandler implements PropertyChangeListener
+ class PropertyChangeHandler implements PropertyChangeListener
{
/**
* Notifies when a property of the text component changes.
@@ -347,13 +348,8 @@ public abstract class BasicTextUI extends TextUI
// Document changed.
modelChanged();
}
- else if (event.getPropertyName().equals("editable"))
- {
- if (textComponent.isEditable())
- textComponent.setBackground(background);
- else
- textComponent.setBackground(inactiveBackground);
- }
+
+ BasicTextUI.this.propertyChange(event);
}
}
@@ -372,11 +368,10 @@ public abstract class BasicTextUI extends TextUI
*/
public void changedUpdate(DocumentEvent ev)
{
- Dimension size = textComponent.getSize();
- rootView.changedUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ rootView.changedUpdate(ev, getVisibleEditorRect(),
rootView.getViewFactory());
}
-
+
/**
* Notification about a document insert event.
*
@@ -384,12 +379,8 @@ public abstract class BasicTextUI extends TextUI
*/
public void insertUpdate(DocumentEvent ev)
{
- Dimension size = textComponent.getSize();
- rootView.insertUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ rootView.insertUpdate(ev, getVisibleEditorRect(),
rootView.getViewFactory());
- int caretPos = textComponent.getCaretPosition();
- if (caretPos >= ev.getOffset())
- textComponent.setCaretPosition(caretPos + ev.getLength());
}
/**
@@ -399,12 +390,8 @@ public abstract class BasicTextUI extends TextUI
*/
public void removeUpdate(DocumentEvent ev)
{
- Dimension size = textComponent.getSize();
- rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ rootView.removeUpdate(ev, getVisibleEditorRect(),
rootView.getViewFactory());
- int caretPos = textComponent.getCaretPosition();
- if (caretPos >= ev.getOffset())
- textComponent.setCaretPosition(ev.getOffset());
}
}
@@ -427,7 +414,7 @@ public abstract class BasicTextUI extends TextUI
/**
* Receives notification when the model changes.
*/
- UpdateHandler updateHandler = new UpdateHandler();
+ PropertyChangeHandler updateHandler = new PropertyChangeHandler();
/** The DocumentEvent handler. */
DocumentHandler documentHandler = new DocumentHandler();
@@ -449,6 +436,7 @@ public abstract class BasicTextUI extends TextUI
*/
public BasicTextUI()
{
+ // Nothing to do here.
}
/**
@@ -526,19 +514,18 @@ public abstract class BasicTextUI extends TextUI
textComponent.setHighlighter(createHighlighter());
String prefix = getPropertyPrefix();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- textComponent.setMargin(defaults.getInsets(prefix + ".margin"));
- textComponent.setBorder(defaults.getBorder(prefix + ".border"));
- textComponent.setFont(defaults.getFont(prefix + ".font"));
+ LookAndFeel.installColorsAndFont(textComponent, prefix + ".background",
+ prefix + ".foreground", prefix + ".font");
+ LookAndFeel.installBorder(textComponent, prefix + ".border");
+ textComponent.setMargin(UIManager.getInsets(prefix + ".margin"));
- caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate"));
+ caret.setBlinkRate(UIManager.getInt(prefix + ".caretBlinkRate"));
// Fetch the colors for enabled/disabled text components.
- background = defaults.getColor(prefix + ".background");
- inactiveBackground = defaults.getColor(prefix + ".inactiveBackground");
- textComponent.setForeground(defaults.getColor(prefix + ".foreground"));
+ inactiveBackground = UIManager.getColor(prefix + ".inactiveBackground");
textComponent.setDisabledTextColor
- (defaults.getColor(prefix + ".inactiveForeground"));
+ (UIManager.getColor(prefix + ".inactiveForeground"));
+ textComponent.setSelectedTextColor(UIManager.getColor(prefix + ".selectionForeground"));
}
/**
@@ -824,8 +811,8 @@ public abstract class BasicTextUI extends TextUI
{
// This method does nothing. All the background filling is done by the
// ComponentUI update method. However, the method is called by paint
- // to provide a way for subclasses to draw something different (e.g. background
- // images etc) on the background.
+ // to provide a way for subclasses to draw something different (e.g.
+ // background images etc) on the background.
}
/**
@@ -912,10 +899,10 @@ public abstract class BasicTextUI extends TextUI
/**
* Maps a position in the document into the coordinate space of the View.
* The output rectangle usually reflects the font height but has a width
- * of zero. A bias of {@link Position.Bias.Forward} is used in this method.
+ * of zero. A bias of {@link Position.Bias#Forward} is used in this method.
*
+ * @param t the text component
* @param pos the position of the character in the model
- * @param a the area that is occupied by the view
*
* @return a rectangle that gives the location of the document position
* inside the view coordinate space
@@ -935,10 +922,10 @@ public abstract class BasicTextUI extends TextUI
* The output rectangle usually reflects the font height but has a width
* of zero.
*
+ * @param t the text component
* @param pos the position of the character in the model
- * @param a the area that is occupied by the view
- * @param bias either {@link Position.Bias.Forward} or
- * {@link Position.Bias.Backward} depending on the preferred
+ * @param bias either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward} depending on the preferred
* direction bias. If <code>null</code> this defaults to
* <code>Position.Bias.Forward</code>
*
@@ -984,7 +971,7 @@ public abstract class BasicTextUI extends TextUI
*/
public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)
{
- return 0; // FIXME: Implement me.
+ return rootView.viewToModel(pt.x, pt.y, getVisibleEditorRect(), biasReturn);
}
/**
@@ -1030,7 +1017,7 @@ public abstract class BasicTextUI extends TextUI
int height = textComponent.getHeight();
if (width <= 0 || height <= 0)
- return null;
+ return new Rectangle(0, 0, 0, 0);
Insets insets = textComponent.getInsets();
return new Rectangle(insets.left, insets.top,
@@ -1047,6 +1034,8 @@ public abstract class BasicTextUI extends TextUI
{
rootView.setView(view);
view.setParent(rootView);
+ textComponent.revalidate();
+ textComponent.repaint();
}
/**
@@ -1070,4 +1059,17 @@ public abstract class BasicTextUI extends TextUI
View view = factory.create(elem);
setView(view);
}
+
+ /**
+ * Receives notification whenever one of the text component's bound
+ * properties changes. This default implementation does nothing.
+ * It is a hook that enables subclasses to react to property changes
+ * on the text component.
+ *
+ * @param ev the property change event
+ */
+ protected void propertyChange(PropertyChangeEvent ev)
+ {
+ // The default implementation does nothing.
+ }
}
diff --git a/javax/swing/plaf/basic/BasicToggleButtonUI.java b/javax/swing/plaf/basic/BasicToggleButtonUI.java
index 9106b0b66..896ea0c89 100644
--- a/javax/swing/plaf/basic/BasicToggleButtonUI.java
+++ b/javax/swing/plaf/basic/BasicToggleButtonUI.java
@@ -38,7 +38,13 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.AbstractButton;
import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
import javax.swing.plaf.ComponentUI;
public class BasicToggleButtonUI extends BasicButtonUI
@@ -58,5 +64,62 @@ public class BasicToggleButtonUI extends BasicButtonUI
{
return "ToggleButton.";
}
-}
+ /**
+ * Paint the component, which is an {@link AbstractButton}, according to
+ * its current state.
+ *
+ * @param g The graphics context to paint with
+ * @param c The component to paint the state of
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+
+ Rectangle tr = new Rectangle();
+ Rectangle ir = new Rectangle();
+ Rectangle vr = new Rectangle();
+
+ Font f = c.getFont();
+
+ g.setFont(f);
+
+ if (b.isBorderPainted())
+ SwingUtilities.calculateInnerArea(b, vr);
+ else
+ vr = SwingUtilities.getLocalBounds(b);
+ String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
+ b.getText(),
+ currentIcon(b),
+ b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ vr, ir, tr,
+ b.getIconTextGap()
+ + defaultTextShiftOffset);
+
+ if ((b.getModel().isArmed() && b.getModel().isPressed())
+ || b.isSelected())
+ paintButtonPressed(g, b);
+
+ paintIcon(g, b, ir);
+ if (text != null)
+ paintText(g, b, tr, text);
+ if (b.isFocusOwner() && b.isFocusPainted())
+ paintFocus(g, b, vr, tr, ir);
+ }
+
+ /**
+ * Paints the icon for the toggle button. This delegates to
+ * {@link BasicButtonUI#paintIcon(Graphics, JComponent, Rectangle)}.
+ *
+ * @param g the graphics context
+ * @param b the button to paint the icon for
+ * @param iconRect the area allocated for the icon
+ */
+ protected void paintIcon(Graphics g, AbstractButton b, Rectangle iconRect)
+ {
+ super.paintIcon(g, b, iconRect);
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java b/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
index db29fdca5..79cf0b0c2 100644
--- a/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
+++ b/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
@@ -43,7 +43,6 @@ import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JSeparator;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
@@ -73,9 +72,7 @@ public class BasicToolBarSeparatorUI extends BasicSeparatorUI
*/
protected void installDefaults(JSeparator s)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- size = defaults.getDimension("ToolBar.separatorSize");
+ size = UIManager.getDimension("ToolBar.separatorSize");
}
/**
diff --git a/javax/swing/plaf/basic/BasicToolBarUI.java b/javax/swing/plaf/basic/BasicToolBarUI.java
index 807582d9f..d02922f74 100644
--- a/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -65,10 +65,11 @@ import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JToolBar;
+import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
import javax.swing.RootPaneContainer;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.MouseInputListener;
@@ -133,6 +134,26 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
protected FocusListener toolBarFocusListener;
/**
+ * @deprecated since JDK1.3.
+ */
+ protected KeyStroke leftKey;
+
+ /**
+ * @deprecated since JDK1.3.
+ */
+ protected KeyStroke rightKey;
+
+ /**
+ * @deprecated since JDK1.3.
+ */
+ protected KeyStroke upKey;
+
+ /**
+ * @deprecated since JDK1.3.
+ */
+ protected KeyStroke downKey;
+
+ /**
* The floating window that is responsible for holding the JToolBar when it
* is dragged outside of its original parent.
*/
@@ -566,18 +587,15 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- toolBar.setBorder(new ToolBarBorder());
- toolBar.setBackground(defaults.getColor("ToolBar.background"));
- toolBar.setForeground(defaults.getColor("ToolBar.foreground"));
- toolBar.setFont(defaults.getFont("ToolBar.font"));
+ LookAndFeel.installBorder(toolBar, "ToolBar.border");
+ LookAndFeel.installColorsAndFont(toolBar, "ToolBar.background",
+ "ToolBar.foreground", "ToolBar.font");
- dockingBorderColor = defaults.getColor("ToolBar.dockingForeground");
- dockingColor = defaults.getColor("ToolBar.dockingBackground");
+ dockingBorderColor = UIManager.getColor("ToolBar.dockingForeground");
+ dockingColor = UIManager.getColor("ToolBar.dockingBackground");
- floatingBorderColor = defaults.getColor("ToolBar.floatingForeground");
- floatingColor = defaults.getColor("ToolBar.floatingBackground");
+ floatingBorderColor = UIManager.getColor("ToolBar.floatingForeground");
+ floatingColor = UIManager.getColor("ToolBar.floatingBackground");
}
/**
@@ -591,10 +609,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
/**
* This method installs listeners for the JToolBar.
- *
- * @param toolbar The JToolBar to register listeners for.
*/
- protected void installListeners(JToolBar toolbar)
+ protected void installListeners()
{
dockingListener = createDockingListener();
toolBar.addMouseListener(dockingListener);
@@ -694,7 +710,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
toolBar.setOpaque(true);
installDefaults();
installComponents();
- installListeners(toolBar);
+ installListeners();
installKeyboardActions();
}
}
@@ -1000,6 +1016,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*/
public void mouseMoved(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
diff --git a/javax/swing/plaf/basic/BasicToolTipUI.java b/javax/swing/plaf/basic/BasicToolTipUI.java
index b7a08aa72..5cec2e333 100644
--- a/javax/swing/plaf/basic/BasicToolTipUI.java
+++ b/javax/swing/plaf/basic/BasicToolTipUI.java
@@ -1,5 +1,5 @@
/* BasicToolTipUI.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,20 +39,18 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.Color;
-import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
+import java.awt.Toolkit;
import javax.swing.JComponent;
import javax.swing.JToolTip;
+import javax.swing.LookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ToolTipUI;
@@ -61,58 +59,12 @@ import javax.swing.plaf.ToolTipUI;
*/
public class BasicToolTipUI extends ToolTipUI
{
- /** The default Border around the JToolTip. */
- private static Border defaultBorder = new Border()
- {
- // FIXME: This needs to go into Basic Look and Feel
- // defaults.
- /**
- * This method returns the border insets.
- *
- * @param c The Component to find Border insets for.
- *
- * @return The Border insets.
- */
- public Insets getBorderInsets(Component c)
- {
- return new Insets(4, 4, 4, 4);
- }
+ /** The shared instance of BasicToolTipUI used for all ToolTips. */
+ private static BasicToolTipUI shared;
- /**
- * This method returns whether the border is opaque.
- *
- * @return Whether the border is opaque.
- */
- public boolean isBorderOpaque()
- {
- return false;
- }
-
- /**
- * This method paints the border.
- *
- * @param c The Component to paint this border around.
- * @param g The Graphics object to paint with.
- * @param x The x coordinate to start painting at.
- * @param y The y coordinate to start painting at.
- * @param w The width of the Component.
- * @param h The height of the Component.
- */
- public void paintBorder(Component c, Graphics g, int x, int y, int w,
- int h)
- {
- Color saved = g.getColor();
- g.setColor(Color.BLACK);
-
- g.drawRect(0, 0, w - 1, h - 1);
-
- g.setColor(saved);
- }
- };
-
- /** The shared instance of BasicToolTipUI used for all ToolTips. */
- private static BasicToolTipUI shared;
+ /** The tooltip's text */
+ private String text;
/**
* Creates a new BasicToolTipUI object.
@@ -124,7 +76,7 @@ public class BasicToolTipUI extends ToolTipUI
/**
* This method creates a new BasicToolTip UI for the given
- * JComponent.
+ * JComponent.
*
* @param c The JComponent to create a UI for.
*
@@ -132,9 +84,9 @@ public class BasicToolTipUI extends ToolTipUI
*/
public static ComponentUI createUI(JComponent c)
{
- if (shared == null)
- shared = new BasicToolTipUI();
- return shared;
+ if (shared == null)
+ shared = new BasicToolTipUI();
+ return shared;
}
/**
@@ -171,12 +123,16 @@ public class BasicToolTipUI extends ToolTipUI
public Dimension getPreferredSize(JComponent c)
{
JToolTip tip = (JToolTip) c;
+ FontMetrics fm;
+ Toolkit g = tip.getToolkit();
+ text = tip.getTipText();
+
Rectangle vr = new Rectangle();
Rectangle ir = new Rectangle();
Rectangle tr = new Rectangle();
Insets insets = tip.getInsets();
- FontMetrics fm = tip.getToolkit().getFontMetrics(tip.getFont());
- SwingUtilities.layoutCompoundLabel(tip, fm, tip.getTipText(), null,
+ fm = g.getFontMetrics(tip.getFont());
+ SwingUtilities.layoutCompoundLabel(tip, fm, text, null,
SwingConstants.CENTER,
SwingConstants.CENTER,
SwingConstants.CENTER,
@@ -192,11 +148,9 @@ public class BasicToolTipUI extends ToolTipUI
*/
protected void installDefaults(JComponent c)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- c.setBackground(defaults.getColor("ToolTip.background"));
- c.setForeground(defaults.getColor("ToolTip.foreground"));
- c.setFont(defaults.getFont("ToolTip.font"));
- c.setBorder(defaultBorder);
+ LookAndFeel.installColorsAndFont(c, "ToolTip.background",
+ "ToolTip.foreground", "ToolTip.font");
+ LookAndFeel.installBorder(c, "ToolTip.border");
}
/**
@@ -206,6 +160,7 @@ public class BasicToolTipUI extends ToolTipUI
*/
protected void installListeners(JComponent c)
{
+ // TODO: Implement this properly.
}
/**
@@ -231,6 +186,7 @@ public class BasicToolTipUI extends ToolTipUI
JToolTip tip = (JToolTip) c;
String text = tip.getTipText();
+ Toolkit t = tip.getToolkit();
if (text == null)
return;
@@ -238,19 +194,19 @@ public class BasicToolTipUI extends ToolTipUI
vr = SwingUtilities.calculateInnerArea(tip, vr);
Rectangle ir = new Rectangle();
Rectangle tr = new Rectangle();
- FontMetrics fm = tip.getToolkit().getFontMetrics(tip.getFont());
- SwingUtilities.layoutCompoundLabel(tip, fm, tip.getTipText(), null,
+ FontMetrics fm = t.getFontMetrics(tip.getFont());
+ int ascent = fm.getAscent();
+ SwingUtilities.layoutCompoundLabel(tip, fm, text, null,
SwingConstants.CENTER,
SwingConstants.CENTER,
SwingConstants.CENTER,
SwingConstants.CENTER, vr, ir, tr, 0);
-
Color saved = g.getColor();
g.setColor(Color.BLACK);
- g.drawString(text, vr.x, vr.y + fm.getAscent());
+ g.drawString(text, vr.x, vr.y + ascent);
- g.setColor(saved);
+ g.setColor(saved);
}
/**
@@ -273,6 +229,7 @@ public class BasicToolTipUI extends ToolTipUI
*/
protected void uninstallListeners(JComponent c)
{
+ // TODO: Implement this properly.
}
/**
diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java
index df763a83d..4f4646c8a 100644
--- a/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/javax/swing/plaf/basic/BasicTreeUI.java
@@ -78,6 +78,7 @@ import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.UIDefaults;
@@ -111,11 +112,11 @@ import javax.swing.tree.TreeSelectionModel;
* the Basic look and feel.
*
* @see javax.swing.JTree
- * @author Sascha Brawer (brawer@dandelis.ch)
+ *
* @author Lillian Angel (langel@redhat.com)
+ * @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class BasicTreeUI
- extends TreeUI
+public class BasicTreeUI extends TreeUI
{
/** Collapse Icon for the tree. */
protected transient Icon collapsedIcon;
@@ -137,9 +138,6 @@ public class BasicTreeUI
*/
protected int totalChildIndent;
- /** Minimum preferred size. */
- protected Dimension preferredMinsize;
-
/** Index of the row that was last selected. */
protected int lastSelectedRow;
@@ -227,7 +225,7 @@ public class BasicTreeUI
/** Set to true if the editor has a different size than the renderer. */
protected boolean editorHasDifferentSize;
-
+
/** The action listener for the editor's Timer. */
Timer editorTimer = new EditorUpdateTimer();
@@ -242,16 +240,22 @@ public class BasicTreeUI
/** The bounds of the current cell. */
Rectangle bounds;
+
+ /** The current path of the visible nodes in the tree. */
+ TreePath currentVisiblePath;
+
+ /** The gap between the icon and text. */
+ int gap = 4;
/** Listeners */
private PropertyChangeListener propertyChangeListener;
private FocusListener focusListener;
private TreeSelectionListener treeSelectionListener;
- private MouseInputListener mouseInputListener;
+ private MouseListener mouseListener;
private KeyListener keyListener;
private PropertyChangeListener selectionModelPropertyChangeListener;
private ComponentListener componentListener;
- private CellEditorListener cellEditorListener;
+ CellEditorListener cellEditorListener;
private TreeExpansionListener treeExpansionListener;
private TreeModelListener treeModelListener;
@@ -260,6 +264,7 @@ public class BasicTreeUI
*/
public BasicTreeUI()
{
+ validCachedPreferredSize = false;
drawingCache = new Hashtable();
nodeDimensions = createNodeDimensions();
configureLayoutCache();
@@ -267,7 +272,7 @@ public class BasicTreeUI
propertyChangeListener = createPropertyChangeListener();
focusListener = createFocusListener();
treeSelectionListener = createTreeSelectionListener();
- mouseInputListener = new MouseInputHandler(null, null, null);
+ mouseListener = createMouseListener();
keyListener = createKeyListener();
selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener();
componentListener = createComponentListener();
@@ -329,7 +334,7 @@ public class BasicTreeUI
*
* @return the indent value for the left child.
*/
- public int getLeftChildIndent(int newAmount)
+ public int getLeftChildIndent()
{
return leftChildIndent;
}
@@ -625,6 +630,7 @@ public class BasicTreeUI
if (treeModel != null)
{
Object root = treeModel.getRoot();
+
if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root)))
root = getNextNode(root);
@@ -646,20 +652,11 @@ public class BasicTreeUI
*/
public TreePath getPathForRow(JTree tree, int row)
{
- if (treeModel != null)
+ if (treeModel != null && currentVisiblePath != null)
{
- Object node = treeModel.getRoot();
- if (!tree.isRootVisible()
- && tree.isExpanded(new TreePath(getPathToRoot(node, 0))))
- node = getNextNode(node);
-
- for (int i = 0; i < row; i++)
- node = getNextVisibleNode(node);
-
- if (node == null)
- return null;
-
- return new TreePath(getPathToRoot(node, 0));
+ Object[] nodes = currentVisiblePath.getPath();
+ if (row < nodes.length)
+ return new TreePath(getPathToRoot(nodes[row], 0));
}
return null;
}
@@ -680,13 +677,18 @@ public class BasicTreeUI
{
int row = 0;
Object dest = path.getLastPathComponent();
- Object curr = treeModel.getRoot();
- while (curr != null && !curr.equals(dest))
+ int rowCount = getRowCount(tree);
+ if (currentVisiblePath != null)
{
- ++row;
- curr = getNextVisibleNode(curr);
+ Object[] nodes = currentVisiblePath.getPath();
+ while (row < rowCount)
+ {
+ if (dest.equals(nodes[row]))
+ return row;
+ row++;
+ }
}
- return row;
+ return -1;
}
/**
@@ -698,21 +700,9 @@ public class BasicTreeUI
*/
public int getRowCount(JTree tree)
{
- int count = 0;
- if (treeModel != null)
- {
- Object node = treeModel.getRoot();
- if (!tree.isRootVisible()
- && tree.isExpanded(new TreePath((getPathToRoot(node, 0)))))
- node = getNextNode(node);
-
- while (node != null)
- {
- count++;
- node = getNextVisibleNode(node);
- }
- }
- return count;
+ if (currentVisiblePath != null)
+ return currentVisiblePath.getPathCount();
+ return 0;
}
/**
@@ -733,7 +723,7 @@ public class BasicTreeUI
{
// FIXME: what if root is hidden? should not depend on (0,0)
// should start counting rows from where root is.
-
+
int row = Math.round(y / getRowHeight());
TreePath path = getPathForRow(tree, row);
@@ -820,6 +810,7 @@ public class BasicTreeUI
*/
protected void prepareForUIInstall()
{
+ // TODO: Implement this properly.
}
/**
@@ -828,6 +819,7 @@ public class BasicTreeUI
*/
protected void completeUIInstall()
{
+ // TODO: Implement this properly.
}
/**
@@ -836,6 +828,7 @@ public class BasicTreeUI
*/
protected void completeUIUninstall()
{
+ // TODO: Implement this properly.
}
/**
@@ -1026,7 +1019,7 @@ public class BasicTreeUI
tree.removePropertyChangeListener(propertyChangeListener);
tree.removeFocusListener(focusListener);
tree.removeTreeSelectionListener(treeSelectionListener);
- tree.removeMouseListener(mouseInputListener);
+ tree.removeMouseListener(mouseListener);
tree.removeKeyListener(keyListener);
tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
tree.removeComponentListener(componentListener);
@@ -1044,6 +1037,7 @@ public class BasicTreeUI
*/
protected void uninstallKeyboardActions()
{
+ // TODO: Implement this properly.
}
/**
@@ -1087,8 +1081,7 @@ public class BasicTreeUI
protected void updateLayoutCacheExpandedNodes()
{
if (treeModel != null)
- updateExpandedDescendants(new TreePath(getPathToRoot(treeModel.
- getRoot(), 0)));
+ updateExpandedDescendants(new TreePath(treeModel.getRoot()));
}
/**
@@ -1144,7 +1137,14 @@ public class BasicTreeUI
protected void updateRenderer()
{
if (tree != null)
- tree.setCellRenderer(currentCellRenderer);
+ {
+ if(tree.getCellRenderer() == null)
+ {
+ if(currentCellRenderer == null)
+ currentCellRenderer = createDefaultCellRenderer();
+ tree.setCellRenderer(currentCellRenderer);
+ }
+ }
}
/**
@@ -1169,14 +1169,30 @@ public class BasicTreeUI
/**
* Updates the <code>preferredSize</code> instance variable, which is
- * returned from <code>getPreferredSize()</code>. For left to right
- * orientations, the size is determined from the current AbstractLayoutCache.
- * For RTL orientations, the preferred size becomes the width minus the
- * minimum x position.
+ * returned from <code>getPreferredSize()</code>.
*/
protected void updateCachedPreferredSize()
{
- // FIXME: not implemented
+ int maxWidth = 0;
+ boolean isLeaf = false;
+ if (currentVisiblePath != null)
+ {
+ Object[] path = currentVisiblePath.getPath();
+ for (int i = 0; i < path.length; i++)
+ {
+ TreePath curr = new TreePath(getPathToRoot(path[i], 0));
+ Rectangle bounds = getPathBounds(tree, curr);
+
+ if (treeModel != null)
+ isLeaf = treeModel.isLeaf(path[i]);
+ if (!isLeaf && hasControlIcons())
+ bounds.width += getCurrentControlIcon(curr).getIconWidth();
+ maxWidth = Math.max(maxWidth, bounds.x + bounds.width);
+ }
+ preferredSize = new Dimension(maxWidth, (getRowHeight() * path.length));
+ }
+ else preferredSize = new Dimension(0, 0);
+ validCachedPreferredSize = true;
}
/**
@@ -1187,7 +1203,9 @@ public class BasicTreeUI
*/
protected void pathWasExpanded(TreePath path)
{
- // FIXME: not implemented
+ validCachedPreferredSize = false;
+ tree.revalidate();
+ tree.repaint();
}
/**
@@ -1195,31 +1213,28 @@ public class BasicTreeUI
*/
protected void pathWasCollapsed(TreePath path)
{
- // FIXME: not implemented
+ validCachedPreferredSize = false;
+ tree.revalidate();
+ tree.repaint();
}
/**
* Install all defaults for the tree.
- *
- * @param tree
- * is the JTree to install defaults for
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- tree.setFont(defaults.getFont("Tree.font"));
- tree.setForeground(defaults.getColor("Tree.foreground"));
- tree.setBackground(defaults.getColor("Tree.background"));
+ LookAndFeel.installColorsAndFont(tree, "Tree.background",
+ "Tree.foreground", "Tree.font");
tree.setOpaque(true);
- rightChildIndent = defaults.getInt("Tree.rightChildIndent");
- leftChildIndent = defaults.getInt("Tree.leftChildIndent");
- setRowHeight(defaults.getInt("Tree.rowHeight"));
+ rightChildIndent = UIManager.getInt("Tree.rightChildIndent");
+ leftChildIndent = UIManager.getInt("Tree.leftChildIndent");
+ setRowHeight(UIManager.getInt("Tree.rowHeight"));
+ tree.setRowHeight(UIManager.getInt("Tree.rowHeight"));
tree.requestFocusInWindow(false);
- tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand"));
- setExpandedIcon(defaults.getIcon("Tree.expandedIcon"));
- setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon"));
+ tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand"));
+ setExpandedIcon(UIManager.getIcon("Tree.expandedIcon"));
+ setCollapsedIcon(UIManager.getIcon("Tree.collapsedIcon"));
}
/**
@@ -1309,7 +1324,7 @@ public class BasicTreeUI
tree.addPropertyChangeListener(propertyChangeListener);
tree.addFocusListener(focusListener);
tree.addTreeSelectionListener(treeSelectionListener);
- tree.addMouseListener(mouseInputListener);
+ tree.addMouseListener(mouseListener);
tree.addKeyListener(keyListener);
tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
tree.addComponentListener(componentListener);
@@ -1326,34 +1341,34 @@ public class BasicTreeUI
*/
public void installUI(JComponent c)
{
+ tree = (JTree) c;
prepareForUIInstall();
super.installUI(c);
- tree = (JTree) c;
installDefaults();
installComponents();
-
+ installKeyboardActions();
+ installListeners();
+
setCellEditor(createDefaultCellEditor());
createdCellEditor = true;
isEditing = false;
-
+
TreeModel mod = tree.getModel();
setModel(mod);
- tree.setRootVisible(true);
if (mod != null)
- tree.expandPath(new TreePath(mod.getRoot()));
+ {
+ TreePath path = new TreePath(mod.getRoot());
+ if (!tree.isExpanded(path))
+ toggleExpandState(path);
+ }
treeSelectionModel = tree.getSelectionModel();
- installKeyboardActions();
- installListeners();
completeUIInstall();
}
/**
* Uninstall the defaults for the tree
- *
- * @param tree
- * to uninstall defaults for
*/
protected void uninstallDefaults()
{
@@ -1395,18 +1410,16 @@ public class BasicTreeUI
public void paint(Graphics g, JComponent c)
{
JTree tree = (JTree) c;
-
+ if (currentVisiblePath == null)
+ updateCurrentVisiblePath();
+
if (treeModel != null)
{
Object root = treeModel.getRoot();
-
- if (!tree.isRootVisible())
- tree.expandPath(new TreePath(root));
-
- paintRecursive(g, 0, 0, 0, 0, tree, treeModel, root);
-
+ paintRecursive(g, 0, 0, 0, tree, treeModel, root);
+
if (hasControlIcons())
- paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, root);
+ paintControlIcons(g, 0, 0, 0, tree, treeModel, root);
}
}
@@ -1443,7 +1456,7 @@ public class BasicTreeUI
*/
public void setPreferredMinSize(Dimension newSize)
{
- // FIXME: not implemented
+ preferredMinSize = newSize;
}
/**
@@ -1453,8 +1466,7 @@ public class BasicTreeUI
*/
public Dimension getPreferredMinSize()
{
- // FIXME: not implemented
- return null;
+ return preferredMinSize;
}
/**
@@ -1484,27 +1496,10 @@ public class BasicTreeUI
*/
public Dimension getPreferredSize(JComponent c, boolean checkConsistancy)
{
- // FIXME: checkConsistancy not implemented, c not used
- int maxWidth = 0;
- int count = 0;
- if (treeModel != null)
- {
- Object node = treeModel.getRoot();
- if (node != null)
- {
- maxWidth = (int) (getCellBounds(0, 0, node).getWidth());
- while (node != null)
- {
- count++;
- Object nextNode = getNextVisibleNode(node);
- if (nextNode != null)
- maxWidth = Math.max(maxWidth,
- (int) (getCellBounds(0, 0, nextNode).getWidth()));
- node = nextNode;
- }
- }
- }
- return new Dimension(maxWidth, (getRowHeight() * count));
+ // FIXME: checkConsistancy not implemented, c not used
+ if(!validCachedPreferredSize)
+ updateCachedPreferredSize();
+ return preferredSize;
}
/**
@@ -1598,7 +1593,7 @@ public class BasicTreeUI
int y;
if (event == null)
{
- Rectangle bounds = getPathBounds(tree, path);
+ bounds = getPathBounds(tree, path);
x = bounds.x;
y = bounds.y;
}
@@ -1628,6 +1623,8 @@ public class BasicTreeUI
editingComponent.getParent().validate();
tree.add(editingComponent.getParent());
editingComponent.getParent().validate();
+ validCachedPreferredSize = false;
+ tree.revalidate();
((JTextField) editingComponent).requestFocusInWindow(false);
editorTimer.start();
return true;
@@ -1676,16 +1673,10 @@ public class BasicTreeUI
if (!isLeaf(row))
{
- if (bounds == null)
- bounds = getPathBounds(tree, path);
- if (tree.isExpanded(path) && expandedIcon != null)
- bounds.x -= expandedIcon.getIconWidth() - 4;
- else if (collapsedIcon != null)
- bounds.x -= collapsedIcon.getIconWidth() - 4;
-
- Icon controlIcon = getCurrentControlIcon(path);
- if (controlIcon != null && (mouseX < bounds.x)
- && (mouseX > (bounds.x - controlIcon.getIconWidth())))
+ bounds = getPathBounds(tree, path);
+
+ if (hasControlIcons() && (mouseX < bounds.x)
+ && (mouseX > (bounds.x - getCurrentControlIcon(path).getIconWidth() - gap)))
cntlClick = true;
}
return cntlClick;
@@ -1722,6 +1713,7 @@ public class BasicTreeUI
tree.collapsePath(path);
else
tree.expandPath(path);
+ updateCurrentVisiblePath();
}
/**
@@ -1856,7 +1848,7 @@ public class BasicTreeUI
(new TreeTraverseAction(0, "")).actionPerformed(e);
else if (e.getActionCommand().equals("selectAll"))
{
- TreePath[] paths = new TreePath[tree.getRowCount()];
+ TreePath[] paths = new TreePath[tree.getVisibleRowCount()];
Object curr = getNextVisibleNode(treeModel.getRoot());
int i = 0;
@@ -1971,8 +1963,7 @@ public class BasicTreeUI
/**
* Updates the preferred size when scrolling, if necessary.
*/
- public class ComponentHandler
- extends ComponentAdapter
+ public class ComponentHandler extends ComponentAdapter
implements ActionListener
{
/**
@@ -1988,6 +1979,7 @@ public class BasicTreeUI
*/
public ComponentHandler()
{
+ // Nothing to do here.
}
/**
@@ -1998,6 +1990,7 @@ public class BasicTreeUI
*/
public void componentMoved(ComponentEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2006,6 +1999,7 @@ public class BasicTreeUI
*/
protected void startTimer()
{
+ // TODO: Implement this properly.
}
/**
@@ -2027,21 +2021,22 @@ public class BasicTreeUI
*/
public void actionPerformed(ActionEvent ae)
{
+ // TODO: Implement this properly.
}
- }// ComponentHandler
+ }
/**
* Listener responsible for getting cell editing events and updating the tree
* accordingly.
*/
- public class CellEditorHandler
- implements CellEditorListener
+ public class CellEditorHandler implements CellEditorListener
{
/**
* Constructor
*/
public CellEditorHandler()
{
+ // Nothing to do here.
}
/**
@@ -2074,6 +2069,9 @@ public class BasicTreeUI
isEditing = false;
tree.requestFocusInWindow(false);
editorTimer.stop();
+ validCachedPreferredSize = false;
+ tree.revalidate();
+ tree.repaint();
}
/**
@@ -2102,6 +2100,8 @@ public class BasicTreeUI
tree.requestFocusInWindow(false);
editorTimer.stop();
isEditing = false;
+ validCachedPreferredSize = false;
+ tree.revalidate();
tree.repaint();
}
}// CellEditorHandler
@@ -2117,6 +2117,7 @@ public class BasicTreeUI
*/
public FocusHandler()
{
+ // Nothing to do here.
}
/**
@@ -2128,6 +2129,7 @@ public class BasicTreeUI
*/
public void focusGained(FocusEvent e)
{
+ // TODO: Implement this properly.
}
/**
@@ -2139,8 +2141,9 @@ public class BasicTreeUI
*/
public void focusLost(FocusEvent e)
{
+ // TODO: Implement this properly.
}
- }// FocusHandler
+ }
/**
* This is used to get multiple key down events to appropriately genereate
@@ -2160,6 +2163,7 @@ public class BasicTreeUI
*/
public KeyHandler()
{
+ // Nothing to do here.
}
/**
@@ -2173,6 +2177,7 @@ public class BasicTreeUI
*/
public void keyTyped(KeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2183,6 +2188,7 @@ public class BasicTreeUI
*/
public void keyPressed(KeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2193,22 +2199,22 @@ public class BasicTreeUI
*/
public void keyReleased(KeyEvent e)
{
+ // TODO: What should be done here, if anything?
}
- }// KeyHandler
+ }
/**
* MouseListener is responsible for updating the selection based on mouse
* events.
*/
- public class MouseHandler
- extends MouseAdapter
- implements MouseMotionListener
+ public class MouseHandler extends MouseAdapter implements MouseMotionListener
{
/**
* Constructor
*/
public MouseHandler()
{
+ // Nothing to do here.
}
/**
@@ -2219,6 +2225,54 @@ public class BasicTreeUI
*/
public void mousePressed(MouseEvent e)
{
+ Point click = e.getPoint();
+ TreePath path = getClosestPathForLocation(tree, click.x, click.y);
+
+ if (path != null)
+ {
+ bounds = getPathBounds(tree, path);
+ int row = getRowForPath(tree, path);
+ boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);
+
+ boolean isLeaf = isLeaf(row);
+
+ TreeCellRenderer tcr = getCellRenderer();
+ Icon icon;
+ if (isLeaf)
+ icon = UIManager.getIcon("Tree.leafIcon");
+ else if (tree.isExpanded(path))
+ icon = UIManager.getIcon("Tree.openIcon");
+ else
+ icon = UIManager.getIcon("Tree.closedIcon");
+
+ if (tcr instanceof DefaultTreeCellRenderer)
+ {
+ Icon tmp = ((DefaultTreeCellRenderer) tcr).getIcon();
+ if (tmp != null)
+ icon = tmp;
+ }
+
+ // add gap*2 for the space before and after the text
+ if (icon != null)
+ bounds.width += icon.getIconWidth() + gap*2;
+
+ boolean inBounds = bounds.contains(click.x, click.y);
+ if ((inBounds || cntlClick) && tree.isVisible(path))
+ {
+ selectPath(tree, path);
+ if (inBounds && e.getClickCount() == 2 && !isLeaf(row))
+ toggleExpandState(path);
+
+ if (cntlClick)
+ {
+ handleExpandControlClick(path, click.x, click.y);
+ if (cellEditor != null)
+ cellEditor.cancelCellEditing();
+ }
+ else if (tree.isEditable())
+ startEditing(path, e);
+ }
+ }
}
/**
@@ -2232,6 +2286,7 @@ public class BasicTreeUI
*/
public void mouseDragged(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2243,6 +2298,7 @@ public class BasicTreeUI
*/
public void mouseMoved(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2253,16 +2309,16 @@ public class BasicTreeUI
*/
public void mouseReleased(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
- }// MouseHandler
+ }
/**
* MouseInputHandler handles passing all mouse events, including mouse motion
* events, until the mouse is released to the destination it is constructed
* with.
*/
- public class MouseInputHandler
- implements MouseInputListener
+ public class MouseInputHandler implements MouseInputListener
{
/** Source that events are coming from */
protected Component source;
@@ -2283,6 +2339,8 @@ public class BasicTreeUI
public MouseInputHandler(Component source, Component destination,
MouseEvent e)
{
+ this.source = source;
+ this.destination = destination;
}
/**
@@ -2294,6 +2352,7 @@ public class BasicTreeUI
*/
public void mouseClicked(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2304,42 +2363,7 @@ public class BasicTreeUI
*/
public void mousePressed(MouseEvent e)
{
- Point click = e.getPoint();
- TreePath path = getClosestPathForLocation(tree, click.x, click.y);
-
- if (path != null)
- {
- bounds = getPathBounds(tree, path);
- int row = getRowForPath(tree, path);
- boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);
-
- if (isLeaf(row))
- {
- bounds.x -= rightChildIndent - 4;
- bounds.width += rightChildIndent + 4;
- }
- else if (tree.isExpanded(path) && expandedIcon != null)
- bounds.width += expandedIcon.getIconWidth() + 4;
- else if (collapsedIcon != null)
- bounds.width += collapsedIcon.getIconWidth() + 4;
-
- boolean inBounds = bounds.contains(click.x, click.y);
- if ((inBounds || cntlClick) && tree.isVisible(path))
- {
- selectPath(tree, path);
- if (inBounds && e.getClickCount() == 2 && !isLeaf(row))
- toggleExpandState(path);
-
- if (cntlClick)
- {
- handleExpandControlClick(path, click.x, click.y);
- if (cellEditor != null)
- cellEditor.cancelCellEditing();
- }
- else if (tree.isEditable())
- startEditing(path, e);
- }
- }
+ // TODO: What should be done here, if anything?
}
/**
@@ -2350,6 +2374,7 @@ public class BasicTreeUI
*/
public void mouseReleased(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2360,6 +2385,7 @@ public class BasicTreeUI
*/
public void mouseEntered(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2370,6 +2396,7 @@ public class BasicTreeUI
*/
public void mouseExited(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2383,6 +2410,7 @@ public class BasicTreeUI
*/
public void mouseDragged(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2394,6 +2422,7 @@ public class BasicTreeUI
*/
public void mouseMoved(MouseEvent e)
{
+ // TODO: What should be done here, if anything?
}
/**
@@ -2401,8 +2430,9 @@ public class BasicTreeUI
*/
protected void removeFromSource()
{
+ // TODO: Implement this properly.
}
- }// MouseInputHandler
+ }
/**
* Class responsible for getting size of node, method is forwarded to
@@ -2417,6 +2447,7 @@ public class BasicTreeUI
*/
public NodeDimensionsHandler()
{
+ // Nothing to do here.
}
/**
@@ -2464,6 +2495,7 @@ public class BasicTreeUI
*/
public PropertyChangeHandler()
{
+ // Nothing to do here.
}
/**
@@ -2475,8 +2507,9 @@ public class BasicTreeUI
*/
public void propertyChange(PropertyChangeEvent event)
{
+ // TODO: What should be done here, if anything?
}
- }// PropertyChangeHandler
+ }
/**
* Listener on the TreeSelectionModel, resets the row selection if any of the
@@ -2491,6 +2524,7 @@ public class BasicTreeUI
*/
public SelectionModelPropertyChangeHandler()
{
+ // Nothing to do here.
}
/**
@@ -2502,8 +2536,9 @@ public class BasicTreeUI
*/
public void propertyChange(PropertyChangeEvent event)
{
+ // TODO: What should be done here, if anything?
}
- }// SelectionModelPropertyChangeHandler
+ }
/**
* ActionListener that invokes cancelEditing when action performed.
@@ -2517,6 +2552,7 @@ public class BasicTreeUI
*/
public TreeCancelEditingAction(String name)
{
+ // TODO: Implement this properly.
}
/**
@@ -2527,6 +2563,7 @@ public class BasicTreeUI
*/
public void actionPerformed(ActionEvent e)
{
+ // TODO: Implement this properly.
}
/**
@@ -2536,9 +2573,10 @@ public class BasicTreeUI
*/
public boolean isEnabled()
{
+ // TODO: Implement this properly.
return false;
}
- }// TreeCancelEditingAction
+ }
/**
* Updates the TreeState in response to nodes expanding/collapsing.
@@ -2552,6 +2590,7 @@ public class BasicTreeUI
*/
public TreeExpansionHandler()
{
+ // Nothing to do here.
}
/**
@@ -2562,6 +2601,9 @@ public class BasicTreeUI
*/
public void treeExpanded(TreeExpansionEvent event)
{
+ validCachedPreferredSize = false;
+ updateCurrentVisiblePath();
+ tree.revalidate();
tree.repaint();
}
@@ -2573,6 +2615,9 @@ public class BasicTreeUI
*/
public void treeCollapsed(TreeExpansionEvent event)
{
+ validCachedPreferredSize = false;
+ updateCurrentVisiblePath();
+ tree.revalidate();
tree.repaint();
}
}// TreeExpansionHandler
@@ -2598,6 +2643,7 @@ public class BasicTreeUI
*/
public TreeHomeAction(int direction, String name)
{
+ // TODO: Implement this properly
}
/**
@@ -2608,6 +2654,7 @@ public class BasicTreeUI
*/
public void actionPerformed(ActionEvent e)
{
+ // TODO: Implement this properly
}
/**
@@ -2617,9 +2664,10 @@ public class BasicTreeUI
*/
public boolean isEnabled()
{
+ // TODO: Implement this properly
return false;
}
- }// TreeHomeAction
+ }
/**
* TreeIncrementAction is used to handle up/down actions. Selection is moved
@@ -2642,6 +2690,7 @@ public class BasicTreeUI
*/
public TreeIncrementAction(int direction, String name)
{
+ // TODO: Implement this properly
}
/**
@@ -2661,7 +2710,7 @@ public class BasicTreeUI
if (prev != null)
{
TreePath newPath = new TreePath(getPathToRoot(prev, 0));
- selectPath(tree, new TreePath(getPathToRoot(prev, 0)));
+ selectPath(tree, newPath);
tree.setLeadSelectionPath(newPath);
}
}
@@ -2681,7 +2730,7 @@ public class BasicTreeUI
if (prev != null)
{
TreePath newPath = new TreePath(getPathToRoot(prev, 0));
- selectPath(tree, new TreePath(getPathToRoot(prev, 0)));
+ selectPath(tree, newPath);
}
}
else if (e.getActionCommand().equals("selectNext"))
@@ -2722,21 +2771,22 @@ public class BasicTreeUI
*/
public boolean isEnabled()
{
+ // TODO: Implement this properly
return false;
}
- }// TreeIncrementAction
+ }
/**
* Forwards all TreeModel events to the TreeState.
*/
- public class TreeModelHandler
- implements TreeModelListener
+ public class TreeModelHandler implements TreeModelListener
{
/**
* Constructor
*/
public TreeModelHandler()
{
+ // Nothing to do here.
}
/**
@@ -2754,6 +2804,9 @@ public class BasicTreeUI
*/
public void treeNodesChanged(TreeModelEvent e)
{
+ validCachedPreferredSize = false;
+ updateCurrentVisiblePath();
+ tree.revalidate();
tree.repaint();
}
@@ -2767,6 +2820,9 @@ public class BasicTreeUI
*/
public void treeNodesInserted(TreeModelEvent e)
{
+ validCachedPreferredSize = false;
+ updateCurrentVisiblePath();
+ tree.revalidate();
tree.repaint();
}
@@ -2783,6 +2839,9 @@ public class BasicTreeUI
*/
public void treeNodesRemoved(TreeModelEvent e)
{
+ validCachedPreferredSize = false;
+ updateCurrentVisiblePath();
+ tree.revalidate();
tree.repaint();
}
@@ -2798,6 +2857,9 @@ public class BasicTreeUI
*/
public void treeStructureChanged(TreeModelEvent e)
{
+ validCachedPreferredSize = false;
+ updateCurrentVisiblePath();
+ tree.revalidate();
tree.repaint();
}
}// TreeModelHandler
@@ -2805,8 +2867,7 @@ public class BasicTreeUI
/**
* TreePageAction handles page up and page down events.
*/
- public class TreePageAction
- extends AbstractAction
+ public class TreePageAction extends AbstractAction
{
/** Specifies the direction to adjust the selection by. */
protected int direction;
@@ -2821,6 +2882,7 @@ public class BasicTreeUI
*/
public TreePageAction(int direction, String name)
{
+ this.direction = direction;
}
/**
@@ -2831,6 +2893,7 @@ public class BasicTreeUI
*/
public void actionPerformed(ActionEvent e)
{
+ // TODO: Implement this properly.
}
/**
@@ -2848,14 +2911,14 @@ public class BasicTreeUI
* Listens for changes in the selection model and updates the display
* accordingly.
*/
- public class TreeSelectionHandler
- implements TreeSelectionListener
+ public class TreeSelectionHandler implements TreeSelectionListener
{
/**
* Constructor
*/
public TreeSelectionHandler()
{
+ // Nothing to do here.
}
/**
@@ -2875,8 +2938,7 @@ public class BasicTreeUI
/**
* For the first selected row expandedness will be toggled.
*/
- public class TreeToggleAction
- extends AbstractAction
+ public class TreeToggleAction extends AbstractAction
{
/**
* Constructor
@@ -2886,6 +2948,7 @@ public class BasicTreeUI
*/
public TreeToggleAction(String name)
{
+ // Nothing to do here.
}
/**
@@ -2896,6 +2959,7 @@ public class BasicTreeUI
*/
public void actionPerformed(ActionEvent e)
{
+ // TODO: Implement this properly.
}
/**
@@ -2913,8 +2977,7 @@ public class BasicTreeUI
* TreeTraverseAction is the action used for left/right keys. Will toggle the
* expandedness of a node, as well as potentially incrementing the selection.
*/
- public class TreeTraverseAction
- extends AbstractAction
+ public class TreeTraverseAction extends AbstractAction
{
/**
* Determines direction to traverse, 1 means expand, -1 means collapse.
@@ -2931,6 +2994,7 @@ public class BasicTreeUI
*/
public TreeTraverseAction(int direction, String name)
{
+ this.direction = direction;
}
/**
@@ -2948,8 +3012,8 @@ public class BasicTreeUI
TreePath path = new TreePath(getPathToRoot(last, 0));
Object p = getParent(treeModel.getRoot(), last);
- if (!treeModel.isLeaf(last) && tree.isExpanded(path))
- tree.collapsePath(path);
+ if (!treeModel.isLeaf(last))
+ toggleExpandState(path);
else if (p != null)
selectPath(tree, new TreePath(getPathToRoot(p, 0)));
}
@@ -2957,8 +3021,8 @@ public class BasicTreeUI
{
TreePath path = new TreePath(getPathToRoot(last, 0));
- if (!treeModel.isLeaf(last) && tree.isCollapsed(path))
- tree.expandPath(path);
+ if (!treeModel.isLeaf(last))
+ toggleExpandState(path);
else
{
Object next = getNextVisibleNode(last);
@@ -2976,9 +3040,10 @@ public class BasicTreeUI
*/
public boolean isEnabled()
{
+ // TODO: Implement this properly
return false;
}
- } // TreeTraverseAction
+ }
/**
* Returns the cell bounds for painting selected cells Package private for use
@@ -3001,8 +3066,7 @@ public class BasicTreeUI
FontMetrics fm = tree.getToolkit().getFontMetrics(f);
if (s != null)
- return new Rectangle(x, y,
- SwingUtilities.computeStringWidth(fm, s) + 4,
+ return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s),
fm.getHeight());
}
return new Rectangle(x, y, 0, 0);
@@ -3032,80 +3096,19 @@ public class BasicTreeUI
int rowHeight = getRowHeight();
if (startNode == null || startNode.equals(node))
{
- if (!tree.isRootVisible()
- && tree.isExpanded(new TreePath(mod.getRoot())))
- return new Point(x + ((getLevel(node)) * rightChildIndent), y);
-
- return new Point(x + ((getLevel(node) + 1) * rightChildIndent), y);
- }
-
- if (!mod.isLeaf(startNode)
- && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0)))
- && !mod.isLeaf(startNode) && mod.getChildCount(startNode) > 0)
- {
- Object child = mod.getChild(startNode, 0);
- if (child != null)
- return getCellLocation(x, y + rowHeight, tree, mod, node, child);
+ int level = getLevel(node);
+ if (level == 0)
+ return new Point(x, y);
+ if (!tree.isRootVisible() &&
+ tree.isExpanded(new TreePath(mod.getRoot())))
+ return new Point(x + ((level - 1) * rightChildIndent), y);
+ return new Point(x + (level * rightChildIndent), y);
}
-
return getCellLocation(x, y + rowHeight, tree, mod, node,
getNextVisibleNode(startNode));
}
/**
- * Paints a node in the tree Package private for use in inner classes.
- *
- * @param g
- * the Graphics context in which to paint
- * @param x
- * the x location of the node
- * @param y
- * the y location of the node
- * @param tree
- * the tree to draw on
- * @param node
- * the object to draw
- */
- void paintNode(Graphics g, int x, int y, JTree tree, Object node,
- boolean isLeaf)
- {
- TreePath curr = new TreePath(getPathToRoot(node, 0));
- boolean selected = tree.isPathSelected(curr);
- boolean expanded = false;
- boolean hasIcons = false;
-
- if (tree.isVisible(curr))
- {
- if (!isLeaf)
- expanded = tree.isExpanded(curr);
-
- if (editingComponent != null && editingPath != null && isEditing(tree)
- && node.equals(editingPath.getLastPathComponent()))
- {
- Rectangle bounds = getPathBounds(tree, editingPath);
- rendererPane.paintComponent(g, editingComponent.getParent(), null,
- new Rectangle(0, 0, bounds.width,
- bounds.height));
- }
- else
- {
- TreeCellRenderer dtcr = tree.getCellRenderer();
- if (dtcr == null)
- dtcr = createDefaultCellRenderer();
-
- int row = getRowForPath(tree, curr);
-
- Component c = dtcr.getTreeCellRendererComponent(tree, node,
- selected, expanded,
- isLeaf, row, false);
-
- rendererPane.paintComponent(g, c, c.getParent(),
- getCellBounds(x, y, node));
- }
- }
- }
-
- /**
* Recursively paints all elements of the tree Package private for use in
* inner classes.
*
@@ -3115,8 +3118,6 @@ public class BasicTreeUI
* of the current object
* @param descent
* is the number of elements drawn
- * @param childNumber
- * is the index of the current child in the tree
* @param depth
* is the depth of the current object in the tree
* @param tree
@@ -3127,46 +3128,50 @@ public class BasicTreeUI
* is the current object to draw
* @return int - current descent of the tree
*/
- int paintRecursive(Graphics g, int indentation, int descent, int childNumber,
+ int paintRecursive(Graphics g, int indentation, int descent,
int depth, JTree tree, TreeModel mod, Object curr)
{
- Rectangle clip = g.getClipBounds();
+ Rectangle clip = tree.getVisibleRect();
if (indentation > clip.x + clip.width + rightChildIndent
|| descent > clip.y + clip.height + getRowHeight())
return descent;
+ TreePath path = new TreePath(getPathToRoot(curr, 0));
int halfHeight = getRowHeight() / 2;
int halfWidth = rightChildIndent / 2;
int y0 = descent + halfHeight;
int heightOfLine = descent + halfHeight;
+ int row = getRowForPath(tree, path);
boolean isRootVisible = tree.isRootVisible();
+ boolean isExpanded = tree.isExpanded(path);
+ boolean isLeaf = mod.isLeaf(curr);
+ Rectangle bounds = getPathBounds(tree, path);
+ Object root = mod.getRoot();
- if (mod.isLeaf(curr))
+ if (isLeaf)
{
- paintNode(g, indentation + 4, descent, tree, curr, true);
+ paintRow(g, clip, null, bounds, path, row, true, false, true);
descent += getRowHeight();
}
else
{
if (depth > 0 || isRootVisible)
{
- paintNode(g, indentation + 4, descent, tree, curr, false);
+ paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);
descent += getRowHeight();
y0 += halfHeight;
}
-
- int max = 0;
- if (!mod.isLeaf(curr))
- max = mod.getChildCount(curr);
- if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
+
+ int max = mod.getChildCount(curr);
+ if (isExpanded)
{
for (int i = 0; i < max; i++)
{
int indent = indentation + rightChildIndent;
if (!isRootVisible && depth == 0)
indent = 0;
- else if ((!isRootVisible && !curr.equals(mod.getRoot()))
- || isRootVisible)
+ else if (isRootVisible ||
+ (!isRootVisible && !curr.equals(root)))
{
g.setColor(getHashColor());
heightOfLine = descent + halfHeight;
@@ -3174,14 +3179,14 @@ public class BasicTreeUI
indentation + halfWidth, indentation + rightChildIndent);
}
- descent = paintRecursive(g, indent, descent, i, depth + 1,
+ descent = paintRecursive(g, indent, descent, depth + 1,
tree, mod, mod.getChild(curr, i));
}
}
}
- if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
- if (y0 != heightOfLine && !mod.isLeaf(curr)
+ if (isExpanded)
+ if (y0 != heightOfLine && !isLeaf
&& mod.getChildCount(curr) > 0)
{
g.setColor(getHashColor());
@@ -3191,7 +3196,7 @@ public class BasicTreeUI
return descent;
}
-
+
/**
* Recursively paints all the control icons on the tree. Package private for
* use in inner classes.
@@ -3202,90 +3207,98 @@ public class BasicTreeUI
* of the current object
* @param descent
* is the number of elements drawn
- * @param childNumber
- * is the index of the current child in the tree
* @param depth
* is the depth of the current object in the tree
* @param tree
* is the tree to draw to
* @param mod
* is the TreeModel we are using to draw
- * @param curr
+ * @param node
* is the current object to draw
- * @return int - current descent of the tree
+ * @return int current descent of the tree
*/
int paintControlIcons(Graphics g, int indentation, int descent,
- int childNumber, int depth, JTree tree, TreeModel mod,
+ int depth, JTree tree, TreeModel mod,
Object node)
{
- int h = descent;
int rowHeight = getRowHeight();
TreePath path = new TreePath(getPathToRoot(node, 0));
Icon icon = getCurrentControlIcon(path);
-
- Rectangle clip = g.getClipBounds();
+
+ Rectangle clip = tree.getVisibleRect();
if (indentation > clip.x + clip.width + rightChildIndent
|| descent > clip.y + clip.height + getRowHeight())
return descent;
-
+
if (mod.isLeaf(node))
descent += rowHeight;
else
- {
+ {
+ if (!node.equals(mod.getRoot()) &&
+ (tree.isRootVisible() || getLevel(node) != 1))
+ {
+ int width = icon.getIconWidth();
+ int height = icon.getIconHeight() + 2;
+ int posX = indentation - rightChildIndent;
+ int posY = descent;
+ if (width > rightChildIndent)
+ posX -= gap;
+ else posX += width/2;
+
+ if (height < rowHeight)
+ posY += height/2;
+
+ icon.paintIcon(tree, g, posX, posY);
+ }
+
if (depth > 0 || tree.isRootVisible())
descent += rowHeight;
-
- int max = 0;
- if (!mod.isLeaf(node))
- max = mod.getChildCount(node);
-
- if (!node.equals(mod.getRoot()))
- icon.paintIcon(tree, g, indentation - rightChildIndent - 3, h);
-
+
if (tree.isExpanded(path))
{
+ int max = 0;
+ if (!mod.isLeaf(node))
+ max = mod.getChildCount(node);
+
for (int i = 0; i < max; i++)
{
int indent = indentation + rightChildIndent;
if (depth == 0 && !tree.isRootVisible())
- indent = -1;
-
- descent = paintControlIcons(g, indent, descent, i, depth + 1,
+ indent = 1;
+
+ descent = paintControlIcons(g, indent, descent, depth + 1,
tree, mod, mod.getChild(node, i));
}
}
}
-
+
return descent;
}
/**
- * Returns control icon. It is null if the LookAndFeel does not
- * implements the control icons.
- * Package private for use in inner classes.
+ * Returns true if the LookAndFeel implements the control icons. Package
+ * private for use in inner classes.
*
- * @return control icon if it exists.
+ * @returns true if there are control icons
*/
- Icon getCurrentControlIcon(TreePath path)
+ boolean hasControlIcons()
{
- if (tree.isExpanded(path))
- return UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon");
- return UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon");
+ if (expandedIcon != null || collapsedIcon != null)
+ return true;
+ return false;
}
/**
- * Returns true if the LookAndFeel implements the control icons.
- * Package private for use in inner classes.
+ * Returns control icon. It is null if the LookAndFeel does not implements the
+ * control icons. Package private for use in inner classes.
*
- * @returns true if there are control icons
+ * @return control icon if it exists.
*/
- boolean hasControlIcons()
+ Icon getCurrentControlIcon(TreePath path)
{
- if (UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon") != null
- || UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon")
- != null)
- return true;
- return false;
+ if (tree.isExpanded(path))
+ return expandedIcon;
+ return collapsedIcon;
}
/**
@@ -3333,77 +3346,33 @@ public class BasicTreeUI
}
/**
- * Get next visible node in the tree. Package private for use in inner
- * classes.
- *
- * @param the
- * current node
- * @return the next visible node in the JTree. Return null if there are no
- * more.
- */
- Object getNextVisibleNode(Object node)
- {
- Object next = null;
- TreePath current = null;
-
- if (node != null)
- next = getNextNode(node);
-
- if (next != null)
- {
- current = new TreePath(getPathToRoot(next, 0));
- if (tree.isVisible(current))
- return next;
-
- while (next != null && !tree.isVisible(current))
- {
- next = getNextNode(next);
-
- if (next != null)
- current = new TreePath(getPathToRoot(next, 0));
- }
- }
- return next;
- }
-
- /**
* Get previous visible node in the tree. Package private for use in inner
* classes.
*
- * @param the
+ * @param node -
* current node
* @return the next visible node in the JTree. Return null if there are no
* more.
*/
Object getPreviousVisibleNode(Object node)
{
- Object prev = null;
- TreePath current = null;
-
- if (node != null)
- prev = getPreviousNode(node);
-
- if (prev != null)
+ if (currentVisiblePath != null)
{
- current = new TreePath(getPathToRoot(prev, 0));
- if (tree.isVisible(current))
- return prev;
-
- while (prev != null && !tree.isVisible(current))
- {
- prev = getPreviousNode(prev);
-
- if (prev != null)
- current = new TreePath(getPathToRoot(prev, 0));
- }
+ Object[] nodes = currentVisiblePath.getPath();
+ int i = 0;
+ while (i < nodes.length && !node.equals(nodes[i]))
+ i++;
+ // return the next node
+ if (i-1 > 0)
+ return nodes[i-1];
}
- return prev;
+ return null;
}
/**
* Returns the next node in the tree Package private for use in inner classes.
*
- * @param the
+ * @param curr -
* current node
* @return the next node in the tree
*/
@@ -3429,7 +3398,7 @@ public class BasicTreeUI
* Returns the previous node in the tree Package private for use in inner
* classes.
*
- * @param the
+ * @param node
* current node
* @return the previous node in the tree
*/
@@ -3463,7 +3432,7 @@ public class BasicTreeUI
* Returns the next sibling in the tree Package private for use in inner
* classes.
*
- * @param the
+ * @param node -
* current node
* @return the next sibling in the tree
*/
@@ -3488,7 +3457,7 @@ public class BasicTreeUI
* Returns the previous sibling in the tree Package private for use in inner
* classes.
*
- * @param the
+ * @param node -
* current node
* @return the previous sibling in the tree
*/
@@ -3572,7 +3541,7 @@ public class BasicTreeUI
/**
* Returns the level of the node in the tree.
*
- * @param the
+ * @param node -
* current node
* @return the number of the level
*/
@@ -3646,7 +3615,7 @@ public class BasicTreeUI
* is the center position in y-direction FIXME what to do if x <
* (icon.width / 2). Same with y
*/
- protected void drawCentered(JComponent c, Graphics g, Icon icon, int x, int y)
+ protected void drawCentered(Component c, Graphics g, Icon icon, int x, int y)
{
int beginPositionX = x - icon.getIconWidth() / 2;
int beginPositionY = y - icon.getIconHeight() / 2;
@@ -3701,8 +3670,8 @@ public class BasicTreeUI
boolean isExpanded, boolean hasBeenExpanded,
boolean isLeaf)
{
- if (treeModel != null)
- paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, path.getLastPathComponent());
+ if (treeModel != null && hasControlIcons())
+ paintControlIcons(g, 0, 0, 0, tree, treeModel, path.getLastPathComponent());
}
/**
@@ -3734,7 +3703,7 @@ public class BasicTreeUI
* clipBounds, insets.
*
* @param g - the graphics configuration.
- * @param clipbounds -
+ * @param clipBounds -
* @param insets -
* @param path - the path to draw the vertical part for.
*/
@@ -3764,7 +3733,32 @@ public class BasicTreeUI
boolean isExpanded, boolean hasBeenExpanded,
boolean isLeaf)
{
- // FIXME: not implemented.
+ boolean selected = tree.isPathSelected(path);
+ boolean hasIcons = false;
+ Object node = path.getLastPathComponent();
+
+ if (tree.isVisible(path))
+ {
+ bounds.width = preferredSize.width;
+ bounds.x += gap;
+
+ if (editingComponent != null && editingPath != null && isEditing(tree)
+ && node.equals(editingPath.getLastPathComponent()))
+ {
+ rendererPane.paintComponent(g, editingComponent.getParent(), null,
+ bounds);
+ }
+ else
+ {
+ TreeCellRenderer dtcr = tree.getCellRenderer();
+ if (dtcr == null)
+ dtcr = createDefaultCellRenderer();
+
+ Component c = dtcr.getTreeCellRendererComponent(tree, node,
+ selected, isExpanded, isLeaf, row, false);
+ rendererPane.paintComponent(g, c, c.getParent(), bounds);
+ }
+ }
}
/**
@@ -3772,6 +3766,7 @@ public class BasicTreeUI
*/
protected void prepareForUIUninstall()
{
+ // TODO: Implement this properly.
}
/**
@@ -3789,7 +3784,72 @@ public class BasicTreeUI
boolean hasBeenExpanded,
boolean isLeaf)
{
- // FIXME: not implemented.
+ Object node = path.getLastPathComponent();
+ if (treeModel != null && (!isLeaf && !node.equals(treeModel.getRoot())) &&
+ (tree.isRootVisible() || getLevel(node) != 1))
+ return true;
return false;
}
+
+ /**
+ * Updates the cached current TreePath of all visible
+ * nodes in the tree.
+ */
+ void updateCurrentVisiblePath()
+ {
+ if (treeModel == null)
+ return;
+
+ Object next = treeModel.getRoot();
+ Rectangle bounds = getCellBounds(0, 0, next);
+
+ // If root is not a valid size to be visible, or is
+ // not visible and the tree is expanded, then the next node acts
+ // as the root
+ if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible()
+ && tree.isExpanded(new TreePath(next))))
+ next = getNextNode(next);
+ TreePath current = null;
+
+ while (next != null)
+ {
+ if (current == null)
+ current = new TreePath(next);
+ else
+ current = current.pathByAddingChild(next);
+ do
+ next = getNextNode(next);
+ while (next != null &&
+ !tree.isVisible(new TreePath(getPathToRoot(next, 0))));
+ }
+ currentVisiblePath = current;
+ tree.setVisibleRowCount(getRowCount(tree));
+ if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 &&
+ currentVisiblePath != null)
+ tree.addSelectionRow(0);
+ }
+
+ /**
+ * Get next visible node in the currentVisiblePath. Package private for use in
+ * inner classes.
+ *
+ * @param node
+ * current node
+ * @return the next visible node in the JTree. Return null if there are no
+ * more.
+ */
+ Object getNextVisibleNode(Object node)
+ {
+ if (currentVisiblePath != null)
+ {
+ Object[] nodes = currentVisiblePath.getPath();
+ int i = 0;
+ while (i < nodes.length && !node.equals(nodes[i]))
+ i++;
+ // return the next node
+ if (i+1 < nodes.length)
+ return nodes[i+1];
+ }
+ return null;
+ }
} // BasicTreeUI
diff --git a/javax/swing/plaf/basic/BasicViewportUI.java b/javax/swing/plaf/basic/BasicViewportUI.java
index 0d461332a..51b902d64 100644
--- a/javax/swing/plaf/basic/BasicViewportUI.java
+++ b/javax/swing/plaf/basic/BasicViewportUI.java
@@ -38,61 +38,22 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.image.ImageObserver;
-
import javax.swing.JComponent;
-import javax.swing.JViewport;
-import javax.swing.ViewportLayout;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
+import javax.swing.LookAndFeel;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ViewportUI;
public class BasicViewportUI extends ViewportUI
{
-
- ChangeListener changeListener;
- Image backingStoreImage;
- int backingStoreWidth = -1;
- int backingStoreHeight = -1;
-
- class ChangeHandler implements ChangeListener
+ protected void installDefaults(JComponent c)
{
- public void stateChanged(ChangeEvent event)
- {
- JViewport v = (JViewport) event.getSource();
- v.repaint();
- }
- }
-
- void installDefaults(JComponent c)
- {
c.setOpaque(true);
+ LookAndFeel.installColorsAndFont(c, "Viewport.background",
+ "Viewport.foreground", "Viewport.font");
}
-
- void uninstallDefaults(JComponent c)
- {
- }
-
- void installListeners(JComponent c)
+ protected void uninstallDefaults(JComponent c)
{
- ((JViewport)c).addChangeListener(changeListener);
- }
-
- void uninstallListeners(JComponent c)
- {
- ((JViewport)c).removeChangeListener(changeListener);
- }
-
- public BasicViewportUI()
- {
- changeListener = new ChangeHandler();
+ // TODO: Implement this properly.
}
public static ComponentUI createUI(JComponent c)
@@ -103,132 +64,12 @@ public class BasicViewportUI extends ViewportUI
public void installUI(JComponent c)
{
super.installUI(c);
- installListeners(c);
+ installDefaults(c);
}
public void uninstallUI(JComponent c)
{
- uninstallListeners(c);
- }
-
-
- public Dimension getPreferredSize(JComponent c)
- {
- // let the ViewportLayout decide
- return null;
- }
-
- public void paint(Graphics g, JComponent c)
- {
- JViewport port = (JViewport)c;
- Component view = port.getView();
-
- if (view == null)
- return;
-
- Point pos = port.getViewPosition();
- Rectangle viewBounds = view.getBounds();
- Rectangle portBounds = port.getBounds();
-
- if (viewBounds.width == 0
- || viewBounds.height == 0
- || portBounds.width == 0
- || portBounds.height == 0)
- return;
-
- switch (port.getScrollMode())
- {
-
- case JViewport.BACKINGSTORE_SCROLL_MODE:
- paintBackingStore(g, port, view, pos, viewBounds, portBounds);
- break;
-
- case JViewport.BLIT_SCROLL_MODE:
- // FIXME: implement separate blit mode
-
- case JViewport.SIMPLE_SCROLL_MODE:
- default:
- paintSimple(g, port, view, pos, viewBounds, portBounds);
- break;
- }
- }
-
- private void paintSimple(Graphics g,
- JViewport v,
- Component view,
- Point pos,
- Rectangle viewBounds,
- Rectangle portBounds)
- {
- Rectangle oldClip = g.getClipBounds();
- g.setClip(new Rectangle(0, 0, portBounds.width, portBounds.height));
- g.translate (-pos.x, -pos.y);
- try
- {
- view.paint(g);
- }
- finally
- {
- g.translate (pos.x, pos.y);
- g.setClip (oldClip);
- }
- }
-
- private void paintBackingStore(Graphics g,
- JViewport v,
- Component view,
- Point pos,
- Rectangle viewBounds,
- Rectangle portBounds)
- {
- if (backingStoreImage == null
- || backingStoreWidth != viewBounds.width
- || backingStoreHeight != viewBounds.height)
- {
- backingStoreImage = v.createImage(viewBounds.width, viewBounds.height);
- backingStoreWidth = viewBounds.width;
- backingStoreHeight = viewBounds.height;
- }
-
- Graphics g2 = backingStoreImage.getGraphics();
-
- if (v.getBackground() != null)
- {
- // fill the backing store background
- java.awt.Color save = g2.getColor();
- g2.setColor(v.getBackground());
- g2.fillRect (0, 0, backingStoreWidth, backingStoreHeight);
- g2.setColor(save);
-
- // fill the viewport background
- save = g.getColor();
- g.setColor(v.getBackground());
- g.fillRect (0, 0, portBounds.width, portBounds.height);
- g.setColor(save);
-
- }
- else
- {
- // clear the backing store background
- g2.clearRect(0, 0, backingStoreWidth, backingStoreHeight);
-
- // clear the viewport background
- g.clearRect(0, 0, portBounds.width, portBounds.height);
- }
-
- g2.setClip(g.getClipBounds());
- g2.translate(-pos.x, -pos.y);
- try
- {
- view.paint(g2);
- }
- finally
- {
- g2.translate(pos.x, pos.y);
- }
- g2 = null;
- g.drawImage(backingStoreImage,
- 0, 0,
- (ImageObserver)null);
+ super.uninstallUI(c);
+ uninstallDefaults(c);
}
}
diff --git a/javax/swing/plaf/metal/MetalBorders.java b/javax/swing/plaf/metal/MetalBorders.java
index 3d2800657..4fa3b3640 100644
--- a/javax/swing/plaf/metal/MetalBorders.java
+++ b/javax/swing/plaf/metal/MetalBorders.java
@@ -44,14 +44,20 @@ import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.AbstractButton;
-import javax.swing.BorderFactory;
import javax.swing.ButtonModel;
+import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
+import javax.swing.JToolBar;
+import javax.swing.SwingConstants;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;
@@ -61,8 +67,7 @@ import javax.swing.text.JTextComponent;
/**
- * This factory class creates borders for the different Swing components
- * UI.
+ * A factory class that creates borders for the different Swing components.
*
* @author Roman Kennke (roman@kennke.org)
*/
@@ -84,11 +89,12 @@ public class MetalBorders
/** The shared instance for getTextFieldBorder(). */
private static Border textFieldBorder;
- /**
- * The shared instance for getTextBorder().
- */
+ /** The shared instance for getTextBorder(). */
private static Border textBorder;
+ /** The shared instance for getRolloverBorder(). */
+ private static Border rolloverBorder;
+
/**
* A MarginBorder that gets shared by multiple components.
* Created on demand by the private helper function {@link
@@ -97,20 +103,19 @@ public class MetalBorders
private static BasicBorders.MarginBorder marginBorder;
/**
- * The border that is drawn around Swing buttons.
+ * A border used for {@link JButton} components.
*/
- public static class ButtonBorder
- extends AbstractBorder
- implements UIResource
+ public static class ButtonBorder extends AbstractBorder implements UIResource
{
/** The borders insets. */
protected static Insets borderInsets = new Insets(3, 3, 3, 3);
/**
- * Creates a new instance of ButtonBorder.
+ * Creates a new instance of <code>ButtonBorder</code>.
*/
public ButtonBorder()
{
+ // Nothing to do here.
}
/**
@@ -180,11 +185,11 @@ public class MetalBorders
}
/**
- * Returns the insets of the ButtonBorder.
+ * Returns the insets of the <code>ButtonBorder</code>.
*
* @param c the component for which the border is used
*
- * @return the insets of the ButtonBorder
+ * @return The insets of the ButtonBorder
*/
public Insets getBorderInsets(Component c)
{
@@ -192,19 +197,20 @@ public class MetalBorders
}
/**
- * Returns the insets of the ButtonBorder in the specified Insets object.
+ * Returns the insets of the <code>ButtonBorder</code> in the specified
+ * <code>newInsets</code> object.
*
* @param c the component for which the border is used
- * @param newInsets the insets object where to put the values
+ * @param newInsets the insets object where to put the values (if
+ * <code>null</code>, a new instance is created).
*
- * @return the insets of the ButtonBorder
+ * @return The insets.
*/
public Insets getBorderInsets(Component c, Insets newInsets)
{
if (newInsets == null)
newInsets = new Insets(0, 0, 0, 0);
- AbstractButton b = (AbstractButton) c;
newInsets.bottom = borderInsets.bottom;
newInsets.left = borderInsets.left;
newInsets.right = borderInsets.right;
@@ -224,6 +230,7 @@ public class MetalBorders
*/
public DesktopIconBorder()
{
+ // Nothing to do here.
}
/**
@@ -288,6 +295,7 @@ public class MetalBorders
*/
public Flush3DBorder()
{
+ // Nothing to do here.
}
/**
@@ -354,8 +362,7 @@ public class MetalBorders
*
* @since 1.3
*/
- public static class PaletteBorder
- extends AbstractBorder
+ public static class PaletteBorder extends AbstractBorder
implements UIResource
{
/**
@@ -363,6 +370,7 @@ public class MetalBorders
*/
public PaletteBorder()
{
+ // Nothing to do here.
}
/**
@@ -441,6 +449,7 @@ public class MetalBorders
*/
public TextFieldBorder()
{
+ // Nothing to do here.
}
/**
@@ -456,8 +465,16 @@ public class MetalBorders
public void paintBorder(Component c, Graphics g, int x, int y, int w,
int h)
{
- JTextComponent tc = (JTextComponent) c;
- if (tc.isEnabled() && tc.isEditable())
+ boolean enabledTextBorder;
+ if (c instanceof JTextComponent)
+ {
+ JTextComponent tc = (JTextComponent) c;
+ enabledTextBorder = tc.isEnabled() && tc.isEditable();
+ }
+ else
+ enabledTextBorder = false;
+
+ if (enabledTextBorder)
super.paintBorder(c, g, x, y, w, h);
else
{
@@ -471,7 +488,7 @@ public class MetalBorders
}
/**
- * A border used when painting {@link JInternalFrame} instances.
+ * A border used for the {@link JInternalFrame} component.
*/
public static class InternalFrameBorder extends AbstractBorder
implements UIResource
@@ -481,6 +498,7 @@ public class MetalBorders
*/
public InternalFrameBorder()
{
+ // Nothing to do here.
}
/**
@@ -569,24 +587,129 @@ public class MetalBorders
}
/**
+ * A border used for {@link JInternalFrame} components that are
+ * presented as dialogs (by the {@link JOptionPane} class).
+ */
+ public static class OptionDialogBorder extends AbstractBorder
+ implements UIResource
+ {
+
+ /**
+ * Creates a new border instance.
+ */
+ public OptionDialogBorder()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ *
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c, Insets newInsets)
+ {
+ if (newInsets == null)
+ newInsets = new Insets(3, 3, 3, 3);
+ else
+ {
+ newInsets.top = 3;
+ newInsets.left = 3;
+ newInsets.bottom = 3;
+ newInsets.right = 3;
+ }
+ return newInsets;
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+
+ JInternalFrame f = (JInternalFrame) c;
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ if (f.getContentPane() instanceof JOptionPane)
+ {
+ JOptionPane pane = (JOptionPane) f.getContentPane();
+ int type = pane.getMessageType();
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ if (type == JOptionPane.QUESTION_MESSAGE)
+ {
+ Color bc = defaults.getColor(
+ "OptionPane.questionDialog.border.background");
+ if (bc != null)
+ g.setColor(bc);
+ }
+ if (type == JOptionPane.WARNING_MESSAGE)
+ {
+ Color bc = defaults.getColor(
+ "OptionPane.warningDialog.border.background");
+ if (bc != null)
+ g.setColor(bc);
+ }
+ else if (type == JOptionPane.ERROR_MESSAGE)
+ {
+ Color bc = defaults.getColor(
+ "OptionPane.errorDialog.border.background");
+ if (bc != null)
+ g.setColor(bc);
+ }
+ }
+
+ // fill the border background
+ g.fillRect(x, y, w, 3);
+ g.fillRect(x, y, 3, h);
+ g.fillRect(x + w - 3, y, 3, h);
+ g.fillRect(x, y + h - 3, w, 3);
+
+ // draw a dot in each corner
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x, y, 1, 1);
+ g.fillRect(x + w - 1, y, 1, 1);
+ g.fillRect(x + w - 1, y + h - 1, 1, 1);
+ g.fillRect(x, y + h - 1, 1, 1);
+
+ }
+
+ }
+
+ /**
* A border used for {@link JMenu} and {@link JMenuItem} components.
*/
- public static class MenuItemBorder
- extends AbstractBorder
- implements UIResource
+ public static class MenuItemBorder extends AbstractBorder
+ implements UIResource
{
/** The border insets. */
- protected static Insets borderInsets = new Insets(2, 2, 2, 2);
-
- // TODO: find where the real colors come from
- private static Color borderColorDark = new Color(102, 102, 153);
- private static Color borderColorLight = new Color(255, 255, 255);
+ protected static Insets borderInsets = new Insets(1, 1, 1, 1);
/**
* Creates a new border instance.
*/
public MenuItemBorder()
{
+ // Nothing to do here.
}
/**
@@ -603,15 +726,17 @@ public class MetalBorders
public void paintBorder(Component c, Graphics g, int x, int y, int w,
int h)
{
+ Color dark = MetalLookAndFeel.getPrimaryControlDarkShadow();
+ Color light = MetalLookAndFeel.getPrimaryControlHighlight();
if (c instanceof JMenu) {
JMenu menu = (JMenu) c;
if (menu.isSelected())
{
- g.setColor(borderColorDark);
+ g.setColor(dark);
g.drawLine(x, y, x, y + h);
g.drawLine(x, y, x + w, y);
g.drawLine(x + w - 2, y + 1, x + w - 2, y + h);
- g.setColor(borderColorLight);
+ g.setColor(light);
g.drawLine(x + w - 1, y + 1, x + w - 1, y + h);
}
}
@@ -619,12 +744,18 @@ public class MetalBorders
{
JMenuItem item = (JMenuItem) c;
if (item.isArmed())
- {
- g.setColor(borderColorDark);
- g.drawLine(x, y, x + w, y);
- g.setColor(borderColorLight);
- g.drawLine(x, y + h - 1, x + w, y + h - 1);
- }
+ {
+ g.setColor(dark);
+ g.drawLine(x, y, x + w, y);
+ g.setColor(light);
+ g.drawLine(x, y + h - 1, x + w, y + h - 1);
+ }
+ else
+ {
+ // Normally we draw a light line on the left.
+ g.setColor(light);
+ g.drawLine(x, y, x, y + h);
+ }
}
}
@@ -678,6 +809,7 @@ public class MetalBorders
*/
public MenuBarBorder()
{
+ // Nothing to do here.
}
/**
@@ -731,7 +863,7 @@ public class MetalBorders
}
/**
- * A border for JScrollPanes.
+ * A border for {@link JScrollPane} components.
*/
public static class ScrollPaneBorder
extends AbstractBorder
@@ -745,6 +877,7 @@ public class MetalBorders
*/
public ScrollPaneBorder()
{
+ // Nothing to do here.
}
/**
@@ -807,6 +940,45 @@ public class MetalBorders
}
/**
+ * A button border that is only visible when the mouse pointer is within
+ * the button's bounds.
+ */
+ public static class RolloverButtonBorder
+ extends MetalBorders.ButtonBorder
+ {
+ /**
+ * Creates a new border instance.
+ */
+ public RolloverButtonBorder()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+ boolean mouseIsOver = false;
+ if (c instanceof AbstractButton)
+ {
+ ButtonModel bmodel = ((AbstractButton) c).getModel();
+ mouseIsOver = bmodel.isRollover();
+ }
+ if (mouseIsOver)
+ super.paintBorder(c, g, x, y, w, h);
+ }
+ }
+
+ /**
* This border is used in Toolbar buttons as inner border.
*/
static class RolloverMarginBorder extends AbstractBorder
@@ -819,6 +991,7 @@ public class MetalBorders
*/
public RolloverMarginBorder()
{
+ // Nothing to do here.
}
/**
@@ -866,13 +1039,14 @@ public class MetalBorders
{
/** The border's insets. */
- protected static Insets borderInsets = new Insets(2, 2, 1, 1);
+ protected static Insets borderInsets = new Insets(3, 1, 2, 1);
/**
* Constructs a new PopupMenuBorder.
*/
public PopupMenuBorder()
{
+ // Nothing to do here.
}
/**
@@ -936,14 +1110,13 @@ public class MetalBorders
// draw highlighted inner border (only top and left)
g.setColor(light);
- g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
}
}
/**
- * A border used for {@link JToggleButton} components.
+ * A border used for the {@link JToggleButton} component.
*
* @since 1.3
*/
@@ -955,6 +1128,7 @@ public class MetalBorders
*/
public ToggleButtonBorder()
{
+ // Nothing to do here.
}
/**
@@ -1035,6 +1209,101 @@ public class MetalBorders
}
/**
+ * A border used for the {@link JToolBar} component.
+ */
+ public static class ToolBarBorder extends AbstractBorder
+ implements UIResource, SwingConstants
+ {
+ /**
+ * Creates a new border instance.
+ */
+ public ToolBarBorder()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ *
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c, Insets newInsets)
+ {
+ JToolBar tb = (JToolBar) c;
+ if (tb.getOrientation() == JToolBar.HORIZONTAL)
+ {
+ if (newInsets == null)
+ newInsets = new Insets(2, 16, 2, 2);
+ else
+ {
+ newInsets.top = 2;
+ newInsets.left = 16;
+ newInsets.bottom = 2;
+ newInsets.right = 2;
+ }
+ return newInsets;
+ }
+ else // assume JToolBar.VERTICAL
+ {
+ if (newInsets == null)
+ newInsets = new Insets(16, 2, 2, 2);
+ else
+ {
+ newInsets.top = 16;
+ newInsets.left = 2;
+ newInsets.bottom = 2;
+ newInsets.right = 2;
+ }
+ return newInsets;
+ }
+
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+
+ JToolBar tb = (JToolBar) c;
+ if (tb.getOrientation() == JToolBar.HORIZONTAL)
+ {
+ MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + 11, y + h - 5,
+ MetalLookAndFeel.getControlHighlight(),
+ MetalLookAndFeel.getControlDarkShadow());
+ }
+ else
+ {
+ MetalUtils.fillMetalPattern(tb, g, x + 2, y + 2, x + w - 5, y + 11,
+ MetalLookAndFeel.getControlHighlight(),
+ MetalLookAndFeel.getControlDarkShadow());
+ }
+ }
+
+ }
+
+ /**
* A border for table header cells.
*
* @since 1.3
@@ -1156,7 +1425,8 @@ public class MetalBorders
{
Border inner = getMarginBorder();
Border outer = new TextFieldBorder();
- textFieldBorder = BorderFactory.createCompoundBorder(outer, inner);
+ textFieldBorder =
+ new BorderUIResource.CompoundBorderUIResource(outer, inner);
}
return textFieldBorder;
}
@@ -1209,4 +1479,22 @@ public class MetalBorders
marginBorder = new BasicBorders.MarginBorder();
return marginBorder;
}
+
+ /**
+ * Returns a shared instance of a compound border for rollover buttons.
+ *
+ * @return A shared border instance.
+ */
+ static Border getRolloverBorder()
+ {
+ if (rolloverBorder == null)
+ {
+ Border outer = new MetalBorders.RolloverButtonBorder();
+ Border inner = MetalBorders.getMarginBorder();
+ rolloverBorder = new BorderUIResource.CompoundBorderUIResource(outer,
+ inner);
+ }
+ return rolloverBorder;
+ }
+
}
diff --git a/javax/swing/plaf/metal/MetalButtonListener.java b/javax/swing/plaf/metal/MetalButtonListener.java
new file mode 100644
index 000000000..e6fb22e92
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalButtonListener.java
@@ -0,0 +1,86 @@
+/* MetalButtonListener.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.AbstractButton;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.basic.BasicButtonListener;
+
+/**
+ * A listener for buttons under the {@link MetalLookAndFeel}.
+ *
+ * @see MetalButtonUI#createButtonListener
+ */
+class MetalButtonListener extends BasicButtonListener
+{
+
+ /**
+ * Creates a new instance.
+ *
+ * @param button the button.
+ */
+ public MetalButtonListener(AbstractButton button)
+ {
+ super(button);
+ }
+
+ /**
+ * Handles property change events.
+ *
+ * @param e the event.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ super.propertyChange(e);
+ if (e.getPropertyName().equals(
+ AbstractButton.ROLLOVER_ENABLED_CHANGED_PROPERTY))
+ {
+ AbstractButton b = (AbstractButton) e.getSource();
+ if (b.getBorder() instanceof UIResource)
+ {
+ if (Boolean.TRUE.equals(e.getNewValue()))
+ b.setBorder(MetalBorders.getRolloverBorder());
+ else if (Boolean.FALSE.equals(e.getNewValue()))
+ b.setBorder(MetalBorders.getButtonBorder());
+ }
+ }
+ }
+}
diff --git a/javax/swing/plaf/metal/MetalButtonUI.java b/javax/swing/plaf/metal/MetalButtonUI.java
index 0dac5ec39..4e148dbe9 100644
--- a/javax/swing/plaf/metal/MetalButtonUI.java
+++ b/javax/swing/plaf/metal/MetalButtonUI.java
@@ -39,18 +39,23 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
import javax.swing.AbstractButton;
+import javax.swing.JButton;
import javax.swing.JComponent;
-import javax.swing.JToolBar;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.basic.BasicButtonListener;
import javax.swing.plaf.basic.BasicButtonUI;
/**
- * The Metal Look &amp; Feel implementation for
- * {@link javax.swing.AbstractButton}s.
+ * A UI delegate for the {@link JButton} component.
*
* @author Roman Kennke (roman@kennke.org)
*/
@@ -58,27 +63,25 @@ public class MetalButtonUI
extends BasicButtonUI
{
- /** The cached MetalButtonUI instance. */
- private static MetalButtonUI instance = null;
-
- /** The color for the focus border. */
+ /** The color used to draw the focus rectangle around the text and/or icon. */
protected Color focusColor;
-
- /** The color that indicates a selected button. */
+
+ /** The background color for the button when it is pressed. */
protected Color selectColor;
/** The color for disabled button labels. */
protected Color disabledTextColor;
/**
- * Creates a new instance of MetalButtonUI.
+ * Creates a new instance.
*/
public MetalButtonUI()
{
super();
- focusColor = getFocusColor();
- selectColor = getSelectColor();
- disabledTextColor = getDisabledTextColor();
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ focusColor = def.getColor(getPropertyPrefix() + "focus");
+ selectColor = def.getColor(getPropertyPrefix() + "select");
+ disabledTextColor = def.getColor(getPropertyPrefix() + "disabledText");
}
/**
@@ -88,8 +91,7 @@ public class MetalButtonUI
*/
protected Color getFocusColor()
{
- UIDefaults def = UIManager.getLookAndFeelDefaults();
- return def.getColor(getPropertyPrefix() + ".focus");
+ return focusColor;
}
/**
@@ -99,8 +101,7 @@ public class MetalButtonUI
*/
protected Color getSelectColor()
{
- UIDefaults def = UIManager.getLookAndFeelDefaults();
- return def.getColor(getPropertyPrefix() + ".select");
+ return selectColor;
}
/**
@@ -110,36 +111,123 @@ public class MetalButtonUI
*/
protected Color getDisabledTextColor()
{
- UIDefaults def = UIManager.getLookAndFeelDefaults();
- return def.getColor(getPropertyPrefix() + ".disabledText");
+ return disabledTextColor;
}
/**
- * Returns an instance of MetalButtonUI.
- *
- * @param component a button for which a UI instance should be returned
+ * Returns a UI delegate for the specified component.
+ *
+ * @param c the component (should be a subclass of {@link AbstractButton}).
+ *
+ * @return A new instance of <code>MetalButtonUI</code>.
*/
- public static ComponentUI createUI(JComponent component)
- {
- if (instance == null)
- instance = new MetalButtonUI();
- return instance;
+ public static ComponentUI createUI(JComponent c) {
+ return new MetalButtonUI();
}
/**
- * Install the Look &amp; Feel defaults for Buttons.
- *
- * @param button the button for which to install the Look &amp; Feel
+ * Installs the default settings for the specified button.
+ *
+ * @param button the button.
+ *
+ * @see #uninstallDefaults(AbstractButton)
*/
public void installDefaults(AbstractButton button)
{
super.installDefaults(button);
+ if (button.isRolloverEnabled())
+ {
+ if (button.getBorder() instanceof UIResource)
+ button.setBorder(MetalBorders.getRolloverBorder());
+ }
+ }
+
+ /**
+ * Removes the defaults added by {@link #installDefaults(AbstractButton)}.
+ */
+ public void uninstallDefaults(AbstractButton button)
+ {
+ super.uninstallDefaults(button);
+ if (button.getBorder() instanceof UIResource)
+ button.setBorder(null);
+ }
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- button.setFont(defaults.getFont("Button.font"));
+ /**
+ * Returns a button listener for the specified button.
+ *
+ * @param button the button.
+ *
+ * @return A button listener.
+ */
+ protected BasicButtonListener createButtonListener(AbstractButton button)
+ {
+ return new MetalButtonListener(button);
+ }
- if (button.getParent() instanceof JToolBar)
- button.setBorder(MetalBorders.getToolbarButtonBorder());
+ /**
+ * Paints the background of the button to indicate that it is in the "pressed"
+ * state.
+ *
+ * @param g the graphics context.
+ * @param b the button.
+ */
+ protected void paintButtonPressed(Graphics g, AbstractButton b)
+ {
+ if (b.isContentAreaFilled())
+ {
+ Rectangle area = b.getVisibleRect();
+ g.setColor(selectColor);
+ g.fillRect(area.x, area.y, area.width, area.height);
+ }
+ }
+
+ /**
+ * Paints the focus rectangle around the button text and/or icon.
+ *
+ * @param g the graphics context.
+ * @param b the button.
+ * @param viewRect the button bounds.
+ * @param textRect the text bounds.
+ * @param iconRect the icon bounds.
+ */
+ protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
+ Rectangle textRect, Rectangle iconRect) {
+ if (b.hasFocus() && b.isFocusPainted())
+ {
+ Color savedColor = g.getColor();
+ g.setColor(getFocusColor());
+ Rectangle focusRect = iconRect.union(textRect);
+ g.drawRect(focusRect.x - 1, focusRect.y - 1,
+ focusRect.width + 1, focusRect.height + 1);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * Paints the button text.
+ *
+ * @param g the graphics context.
+ * @param c the button.
+ * @param textRect the text bounds.
+ * @param text the text to display.
+ */
+ protected void paintText(Graphics g, JComponent c, Rectangle textRect,
+ String text)
+ {
+ AbstractButton b = (AbstractButton) c;
+ Font f = b.getFont();
+ g.setFont(f);
+ FontMetrics fm = g.getFontMetrics(f);
+
+ if (b.isEnabled())
+ {
+ g.setColor(b.getForeground());
+ g.drawString(text, textRect.x, textRect.y + fm.getAscent());
+ }
+ else
+ {
+ g.setColor(getDisabledTextColor());
+ g.drawString(text, textRect.x, textRect.y + fm.getAscent());
+ }
}
-
}
diff --git a/javax/swing/plaf/metal/MetalCheckBoxIcon.java b/javax/swing/plaf/metal/MetalCheckBoxIcon.java
index 5536e7957..6b9f31b85 100644
--- a/javax/swing/plaf/metal/MetalCheckBoxIcon.java
+++ b/javax/swing/plaf/metal/MetalCheckBoxIcon.java
@@ -47,8 +47,7 @@ import javax.swing.JCheckBox;
import javax.swing.plaf.UIResource;
/**
- * An {@link Icon} implementation for {@link JCheckBox}es in the
- * Metal Look &amp; Feel.
+ * An {@link Icon} used by the {@link MetalCheckBoxUI} class.
*
* @author Roman Kennke (roman@kennke.org)
*/
diff --git a/javax/swing/plaf/metal/MetalCheckBoxUI.java b/javax/swing/plaf/metal/MetalCheckBoxUI.java
index c46cb5f2f..b4f6f0a56 100644
--- a/javax/swing/plaf/metal/MetalCheckBoxUI.java
+++ b/javax/swing/plaf/metal/MetalCheckBoxUI.java
@@ -44,8 +44,7 @@ import javax.swing.UIDefaults;
import javax.swing.plaf.ComponentUI;
/**
- * A UI delegate for the {@link JCheckBox} component under the
- * {@link MetalLookAndFeel}.
+ * A UI delegate for the {@link JCheckBox} component.
*/
public class MetalCheckBoxUI
extends MetalRadioButtonUI
@@ -64,11 +63,11 @@ public class MetalCheckBoxUI
}
/**
- * Returns an instance of MetalCheckBoxUI.
+ * Returns a shared instance of <code>MetalCheckBoxUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalCheckBoxUI
+ * @return A shared instance of <code>MetalCheckBoxUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
diff --git a/javax/swing/plaf/metal/MetalComboBoxButton.java b/javax/swing/plaf/metal/MetalComboBoxButton.java
index f9b802ab7..6993e18e9 100644
--- a/javax/swing/plaf/metal/MetalComboBoxButton.java
+++ b/javax/swing/plaf/metal/MetalComboBoxButton.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package javax.swing.plaf.metal;
-import java.awt.FontMetrics;
+import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
@@ -99,7 +99,9 @@ public class MetalComboBoxButton extends JButton {
public MetalComboBoxButton(JComboBox cb, Icon i, boolean onlyIcon,
CellRendererPane pane, JList list)
{
- super(i);
+ super();
+ if (cb == null)
+ throw new NullPointerException("Null 'cb' argument");
comboBox = cb;
comboIcon = i;
iconOnly = onlyIcon;
@@ -200,6 +202,7 @@ public class MetalComboBoxButton extends JButton {
*/
public void paintComponent(Graphics g)
{
+ super.paintComponent(g);
if (iconOnly)
{
Rectangle bounds = getBounds();
@@ -209,28 +212,30 @@ public class MetalComboBoxButton extends JButton {
}
else
{
- String text = comboBox.getModel().getSelectedItem().toString();
+ Object selected = comboBox.getModel().getSelectedItem();
+ if (selected == null)
+ selected = "";
Rectangle bounds = comboBox.getBounds();
Rectangle innerArea = SwingUtilities.calculateInnerArea(this, null);
+ Insets insets = comboBox.getInsets();
+ Rectangle renderArea = new Rectangle(innerArea.x, innerArea.y,
+ innerArea.width - comboIcon.getIconWidth() - 4, innerArea.height);
+ Component cellRenderer
+ = comboBox.getRenderer().getListCellRendererComponent(this.listBox,
+ selected, comboBox.getSelectedIndex(), false, false);
+ cellRenderer.setBackground(comboBox.getBackground());
+ cellRenderer.setEnabled(comboBox.isEnabled());
+ rendererPane.paintComponent(g, cellRenderer, this, renderArea);
if (comboBox.hasFocus())
{
g.setColor(MetalLookAndFeel.getFocusColor());
g.drawRect(innerArea.x, innerArea.y - 1, innerArea.width - 1,
innerArea.height);
}
- Insets insets = comboBox.getInsets();
int iconX = bounds.width - insets.right - comboIcon.getIconWidth() - 7;
int iconY = insets.top
+ (bounds.height - comboIcon.getIconHeight()) / 2;
comboIcon.paintIcon(comboBox, g, iconX, iconY);
- if (comboBox.isEnabled())
- g.setColor(MetalLookAndFeel.getBlack());
- else
- g.setColor(MetalLookAndFeel.getControlDisabled());
- FontMetrics fm = g.getFontMetrics(comboBox.getFont());
- // FIXME: the label may need truncating with '...' and the
- // alignment needs work
- g.drawString(text, insets.left + 5, fm.getAscent() + 4);
}
}
}
diff --git a/javax/swing/plaf/metal/MetalComboBoxEditor.java b/javax/swing/plaf/metal/MetalComboBoxEditor.java
index c086ee70c..c2bea9f5f 100644
--- a/javax/swing/plaf/metal/MetalComboBoxEditor.java
+++ b/javax/swing/plaf/metal/MetalComboBoxEditor.java
@@ -51,8 +51,7 @@ import javax.swing.plaf.metal.MetalBorders.Flush3DBorder;
/**
* An editor used by the {@link MetalComboBoxUI} class.
*/
-public class MetalComboBoxEditor
- extends BasicComboBoxEditor
+public class MetalComboBoxEditor extends BasicComboBoxEditor
{
/**
* A border used for the {@link JTextField} component.
@@ -64,6 +63,7 @@ public class MetalComboBoxEditor
*/
public MetalComboBoxEditorBorder()
{
+ // Nothing to do here.
}
/**
@@ -116,8 +116,7 @@ public class MetalComboBoxEditor
* A subclass of {@link MetalComboBoxEditor} that implements the
* {@link javax.swing.plaf.UIResource} interface.
*/
- public static class UIResource
- extends MetalComboBoxEditor
+ public static class UIResource extends MetalComboBoxEditor
implements javax.swing.plaf.UIResource
{
/**
@@ -125,6 +124,7 @@ public class MetalComboBoxEditor
*/
public UIResource()
{
+ // Nothing to do here.
}
}
diff --git a/javax/swing/plaf/metal/MetalComboBoxUI.java b/javax/swing/plaf/metal/MetalComboBoxUI.java
index 7297d1a30..81bb3e768 100644
--- a/javax/swing/plaf/metal/MetalComboBoxUI.java
+++ b/javax/swing/plaf/metal/MetalComboBoxUI.java
@@ -41,6 +41,7 @@ package javax.swing.plaf.metal;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
+import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
@@ -49,6 +50,7 @@ import java.beans.PropertyChangeListener;
import javax.swing.CellRendererPane;
import javax.swing.ComboBoxEditor;
+import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
@@ -61,8 +63,7 @@ import javax.swing.plaf.basic.ComboPopup;
/**
* A UI delegate for the {@link JComboBox} component.
*/
-public class MetalComboBoxUI
- extends BasicComboBoxUI
+public class MetalComboBoxUI extends BasicComboBoxUI
{
/**
* A layout manager that arranges the editor component (if active) and the
@@ -75,7 +76,8 @@ public class MetalComboBoxUI
* Creates a new instance of the layout manager.
*/
public MetalComboBoxLayoutManager()
- {
+ {
+ // Nothing to do here.
}
/**
@@ -121,6 +123,7 @@ public class MetalComboBoxUI
*/
public MetalPropertyChangeListener()
{
+ // Nothing to do here.
}
/**
@@ -209,8 +212,10 @@ public class MetalComboBoxUI
*/
protected JButton createArrowButton()
{
- return new MetalComboBoxButton(comboBox, new MetalComboBoxIcon(),
+ JButton button = new MetalComboBoxButton(comboBox, new MetalComboBoxIcon(),
new CellRendererPane(), listBox);
+ button.setMargin(new Insets(0, 1, 1, 3));
+ return button;
}
/**
@@ -251,7 +256,11 @@ public class MetalComboBoxUI
}
else
{
- arrowButton.setText(comboBox.getSelectedItem().toString());
+ String text = "";
+ Object selected = comboBox.getSelectedItem();
+ if (selected != null)
+ text = selected.toString();
+ arrowButton.setText(text);
if (editor != null)
editor.setVisible(true);
}
@@ -286,10 +295,15 @@ public class MetalComboBoxUI
*/
public Dimension getMinimumSize(JComponent c)
{
- // FIXME: this needs work
- Dimension result = super.getMinimumSize(c);
- result.height = result.height + 9;
- return result;
+ MetalComboBoxButton b = (MetalComboBoxButton) arrowButton;
+ Icon icon = b.getComboIcon();
+ Insets insets = b.getInsets();
+ Dimension d = getDisplaySize();
+ int insetsH = insets.top + insets.bottom;
+ int insetsW = insets.left + insets.right;
+ int iconWidth = icon.getIconWidth() + 6;
+ return new Dimension(d.width + insetsW + iconWidth,
+ d.height + insetsH);
}
}
diff --git a/javax/swing/plaf/metal/MetalDesktopIconUI.java b/javax/swing/plaf/metal/MetalDesktopIconUI.java
index 00870545b..ecbb76e6e 100644
--- a/javax/swing/plaf/metal/MetalDesktopIconUI.java
+++ b/javax/swing/plaf/metal/MetalDesktopIconUI.java
@@ -39,9 +39,13 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import javax.swing.JComponent;
+import javax.swing.JInternalFrame;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicDesktopIconUI;
+/**
+ * A UI delegate for the {@link JInternalFrame.JDesktopIcon} component.
+ */
public class MetalDesktopIconUI
extends BasicDesktopIconUI
{
@@ -51,7 +55,7 @@ public class MetalDesktopIconUI
private static MetalDesktopIconUI instance = null;
/**
- * Constructs a new instance of MetalDesktopIconUI.
+ * Constructs a new instance of <code>MetalDesktopIconUI</code>.
*/
public MetalDesktopIconUI()
{
@@ -59,11 +63,11 @@ public class MetalDesktopIconUI
}
/**
- * Returns an instance of MetalDesktopIconUI.
+ * Returns a shared instance of <code>MetalDesktopIconUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalDesktopIconUI
+ * @return A shared instance of <code>MetalDesktopIconUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
diff --git a/javax/swing/plaf/metal/MetalFileChooserUI.java b/javax/swing/plaf/metal/MetalFileChooserUI.java
new file mode 100644
index 000000000..3a2e1c135
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalFileChooserUI.java
@@ -0,0 +1,430 @@
+/* MetalFileChooserUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JList;
+import javax.swing.UIManager;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileSystemView;
+import javax.swing.filechooser.FileView;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicFileChooserUI;
+
+
+/**
+ * A UI delegate for the {@link JFileChooser} component. This class is only
+ * partially implemented and is not usable yet.
+ */
+public class MetalFileChooserUI extends BasicFileChooserUI
+{
+ /**
+ * A combo box model containing the selected directory and all its parent
+ * directories.
+ */
+ protected class DirectoryComboBoxModel extends AbstractListModel
+ implements ComboBoxModel
+ {
+ /** Storage for the items in the model. */
+ private List items;
+
+ /** The index of the selected item. */
+ private int selectedIndex;
+
+ /**
+ * Creates a new model.
+ */
+ public DirectoryComboBoxModel()
+ {
+ items = new java.util.ArrayList();
+ selectedIndex = -1;
+ }
+
+ /**
+ * Returns the number of items in the model.
+ *
+ * @return The number of items in the model.
+ */
+ public int getSize()
+ {
+ return items.size();
+ }
+
+ /**
+ * Returns the item at the specified index.
+ *
+ * @param index the item index.
+ *
+ * @return The item.
+ */
+ public Object getElementAt(int index)
+ {
+ return items.get(index);
+ }
+
+ /**
+ * Returns the depth of the item at the given <code>index</code>.
+ *
+ * @param index the item index.
+ *
+ * @return The depth.
+ */
+ public int getDepth(int index)
+ {
+ return Math.max(index, 0);
+ }
+
+ /**
+ * Returns the selected item, or <code>null</code> if no item is selected.
+ *
+ * @return The selected item, or <code>null</code>.
+ */
+ public Object getSelectedItem()
+ {
+ if (selectedIndex >= 0)
+ return items.get(selectedIndex);
+ else
+ return null;
+ }
+
+ /**
+ * Sets the selected item. This clears all the directories from the
+ * existing list, and repopulates it with the new selected directory
+ * and all its parent directories.
+ *
+ * @param selectedDirectory the selected directory.
+ */
+ public void setSelectedItem(Object selectedDirectory)
+ {
+ items.clear();
+ FileSystemView fsv = getFileChooser().getFileSystemView();
+ File parent = (File) selectedDirectory;
+ while (parent != null)
+ {
+ items.add(0, parent);
+ parent = fsv.getParentDirectory(parent);
+ }
+ selectedIndex = items.indexOf(selectedDirectory);
+ fireContentsChanged(this, 0, items.size() - 1);
+ }
+
+ }
+
+ /**
+ * Handles changes to the selection in the directory combo box.
+ */
+ protected class DirectoryComboBoxAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ protected DirectoryComboBoxAction()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Handles the action event.
+ *
+ * @param e the event.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ JFileChooser fc = getFileChooser();
+ fc.setCurrentDirectory((File) directoryModel.getSelectedItem());
+ }
+ }
+
+ /**
+ * A renderer for the files and directories in the file chooser.
+ */
+ protected class FileRenderer extends DefaultListCellRenderer
+ {
+
+ /**
+ * Creates a new renderer.
+ */
+ protected FileRenderer()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns a component that can render the specified value.
+ *
+ * @param list the list.
+ * @param value the value (a {@link File}).
+ * @param index the index.
+ * @param isSelected is the item selected?
+ * @param cellHasFocus does the item have the focus?
+ *
+ * @return The renderer.
+ */
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus)
+ {
+ FileView v = getFileView(getFileChooser());
+ File f = (File) value;
+ setText(v.getName(f));
+ setIcon(v.getIcon(f));
+ if (isSelected)
+ {
+ setBackground(list.getSelectionBackground());
+ setForeground(list.getSelectionForeground());
+ }
+ else
+ {
+ setBackground(list.getBackground());
+ setForeground(list.getForeground());
+ }
+
+ setEnabled(list.isEnabled());
+ setFont(list.getFont());
+
+ if (cellHasFocus)
+ setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
+ else
+ setBorder(noFocusBorder);
+ return this;
+ }
+ }
+
+ /**
+ * A combo box model for the file selection filters.
+ */
+ protected class FilterComboBoxModel
+ extends AbstractListModel
+ implements ComboBoxModel, PropertyChangeListener
+ {
+
+ /** Storage for the filters in the model. */
+ protected FileFilter[] filters;
+
+ /** The index of the selected file filter. */
+ private int selectedIndex;
+
+ /**
+ * Creates a new model.
+ */
+ protected FilterComboBoxModel()
+ {
+ filters = new FileFilter[1];
+ filters[0] = getAcceptAllFileFilter(getFileChooser());
+ selectedIndex = 0;
+ }
+
+ /**
+ * Handles property changes.
+ *
+ * @param e the property change event.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
+ {
+ selectedIndex = -1;
+ FileFilter selected = (FileFilter) e.getNewValue();
+ for (int i = 0; i < filters.length; i++)
+ if (filters[i].equals(selected))
+ selectedIndex = i;
+ fireContentsChanged(this, -1, -1);
+ }
+ else if (e.getPropertyName().equals(
+ JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY))
+ {
+ // repopulate list
+ JFileChooser fc = getFileChooser();
+ FileFilter[] choosableFilters = fc.getChoosableFileFilters();
+ filters = choosableFilters;
+ fireContentsChanged(this, 0, filters.length);
+ }
+ }
+
+ /**
+ * Sets the selected filter.
+ *
+ * @param filter the filter.
+ */
+ public void setSelectedItem(Object filter)
+ {
+ // change the filter in the file chooser and let the property change
+ // event trigger the change to the selected item
+ getFileChooser().setFileFilter((FileFilter) filter);
+ }
+
+ /**
+ * Returns the selected file filter.
+ *
+ * @return The selected file filter.
+ */
+ public Object getSelectedItem()
+ {
+ if (selectedIndex >= 0)
+ return filters[selectedIndex];
+ return null;
+ }
+
+ /**
+ * Returns the number of items in the model.
+ *
+ * @return The number of items in the model.
+ */
+ public int getSize()
+ {
+ return filters.length;
+ }
+
+ /**
+ * Returns the item at the specified index.
+ *
+ * @param index the item index.
+ *
+ * @return The item at the specified index.
+ */
+ public Object getElementAt(int index)
+ {
+ return filters[index];
+ }
+
+ }
+
+ /**
+ * A renderer for the items in the file filter combo box.
+ */
+ public class FilterComboBoxRenderer extends DefaultListCellRenderer
+ {
+ /**
+ * Creates a new renderer.
+ */
+ public FilterComboBoxRenderer()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns a component that can be used to paint the given value within
+ * the list.
+ *
+ * @param list the list.
+ * @param value the value (a {@link FileFilter}).
+ * @param index the item index.
+ * @param isSelected is the item selected?
+ * @param cellHasFocus does the list cell have focus?
+ *
+ * @return A component.
+ */
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus)
+ {
+ FileFilter filter = (FileFilter) value;
+ return super.getListCellRendererComponent(list, filter.getDescription(),
+ index, isSelected, cellHasFocus);
+ }
+ }
+
+ /** The model for the directory combo box. */
+ DirectoryComboBoxModel directoryModel;
+
+ /**
+ * A factory method that returns a UI delegate for the specified
+ * component.
+ *
+ * @param c the component (which should be a {@link JFileChooser}).
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ JFileChooser chooser = (JFileChooser) c;
+ return new MetalFileChooserUI(chooser);
+ }
+
+ /**
+ * Creates a new instance of this UI delegate.
+ *
+ * @param filechooser the file chooser component.
+ */
+ public MetalFileChooserUI(JFileChooser filechooser)
+ {
+ super(filechooser);
+ }
+
+ /**
+ * Creates and returns a new instance of {@link DirectoryComboBoxModel}.
+ *
+ * @return A new instance of {@link DirectoryComboBoxModel}.
+ */
+ protected MetalFileChooserUI.DirectoryComboBoxModel
+ createDirectoryComboBoxModel(JFileChooser fc)
+ {
+ return new DirectoryComboBoxModel();
+ }
+
+ /**
+ * Creates and returns a new instance of {@link FilterComboBoxModel}.
+ *
+ * @return A new instance of {@link FilterComboBoxModel}.
+ */
+ protected FilterComboBoxModel createFilterComboBoxModel()
+ {
+ return new FilterComboBoxModel();
+ }
+
+ /**
+ * Creates and returns a new instance of {@link FilterComboBoxRenderer}.
+ *
+ * @return A new instance of {@link FilterComboBoxRenderer}.
+ */
+ protected MetalFileChooserUI.FilterComboBoxRenderer
+ createFilterComboBoxRenderer()
+ {
+ return new FilterComboBoxRenderer();
+ }
+
+}
diff --git a/javax/swing/plaf/metal/MetalIconFactory.java b/javax/swing/plaf/metal/MetalIconFactory.java
index 0c52272e2..6f4feccfc 100644
--- a/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/javax/swing/plaf/metal/MetalIconFactory.java
@@ -77,6 +77,7 @@ public class MetalIconFactory implements Serializable
*/
public CheckBoxMenuItemIcon()
{
+ // Nothing to do here.
}
/**
@@ -144,14 +145,15 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserDetailViewIcon()
*/
- private static class FileChooserDetailViewIcon
- implements Icon, Serializable {
-
+ private static class FileChooserDetailViewIcon implements Icon, Serializable
+ {
+
/**
* Creates a new icon.
*/
public FileChooserDetailViewIcon()
{
+ // Nothing to do here.
}
/**
@@ -223,14 +225,15 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserHomeFolderIcon()
*/
- private static class FileChooserHomeFolderIcon
- implements Icon, Serializable {
-
+ private static class FileChooserHomeFolderIcon implements Icon, Serializable
+ {
+
/**
* Creates a new icon.
*/
public FileChooserHomeFolderIcon()
{
+ // Nothing to do here.
}
/**
@@ -318,6 +321,7 @@ public class MetalIconFactory implements Serializable
*/
public FileChooserListViewIcon()
{
+ // Nothing to do here.
}
/**
@@ -406,14 +410,14 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserNewFolderIcon()
*/
- private static class FileChooserNewFolderIcon
- implements Icon, Serializable
+ private static class FileChooserNewFolderIcon implements Icon, Serializable
{
/**
* Creates a new icon.
*/
public FileChooserNewFolderIcon()
{
+ // Nothing to do here.
}
/**
@@ -478,8 +482,7 @@ public class MetalIconFactory implements Serializable
*
* @see MetalIconFactory#getFileChooserNewFolderIcon()
*/
- private static class FileChooserUpFolderIcon
- extends FileChooserNewFolderIcon
+ private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon
implements Icon, Serializable
{
/**
@@ -487,6 +490,7 @@ public class MetalIconFactory implements Serializable
*/
public FileChooserUpFolderIcon()
{
+ // Nothing to do here.
}
/**
@@ -531,13 +535,15 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the height of the icon, in pixels.
+ * Returns the height of the icon, in pixels. The height returned is
+ * <code>16</code> plus the value returned by
+ * {@link #getAdditionalHeight()}.
*
* @return The height of the icon.
*/
public int getIconHeight()
{
- return 16;
+ return 16 + getAdditionalHeight();
}
/**
@@ -570,9 +576,11 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for the icon. The
+ * {@link #getIconHeight()} method adds this value to the icon height it
+ * returns. Subclasses can override this method to adjust the icon height.
*
- * @return The additional height.
+ * @return The additional height (<code>0</code> unless overridden).
*/
public int getAdditionalHeight()
{
@@ -606,13 +614,15 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the height of the icon, in pixels.
+ * Returns the height of the icon, in pixels. The height returned is
+ * <code>16</code> plus the value returned by
+ * {@link #getAdditionalHeight()}.
*
* @return The height of the icon.
*/
public int getIconHeight()
{
- return 16;
+ return 16 + getAdditionalHeight();
}
/**
@@ -643,9 +653,11 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for the icon. The
+ * {@link #getIconHeight()} method adds this value to the icon height it
+ * returns. Subclasses can override this method to adjust the icon height.
*
- * @return The additional height.
+ * @return The additional height (<code>0</code> unless overridden).
*/
public int getAdditionalHeight()
{
@@ -670,7 +682,7 @@ public class MetalIconFactory implements Serializable
*
* @since 1.3
*/
- public static class PaletteCloseIcon
+ public static class PaletteCloseIcon
implements Icon, Serializable, UIResource
{
/**
@@ -732,8 +744,7 @@ public class MetalIconFactory implements Serializable
*
* @author Roman Kennke (roman@kennke.org)
*/
- static class RadioButtonIcon
- implements Icon, UIResource, Serializable
+ static class RadioButtonIcon implements Icon, UIResource, Serializable
{
/**
@@ -847,14 +858,14 @@ public class MetalIconFactory implements Serializable
/**
* An icon displayed for {@link JRadioButtonMenuItem} components.
*/
- private static class RadioButtonMenuItemIcon
- implements Icon, Serializable
+ private static class RadioButtonMenuItemIcon implements Icon, Serializable
{
/**
* Creates a new icon instance.
*/
public RadioButtonMenuItemIcon()
- {
+ {
+ // Nothing to do here.
}
/**
@@ -924,8 +935,7 @@ public class MetalIconFactory implements Serializable
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
- private static class HorizontalSliderThumbIcon
- implements Icon, Serializable
+ private static class HorizontalSliderThumbIcon implements Icon, Serializable
{
/**
@@ -933,6 +943,7 @@ public class MetalIconFactory implements Serializable
*/
public HorizontalSliderThumbIcon()
{
+ // Nothing to do here.
}
/**
@@ -1042,7 +1053,7 @@ public class MetalIconFactory implements Serializable
* An icon used for the 'close' button in the title frame of a
* {@link JInternalFrame}.
*/
- private static class InternalFrameCloseIcon implements Icon, Serializable
+ private static class InternalFrameCloseIcon implements Icon, Serializable
{
/** The icon size in pixels. */
private int size;
@@ -1158,8 +1169,8 @@ public class MetalIconFactory implements Serializable
/**
* The icon displayed at the top-left corner of a {@link JInternalFrame}.
*/
- private static class InternalFrameDefaultMenuIcon
- implements Icon, Serializable
+ private static class InternalFrameDefaultMenuIcon
+ implements Icon, Serializable
{
/**
@@ -1167,6 +1178,7 @@ public class MetalIconFactory implements Serializable
*/
public InternalFrameDefaultMenuIcon()
{
+ // Nothing to do here.
}
/**
@@ -1229,8 +1241,8 @@ public class MetalIconFactory implements Serializable
* maximise an internal frame, this icon will replace the 'maximise' icon to
* provide a 'restore' option.
*/
- private static class InternalFrameAltMaximizeIcon
- implements Icon, Serializable
+ private static class InternalFrameAltMaximizeIcon
+ implements Icon, Serializable
{
/** The icon size in pixels. */
private int size;
@@ -1340,8 +1352,7 @@ public class MetalIconFactory implements Serializable
* An icon used for the 'maximize' button in the title frame of a
* {@link JInternalFrame}.
*/
- private static class InternalFrameMaximizeIcon
- implements Icon, Serializable
+ private static class InternalFrameMaximizeIcon implements Icon, Serializable
{
/**
@@ -1349,6 +1360,7 @@ public class MetalIconFactory implements Serializable
*/
public InternalFrameMaximizeIcon()
{
+ // Nothing to do here.
}
/**
@@ -1452,8 +1464,7 @@ public class MetalIconFactory implements Serializable
/**
* An icon used in the title frame of a {@link JInternalFrame}.
*/
- private static class InternalFrameMinimizeIcon
- implements Icon, Serializable
+ private static class InternalFrameMinimizeIcon implements Icon, Serializable
{
/**
@@ -1461,6 +1472,7 @@ public class MetalIconFactory implements Serializable
*/
public InternalFrameMinimizeIcon()
{
+ // Nothing to do here.
}
/**
@@ -1556,13 +1568,14 @@ public class MetalIconFactory implements Serializable
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
- private static class VerticalSliderThumbIcon implements Icon, Serializable
+ private static class VerticalSliderThumbIcon implements Icon, Serializable
{
/**
* Creates a new instance.
*/
public VerticalSliderThumbIcon()
{
+ // Nothing to do here.
}
/**
@@ -1673,7 +1686,7 @@ public class MetalIconFactory implements Serializable
* A tree control icon. This icon can be in one of two states: expanded and
* collapsed.
*/
- public static class TreeControlIcon implements Icon, Serializable
+ public static class TreeControlIcon implements Icon, Serializable
{
/** ???. */
@@ -1806,19 +1819,21 @@ public class MetalIconFactory implements Serializable
/**
* A tree folder icon.
*/
- public static class TreeFolderIcon extends FolderIcon16
+ public static class TreeFolderIcon extends FolderIcon16
{
/**
* Creates a new instance.
*/
public TreeFolderIcon()
- {
+ {
+ // Nothing to do here.
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for this icon, in this case <code>2</code>
+ * pixels.
*
- * @return The additional height.
+ * @return <code>2</code>.
*/
public int getAdditionalHeight()
{
@@ -1839,19 +1854,21 @@ public class MetalIconFactory implements Serializable
/**
* A tree leaf icon.
*/
- public static class TreeLeafIcon extends FileIcon16
+ public static class TreeLeafIcon extends FileIcon16
{
/**
* Creates a new instance.
*/
public TreeLeafIcon()
{
+ // Nothing to do here.
}
/**
- * Returns the additional height (???).
+ * Returns the additional height for this icon, in this case <code>4</code>
+ * pixels.
*
- * @return The additional height.
+ * @return <code>4</code>.
*/
public int getAdditionalHeight()
{
@@ -1868,16 +1885,310 @@ public class MetalIconFactory implements Serializable
return 2;
}
}
+
+ /**
+ * An icon representing a hard disk.
+ *
+ * @see MetalIconFactory#getTreeHardDriveIcon()
+ */
+ private static class TreeHardDriveIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeHardDriveIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 1, y + 4, x + 1, y + 5);
+ g.drawLine(x + 14, y + 4, x + 14, y + 5);
+ g.drawLine(x + 1, y + 7, x + 1, y + 8);
+ g.drawLine(x + 14, y + 7, x + 14, y + 8);
+ g.drawLine(x + 1, y + 10, x + 1, y + 11);
+ g.drawLine(x + 14, y + 10, x + 14, y + 11);
+
+ g.drawLine(x + 2, y + 3, x + 3, y + 3);
+ g.drawLine(x + 12, y + 3, x + 13, y + 3);
+ g.drawLine(x + 2, y + 6, x + 3, y + 6);
+ g.drawLine(x + 12, y + 6, x + 13, y + 6);
+ g.drawLine(x + 2, y + 9, x + 3, y + 9);
+ g.drawLine(x + 12, y + 9, x + 13, y + 9);
+ g.drawLine(x + 2, y + 12, x + 3, y + 12);
+ g.drawLine(x + 12, y + 12, x + 13, y + 12);
+
+ g.drawLine(x + 4, y + 2, x + 11, y + 2);
+ g.drawLine(x + 4, y + 7, x + 11, y + 7);
+ g.drawLine(x + 4, y + 10, x + 11, y + 10);
+ g.drawLine(x + 4, y + 13, x + 11, y + 13);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.fillRect(x + 4, y + 3, 2, 2);
+ g.drawLine(x + 6, y + 4, x + 6, y + 4);
+ g.drawLine(x + 7, y + 3, x + 9, y + 3);
+ g.drawLine(x + 8, y + 4, x + 8, y + 4);
+ g.drawLine(x + 11, y + 3, x + 11, y + 3);
+ g.fillRect(x + 2, y + 4, 2, 2);
+ g.fillRect(x + 2, y + 7, 2, 2);
+ g.fillRect(x + 2, y + 10, 2, 2);
+ g.drawLine(x + 4, y + 6, x + 4, y + 6);
+ g.drawLine(x + 4, y + 9, x + 4, y + 9);
+ g.drawLine(x + 4, y + 12, x + 4, y + 12);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 13, y + 4, x + 13, y + 4);
+ g.drawLine(x + 12, y + 5, x + 13, y + 5);
+ g.drawLine(x + 13, y + 7, x + 13, y + 7);
+ g.drawLine(x + 12, y + 8, x + 13, y + 8);
+ g.drawLine(x + 13, y + 10, x + 13, y + 10);
+ g.drawLine(x + 12, y + 11, x + 13, y + 11);
+
+ g.drawLine(x + 10, y + 5, x + 10, y + 5);
+ g.drawLine(x + 7, y + 6, x + 7, y + 6);
+ g.drawLine(x + 9, y + 6, x + 9, y + 6);
+ g.drawLine(x + 11, y + 6, x + 11, y + 6);
+
+ g.drawLine(x + 10, y + 8, x + 10, y + 8);
+ g.drawLine(x + 7, y + 9, x + 7, y + 9);
+ g.drawLine(x + 9, y + 9, x + 9, y + 9);
+ g.drawLine(x + 11, y + 9, x + 11, y + 9);
+
+ g.drawLine(x + 10, y + 11, x + 10, y + 11);
+ g.drawLine(x + 7, y + 12, x + 7, y + 12);
+ g.drawLine(x + 9, y + 12, x + 9, y + 12);
+ g.drawLine(x + 11, y + 12, x + 11, y + 12);
+
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * An icon representing a floppy disk.
+ *
+ * @see MetalIconFactory#getTreeFloppyDriveIcon()
+ */
+ private static class TreeFloppyDriveIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeFloppyDriveIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + 14);
+ g.drawLine(x + 1, y + 14, x + 14, y + 14);
+ g.drawLine(x + 14, y + 2, x + 14, y + 14);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 2, 12, 12);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.fillRect(x + 5, y + 2, 6, 5);
+ g.drawLine(x + 4, y + 8, x + 11, y + 8);
+ g.drawLine(x + 3, y + 9, x + 3, y + 13);
+ g.drawLine(x + 12, y + 9, x + 12, y + 13);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.fillRect(x + 8, y + 3, 2, 3);
+ g.fillRect(x + 4, y + 9, 8, 5);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.drawLine(x + 5, y + 10, x + 9, y + 10);
+ g.drawLine(x + 5, y + 12, x + 8, y + 12);
+
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * An icon representing a computer.
+ *
+ * @see MetalIconFactory#getTreeComputerIcon()
+ */
+ private static class TreeComputerIcon implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeComputerIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 1, x + 12, y + 1);
+ g.drawLine(x + 2, y + 2, x + 2, y + 8);
+ g.drawLine(x + 13, y + 2, x + 13, y + 8);
+ g.drawLine(x + 3, y + 9, x + 3, y + 9);
+ g.drawLine(x + 12, y + 9, x + 12, y + 9);
+ g.drawRect(x + 1, y + 10, 13, 4);
+ g.drawLine(x + 5, y + 3, x + 10, y + 3);
+ g.drawLine(x + 5, y + 8, x + 10, y + 8);
+ g.drawLine(x + 4, y + 4, x + 4, y + 7);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 5, y + 4, 6, 4);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 6, y + 12, x + 8, y + 12);
+ g.drawLine(x + 10, y + 12, x + 12, y + 12);
+ g.setColor(saved);
+ }
+ }
+ /** The icon returned by {@link #getCheckBoxIcon()}. */
+ private static Icon checkBoxIcon;
+
+ /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
+ private static Icon checkBoxMenuItemIcon;
+
+ /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
+ private static Icon fileChooserDetailViewIcon;
+
+ /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
+ private static Icon fileChooserHomeFolderIcon;
+
+ /** The icon returned by {@link #getFileChooserListViewIcon()}. */
+ private static Icon fileChooserListViewIcon;
+
+ /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
+ private static Icon fileChooserNewFolderIcon;
+
+ /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
+ private static Icon fileChooserUpFolderIcon;
+
/** The cached RadioButtonIcon instance. */
private static RadioButtonIcon radioButtonIcon;
+ /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
+ private static Icon radioButtonMenuItemIcon;
+
+ /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
+ private static Icon internalFrameDefaultMenuIcon;
+
+ /** The icon returned by {@link #getTreeComputerIcon()}. */
+ private static Icon treeComputerIcon;
+
+ /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
+ private static Icon treeFloppyDriveIcon;
+
+ /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
+ private static Icon treeHardDriveIcon;
+
/**
* Creates a new instance. All the methods are static, so creating an
* instance isn't necessary.
*/
public MetalIconFactory()
- {
+ {
+ // Nothing to do here.
}
/**
@@ -1889,7 +2200,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getCheckBoxIcon()
{
- return new MetalCheckBoxIcon();
+ if (checkBoxIcon == null)
+ checkBoxIcon = new MetalCheckBoxIcon();
+ return checkBoxIcon;
}
/**
@@ -1900,7 +2213,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getCheckBoxMenuItemIcon()
{
- return new CheckBoxMenuItemIcon();
+ if (checkBoxMenuItemIcon == null)
+ checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
+ return checkBoxMenuItemIcon;
}
/**
@@ -1910,7 +2225,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getFileChooserDetailViewIcon()
{
- return new FileChooserDetailViewIcon();
+ if (fileChooserDetailViewIcon == null)
+ fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
+ return fileChooserDetailViewIcon;
}
/**
@@ -1920,7 +2237,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getFileChooserHomeFolderIcon()
{
- return new FileChooserHomeFolderIcon();
+ if (fileChooserHomeFolderIcon == null)
+ fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
+ return fileChooserHomeFolderIcon;
}
/**
@@ -1930,7 +2249,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getFileChooserListViewIcon()
{
- return new FileChooserListViewIcon();
+ if (fileChooserListViewIcon == null)
+ fileChooserListViewIcon = new FileChooserListViewIcon();
+ return fileChooserListViewIcon;
}
/**
@@ -1940,7 +2261,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getFileChooserNewFolderIcon()
{
- return new FileChooserNewFolderIcon();
+ if (fileChooserNewFolderIcon == null)
+ fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
+ return fileChooserNewFolderIcon;
}
/**
@@ -1950,7 +2273,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getFileChooserUpFolderIcon()
{
- return new FileChooserUpFolderIcon();
+ if (fileChooserUpFolderIcon == null)
+ fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
+ return fileChooserUpFolderIcon;
}
/**
@@ -1972,7 +2297,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getRadioButtonMenuItemIcon()
{
- return new RadioButtonMenuItemIcon();
+ if (radioButtonMenuItemIcon == null)
+ radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
+ return radioButtonMenuItemIcon;
}
/**
@@ -2007,7 +2334,9 @@ public class MetalIconFactory implements Serializable
*/
public static Icon getInternalFrameDefaultMenuIcon()
{
- return new InternalFrameDefaultMenuIcon();
+ if (internalFrameDefaultMenuIcon == null)
+ internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
+ return internalFrameDefaultMenuIcon;
}
/**
@@ -2096,4 +2425,40 @@ public class MetalIconFactory implements Serializable
return new TreeControlIcon(isCollapsed);
}
+ /**
+ * Returns a <code>16x16</code> icon representing a computer.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeComputerIcon()
+ {
+ if (treeComputerIcon == null)
+ treeComputerIcon = new TreeComputerIcon();
+ return treeComputerIcon;
+ }
+
+ /**
+ * Returns a <code>16x16</code> icon representing a floppy disk.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeFloppyDriveIcon()
+ {
+ if (treeFloppyDriveIcon == null)
+ treeFloppyDriveIcon = new TreeFloppyDriveIcon();
+ return treeFloppyDriveIcon;
+ }
+
+ /**
+ * Returns a <code>16x16</code> icon representing a hard disk.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeHardDriveIcon()
+ {
+ if (treeHardDriveIcon == null)
+ treeHardDriveIcon = new TreeHardDriveIcon();
+ return treeHardDriveIcon;
+ }
+
}
diff --git a/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java b/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
index efae78417..33eb3491a 100644
--- a/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
+++ b/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
@@ -61,9 +61,10 @@ import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
/**
- * The title pane for a {@link JInternalFrame}. This can be displayed in two
- * styles: one for regular internal frames, and the other for "palette" style
- * internal frames.
+ * The title pane for a {@link JInternalFrame} (see
+ * {@link MetalInternalFrameUI#createNorthPane(JInternalFrame)}). This can
+ * be displayed in two styles: one for regular internal frames, and the other
+ * for "palette" style internal frames.
*/
public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
{
@@ -86,7 +87,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
/**
* Handles <code>JInternalFrame.isPalette</code> property changes, with all
- * other propert changes being passed to the superclass.
+ * other property changes being passed to the superclass.
*
* @param e the event.
*/
@@ -214,6 +215,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
*/
public void removeLayoutComponent(Component c)
{
+ // Nothing to do here.
}
}
@@ -234,7 +236,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
protected int paletteTitleHeight;
/** The label used to display the title for the internal frame. */
- private JLabel title;
+ JLabel title;
/**
* Creates a new title pane for the specified frame.
@@ -315,6 +317,9 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
// do nothing
}
+ /**
+ * Adds the sub components of the title pane.
+ */
protected void addSubComponents()
{
// FIXME: this method is probably overridden to only add the required
@@ -348,7 +353,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
Rectangle b = SwingUtilities.getLocalBounds(this);
g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
g.fillRect(b.x, b.y, b.width, b.height);
- MetalUtils.fillMetalPattern(g, b.x + 4, b.y + 2, b.width
+ MetalUtils.fillMetalPattern(this, g, b.x + 4, b.y + 2, b.width
- paletteCloseIcon.getIconWidth() - 13, b.height - 5,
MetalLookAndFeel.getPrimaryControlHighlight(),
MetalLookAndFeel.getBlack());
@@ -399,7 +404,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
endX = Math.max(closeButton.getX(), endX);
endX -= 7;
if (endX > startX)
- MetalUtils.fillMetalPattern(g, startX, 3, endX - startX, getHeight() - 6, Color.white, Color.gray);
+ MetalUtils.fillMetalPattern(this, g, startX, 3, endX - startX, getHeight() - 6, Color.white, Color.gray);
}
g.setColor(savedColor);
}
@@ -422,6 +427,11 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
closeButton.setIcon(closeIcon);
}
+ /**
+ * Creates and returns a property change handler for the title pane.
+ *
+ * @return The property change handler.
+ */
protected PropertyChangeListener createPropertyChangeListener()
{
return new MetalInternalFrameTitlePanePropertyChangeHandler();
diff --git a/javax/swing/plaf/metal/MetalInternalFrameUI.java b/javax/swing/plaf/metal/MetalInternalFrameUI.java
index 49b8a0661..6be573f4b 100644
--- a/javax/swing/plaf/metal/MetalInternalFrameUI.java
+++ b/javax/swing/plaf/metal/MetalInternalFrameUI.java
@@ -47,15 +47,15 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;
/**
- * A UI delegate for the {@link JInternalFrame} component under the
- * {@link MetalLookAndFeel}.
+ * A UI delegate for the {@link JInternalFrame} component.
*/
public class MetalInternalFrameUI
extends BasicInternalFrameUI
{
/**
- * The key for the client property that controls whether the internal frame
- * is displayed using the palette style.
+ * The key (<code>JInternalFrame.isPalette</code>) for the client property
+ * that controls whether the internal frame is displayed using the palette
+ * style.
*/
protected static String IS_PALETTE = "JInternalFrame.isPalette";
diff --git a/javax/swing/plaf/metal/MetalLabelUI.java b/javax/swing/plaf/metal/MetalLabelUI.java
index fe8a9e4e4..e4eaa7172 100644
--- a/javax/swing/plaf/metal/MetalLabelUI.java
+++ b/javax/swing/plaf/metal/MetalLabelUI.java
@@ -50,17 +50,17 @@ import javax.swing.plaf.basic.BasicGraphicsUtils;
import javax.swing.plaf.basic.BasicLabelUI;
/**
- * A UI delegate used for {@link JLabel}s in the {@link MetalLookAndFeel}.
+ * A UI delegate for the {@link JLabel} component.
*/
public class MetalLabelUI
extends BasicLabelUI
{
- /** The shared UI instance for JLabels. */
+ /** The shared instance of the UI delegate. */
protected static MetalLabelUI metalLabelUI;
/**
- * Constructs a new instance of MetalLabelUI.
+ * Constructs a new instance of <code>MetalLabelUI</code>.
*/
public MetalLabelUI()
{
@@ -68,11 +68,11 @@ public class MetalLabelUI
}
/**
- * Returns an instance of MetalLabelUI.
+ * Returns a shared instance of <code>MetalLabelUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalLabelUI
+ * @return A shared instance of <code>MetalLabelUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java
index 3bc9b25c8..5542c0b76 100644
--- a/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -42,11 +42,14 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
+import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
+import javax.swing.UIManager;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
+import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
@@ -78,7 +81,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
*/
protected void createDefaultTheme()
{
- setCurrentTheme(new OceanTheme());
+ setCurrentTheme(new DefaultMetalTheme());
}
/**
@@ -602,12 +605,21 @@ public class MetalLookAndFeel extends BasicLookAndFeel
}
/**
- * Sets the current theme for the look and feel.
+ * Sets the current theme for the look and feel. Note that the theme must be
+ * set <em>before</em> the look and feel is installed. To change the theme
+ * for an already running application that is using the
+ * {@link MetalLookAndFeel}, first set the theme with this method, then
+ * create a new instance of {@link MetalLookAndFeel} and install it in the
+ * usual way (see {@link UIManager#setLookAndFeel(LookAndFeel)}).
*
- * @param theme the theme.
+ * @param theme the theme (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>theme</code> is <code>null</code>.
*/
public static void setCurrentTheme(MetalTheme theme)
{
+ if (theme == null)
+ throw new NullPointerException("Null 'theme' not permitted.");
MetalLookAndFeel.theme = theme;
}
@@ -769,7 +781,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Button.foreground", getControlTextColor(),
"Button.highlight", getControlHighlight(),
"Button.light", getControlHighlight(),
- "Button.margin", new Insets(2, 14, 2, 14),
+ "Button.margin", new InsetsUIResource(2, 14, 2, 14),
"Button.select", getControlShadow(),
"Button.shadow", getControlShadow(),
@@ -845,6 +857,11 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"FormattedTextField.selectionBackground", getTextHighlightColor(),
"FormattedTextField.selectionForeground", getHighlightedTextColor(),
+ "FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
+ "FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
+ "FileView.fileIcon", MetalIconFactory.getTreeLeafIcon(),
+ "FileView.floppyDriveIcon", MetalIconFactory.getTreeFloppyDriveIcon(),
+ "FileView.hardDriveIcon", MetalIconFactory.getTreeHardDriveIcon(),
"InternalFrame.activeTitleBackground", getWindowTitleBackground(),
"InternalFrame.activeTitleForeground", getWindowTitleForeground(),
@@ -873,10 +890,13 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Label.font", getControlTextFont(),
"Label.foreground", getSystemTextColor(),
+ "List.font", getControlTextFont(),
"List.background", getWindowBackground(),
"List.foreground", getUserTextColor(),
"List.selectionBackground", getTextHighlightColor(),
"List.selectionForeground", getHighlightedTextColor(),
+ "List.focusCellHighlightBorder",
+ new LineBorderUIResource(MetalLookAndFeel.getFocusColor()),
"Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
"Menu.acceleratorForeground", getAcceleratorForeground(),
@@ -996,6 +1016,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ScrollBar.thumbShadow", getPrimaryControlDarkShadow(),
"ScrollBar.track", getControl(),
"ScrollBar.trackHighlight", getControlDarkShadow(),
+ "ScrollBar.width", new Integer(17),
"ScrollPane.background", getControl(),
"ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
@@ -1050,9 +1071,12 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Table.focusCellBackground", getWindowBackground(),
"Table.focusCellForeground", getControlTextColor(),
"Table.foreground", getControlTextColor(),
- "Table.focusCellHighlightBorder", getControlShadow(),
+ "Table.focusCellHighlightBorder",
+ new BorderUIResource.LineBorderUIResource(getControlShadow()),
"Table.focusCellBackground", getWindowBackground(),
"Table.gridColor", getControlDarkShadow(),
+ "Table.selectionBackground", new ColorUIResource(204, 204, 255),
+ "Table.selectionForeground", new ColorUIResource(0, 0, 0),
"TableHeader.background", getControl(),
"TableHeader.cellBorder", new MetalBorders.TableHeaderBorder(),
@@ -1116,6 +1140,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ToolBar.highlight", getControlHighlight(),
"ToolBar.light", getControlHighlight(),
"ToolBar.shadow", getControlShadow(),
+ "ToolBar.border", new MetalBorders.ToolBarBorder(),
"ToolTip.background", getPrimaryControl(),
"ToolTip.backgroundInactive", getControl(),
diff --git a/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java b/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
index ec9bf2b55..44a2d3bcd 100644
--- a/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
+++ b/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
@@ -39,8 +39,12 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
import javax.swing.plaf.ComponentUI;
+/**
+ * A UI delegate for the {@link JPopupMenu.Separator} component.
+ */
public class MetalPopupMenuSeparatorUI
extends MetalSeparatorUI
{
@@ -50,7 +54,7 @@ public class MetalPopupMenuSeparatorUI
private static MetalPopupMenuSeparatorUI instance = null;
/**
- * Constructs a new instance of MetalPopupMenuSeparatorUI.
+ * Constructs a new instance of <code>MetalPopupMenuSeparatorUI</code>.
*/
public MetalPopupMenuSeparatorUI()
{
@@ -58,11 +62,11 @@ public class MetalPopupMenuSeparatorUI
}
/**
- * Returns an instance of MetalPopupMenuSeparatorUI.
+ * Returns a shared instance of <code>MetalPopupMenuSeparatorUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalPopupMenuSeparatorUI
+ * @return A shared instance of <code>MetalPopupMenuSeparatorUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
diff --git a/javax/swing/plaf/metal/MetalProgressBarUI.java b/javax/swing/plaf/metal/MetalProgressBarUI.java
index a32590d0a..9241cf13c 100644
--- a/javax/swing/plaf/metal/MetalProgressBarUI.java
+++ b/javax/swing/plaf/metal/MetalProgressBarUI.java
@@ -38,20 +38,18 @@ exception statement from your version. */
package javax.swing.plaf.metal;
-import java.util.HashMap;
-
import javax.swing.JComponent;
+import javax.swing.JProgressBar;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicProgressBarUI;
-public class MetalProgressBarUI
- extends BasicProgressBarUI
+/**
+ * A UI delegate for the {@link JProgressBar} component.
+ */
+public class MetalProgressBarUI extends BasicProgressBarUI
{
- /** The UI instances for MetalTreeUIs */
- private static HashMap instances = null;
-
/**
- * Constructs a new instance of MetalProgressBarUI.
+ * Constructs a new instance of <code>MetalProgressBarUI</code>.
*/
public MetalProgressBarUI()
{
@@ -59,27 +57,14 @@ public class MetalProgressBarUI
}
/**
- * Returns an instance of MetalProgressBarUI.
+ * Returns a new instance of <code>MetalProgressBarUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalProgressBarUI
+ * @return A new instance of <code>MetalProgressBarUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
- if (instances == null)
- instances = new HashMap();
-
- Object o = instances.get(component);
- MetalProgressBarUI instance;
- if (o == null)
- {
- instance = new MetalProgressBarUI();
- instances.put(component, instance);
- }
- else
- instance = (MetalProgressBarUI) o;
-
- return instance;
+ return new MetalProgressBarUI();
}
}
diff --git a/javax/swing/plaf/metal/MetalRadioButtonUI.java b/javax/swing/plaf/metal/MetalRadioButtonUI.java
index 4e80718a7..c2e4ca546 100644
--- a/javax/swing/plaf/metal/MetalRadioButtonUI.java
+++ b/javax/swing/plaf/metal/MetalRadioButtonUI.java
@@ -53,8 +53,7 @@ import javax.swing.plaf.basic.BasicRadioButtonUI;
/**
- * A UI delegate for the {@link JRadioButton} component under the
- * {@link MetalLookAndFeel}.
+ * A UI delegate for the {@link JRadioButton} component.
*/
public class MetalRadioButtonUI
extends BasicRadioButtonUI
@@ -70,7 +69,7 @@ public class MetalRadioButtonUI
protected Color disabledTextColor;
/**
- * Constructs a new instance of MetalRadioButtonUI.
+ * Constructs a new instance of <code>MetalRadioButtonUI</code>.
*/
public MetalRadioButtonUI()
{
@@ -78,11 +77,11 @@ public class MetalRadioButtonUI
}
/**
- * Returns an instance of MetalRadioButtonUI.
+ * Returns a new instance of <code>MetalRadioButtonUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalRadioButtonUI
+ * @return A new instance of <code>MetalRadioButtonUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
@@ -179,9 +178,9 @@ public class MetalRadioButtonUI
protected void paintFocus(Graphics g, Rectangle t, Dimension d)
{
g.setColor(focusColor);
- g.drawRect(t.x, t.y, t.width, t.height);
- // FIXME: we seem to be drawing too tight a rectangle here, perhaps there
- // is some padding to do somewhere???
+ // minus 2 because of line thickness. Prevents border
+ // from being cutoff.
+ g.drawRect(t.x, t.y, t.width - 2, t.height - 2);
}
}
diff --git a/javax/swing/plaf/metal/MetalRootPaneUI.java b/javax/swing/plaf/metal/MetalRootPaneUI.java
index 4196a4e47..faed80382 100644
--- a/javax/swing/plaf/metal/MetalRootPaneUI.java
+++ b/javax/swing/plaf/metal/MetalRootPaneUI.java
@@ -39,9 +39,16 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import javax.swing.JComponent;
+import javax.swing.JRootPane;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicRootPaneUI;
+/**
+ * A UI delegate for the {@link JRootPane} component. This class is not fully
+ * implemented.
+ *
+ * @since 1.4
+ */
public class MetalRootPaneUI
extends BasicRootPaneUI
{
@@ -51,7 +58,7 @@ public class MetalRootPaneUI
private static MetalRootPaneUI instance = null;
/**
- * Constructs a new instance of MetalRootPaneUI.
+ * Constructs a shared instance of <code>MetalRootPaneUI</code>.
*/
public MetalRootPaneUI()
{
@@ -59,11 +66,11 @@ public class MetalRootPaneUI
}
/**
- * Returns an instance of MetalRootPaneUI.
+ * Returns a shared instance of <code>MetalRootPaneUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalRootPaneUI
+ * @return A shared instance of <code>MetalRootPaneUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
diff --git a/javax/swing/plaf/metal/MetalScrollBarUI.java b/javax/swing/plaf/metal/MetalScrollBarUI.java
index 5d7905a35..9602ade99 100644
--- a/javax/swing/plaf/metal/MetalScrollBarUI.java
+++ b/javax/swing/plaf/metal/MetalScrollBarUI.java
@@ -56,8 +56,7 @@ import javax.swing.plaf.basic.BasicScrollBarUI;
/**
* A UI delegate for the {@link JScrollBar} component.
*/
-public class MetalScrollBarUI
- extends BasicScrollBarUI
+public class MetalScrollBarUI extends BasicScrollBarUI
{
/**
@@ -75,6 +74,7 @@ public class MetalScrollBarUI
*/
public MetalScrollBarPropertyChangeHandler()
{
+ // Nothing to do here.
}
/**
@@ -90,25 +90,35 @@ public class MetalScrollBarUI
{
Boolean prop = (Boolean) e.getNewValue();
isFreeStanding = (prop == null ? true : prop.booleanValue());
- increaseButton.setFreeStanding(isFreeStanding);
- decreaseButton.setFreeStanding(isFreeStanding);
+ if (increaseButton != null)
+ increaseButton.setFreeStanding(isFreeStanding);
+ if (decreaseButton != null)
+ decreaseButton.setFreeStanding(isFreeStanding);
}
+ else
+ super.propertyChange(e);
}
}
/** The name for the 'free standing' property. */
public static final String FREE_STANDING_PROP = "JScrollBar.isFreeStanding";
- /** The minimum thumb size */
- private static final Dimension MIN_THUMB_SIZE = new Dimension(17, 17);
+ /** The minimum thumb size for a scroll bar that is not free standing. */
+ private static final Dimension MIN_THUMB_SIZE = new Dimension(15, 15);
+ /** The minimum thumb size for a scroll bar that is free standing. */
+ private static final Dimension MIN_THUMB_SIZE_FREE_STANDING
+ = new Dimension(17, 17);
+
/** The button that increases the value in the scroll bar. */
protected MetalScrollButton increaseButton;
/** The button that decreases the value in the scroll bar. */
protected MetalScrollButton decreaseButton;
- /** The scroll bar width. */
+ /**
+ * The scroll bar width.
+ */
protected int scrollBarWidth;
/**
@@ -117,10 +127,17 @@ public class MetalScrollBarUI
* scroll bar which is not free standing has borders missing from one
* side, and relies on being part of another container with its own borders
* to look right visually. */
- protected boolean isFreeStanding;
+ protected boolean isFreeStanding = true;
+
+ /**
+ * The color for the scroll bar shadow (this is read from the UIDefaults in
+ * the installDefaults() method).
+ */
+ Color scrollBarShadowColor;
/**
- * Constructs a new instance of MetalScrollBarUI.
+ * Constructs a new instance of <code>MetalScrollBarUI</code>, with no
+ * specific initialisation.
*/
public MetalScrollBarUI()
{
@@ -128,11 +145,11 @@ public class MetalScrollBarUI
}
/**
- * Returns an instance of MetalScrollBarUI.
+ * Returns a new instance of <code>MetalScrollBarUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalScrollBarUI
+ * @return An instance of MetalScrollBarUI
*/
public static ComponentUI createUI(JComponent component)
{
@@ -150,6 +167,7 @@ public class MetalScrollBarUI
// that we can do this).
Boolean prop = (Boolean) scrollbar.getClientProperty(FREE_STANDING_PROP);
isFreeStanding = (prop == null ? true : prop.booleanValue());
+ scrollBarShadowColor = UIManager.getColor("ScrollBar.shadow");
super.installDefaults();
}
@@ -179,7 +197,9 @@ public class MetalScrollBarUI
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
scrollBarWidth = defaults.getInt("ScrollBar.width");
- return new MetalScrollButton(orientation, scrollBarWidth, isFreeStanding);
+ decreaseButton = new MetalScrollButton(orientation, scrollBarWidth,
+ isFreeStanding);
+ return decreaseButton;
}
/**
@@ -195,7 +215,9 @@ public class MetalScrollBarUI
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
scrollBarWidth = defaults.getInt("ScrollBar.width");
- return new MetalScrollButton(orientation, scrollBarWidth, isFreeStanding);
+ increaseButton = new MetalScrollButton(orientation, scrollBarWidth,
+ isFreeStanding);
+ return increaseButton;
}
/**
@@ -239,7 +261,7 @@ public class MetalScrollBarUI
g.drawLine(x, y, x + w - 1, y);
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
- g.setColor(MetalLookAndFeel.getControlShadow());
+ g.setColor(scrollBarShadowColor);
g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
@@ -247,14 +269,21 @@ public class MetalScrollBarUI
{
g.setColor(MetalLookAndFeel.getControlDarkShadow());
g.drawLine(x, y + h - 2, x + w - 1, y + h - 2);
- g.setColor(MetalLookAndFeel.getControlShadow());
+ g.setColor(scrollBarShadowColor);
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
}
}
else
{
g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawRect(x, y, w - 1, h - 1);
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 1, h - 1);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+ }
}
}
@@ -268,7 +297,7 @@ public class MetalScrollBarUI
* @param w the width for the track bounds.
* @param h the height for the track bounds.
*/
- protected void paintTrackVertical(Graphics g, JComponent c,
+ private void paintTrackVertical(Graphics g, JComponent c,
int x, int y, int w, int h)
{
if (c.isEnabled())
@@ -278,10 +307,9 @@ public class MetalScrollBarUI
g.drawLine(x, y, x + w - 1, y);
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
- g.setColor(MetalLookAndFeel.getControlShadow());
+ g.setColor(scrollBarShadowColor);
g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
- g.drawLine(x + 1, y + h - 2, x + w - 1, y + h - 2);
if (isFreeStanding)
{
@@ -294,7 +322,14 @@ public class MetalScrollBarUI
else
{
g.setColor(MetalLookAndFeel.getControlDisabled());
- g.drawRect(x, y, w - 1, h - 1);
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 1, h - 1);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ }
}
}
@@ -310,54 +345,135 @@ public class MetalScrollBarUI
// a disabled scrollbar has no thumb in the metal look and feel
if (!c.isEnabled())
return;
+ if (scrollbar.getOrientation() == HORIZONTAL)
+ paintThumbHorizontal(g, c, thumbBounds);
+ else
+ paintThumbVertical(g, c, thumbBounds);
+
+ // draw the pattern
+ MetalUtils.fillMetalPattern(c, g, thumbBounds.x + 3, thumbBounds.y + 3,
+ thumbBounds.width - 6, thumbBounds.height - 6,
+ thumbHighlightColor, thumbLightShadowColor);
+ }
+
+ /**
+ * Paints the thumb for a horizontal scroll bar.
+ *
+ * @param g the graphics device.
+ * @param c the scroll bar component.
+ * @param thumbBounds the thumb bounds.
+ */
+ private void paintThumbHorizontal(Graphics g, JComponent c,
+ Rectangle thumbBounds)
+ {
+ int x = thumbBounds.x;
+ int y = thumbBounds.y;
+ int w = thumbBounds.width;
+ int h = thumbBounds.height;
// first we fill the background
g.setColor(thumbColor);
- g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width,
- thumbBounds.height);
-
- // draw the outer dark line
- int hAdj = 1;
- int wAdj = 1;
- if (scrollbar.getOrientation() == HORIZONTAL)
- hAdj++;
+ if (isFreeStanding)
+ g.fillRect(x, y, w, h - 1);
else
- wAdj++;
+ g.fillRect(x, y, w, h);
- g.setColor(new Color(102, 102, 153));
- g.drawRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - wAdj,
- thumbBounds.height - hAdj);
-
- // draw the inner light line
+ // then draw the dark box
+ g.setColor(thumbLightShadowColor);
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 1, h - 2);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x + w - 1, y, x + w - 1, y + h -1);
+ }
+
+ // then the highlight
g.setColor(thumbHighlightColor);
- g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1,
- thumbBounds.x + thumbBounds.width - 2,
- thumbBounds.y + 1);
- g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1,
- thumbBounds.x + 1,
- thumbBounds.y + thumbBounds.height - 2);
-
+ if (isFreeStanding)
+ {
+ g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
+ }
+ else
+ {
+ g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
+ }
+
// draw the shadow line
UIDefaults def = UIManager.getLookAndFeelDefaults();
g.setColor(def.getColor("ScrollBar.shadow"));
- g.drawLine(thumbBounds.x + 1, thumbBounds.y + thumbBounds.height,
- thumbBounds.x + thumbBounds.width,
- thumbBounds.y + thumbBounds.height);
+ g.drawLine(x + w, y + 1, x + w, y + h - 1);
- // draw the pattern
- MetalUtils.fillMetalPattern(g, thumbBounds.x + 3, thumbBounds.y + 3,
- thumbBounds.width - 6, thumbBounds.height - 6,
- thumbHighlightColor, new Color(102, 102, 153));
}
-
+
+ /**
+ * Paints the thumb for a vertical scroll bar.
+ *
+ * @param g the graphics device.
+ * @param c the scroll bar component.
+ * @param thumbBounds the thumb bounds.
+ */
+ private void paintThumbVertical(Graphics g, JComponent c,
+ Rectangle thumbBounds)
+ {
+ int x = thumbBounds.x;
+ int y = thumbBounds.y;
+ int w = thumbBounds.width;
+ int h = thumbBounds.height;
+
+ // first we fill the background
+ g.setColor(thumbColor);
+ if (isFreeStanding)
+ g.fillRect(x, y, w - 1, h);
+ else
+ g.fillRect(x, y, w, h);
+
+ // then draw the dark box
+ g.setColor(thumbLightShadowColor);
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 2, h - 1);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ }
+
+ // then the highlight
+ g.setColor(thumbHighlightColor);
+ if (isFreeStanding)
+ {
+ g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
+ }
+ else
+ {
+ g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
+ }
+
+ // draw the shadow line
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ g.setColor(def.getColor("ScrollBar.shadow"));
+ g.drawLine(x + 1, y + h, x + w - 2, y + h);
+ }
+
/**
- * This method returns the minimum thumb size.
+ * Returns the minimum thumb size. For a free standing scroll bar the
+ * minimum size is <code>17 x 17</code> pixels, whereas for a non free
+ * standing scroll bar the minimum size is <code>15 x 15</code> pixels.
*
* @return The minimum thumb size.
*/
protected Dimension getMinimumThumbSize()
{
- return MIN_THUMB_SIZE;
+ if (isFreeStanding)
+ return MIN_THUMB_SIZE_FREE_STANDING;
+ else
+ return MIN_THUMB_SIZE;
}
}
diff --git a/javax/swing/plaf/metal/MetalScrollButton.java b/javax/swing/plaf/metal/MetalScrollButton.java
index b9f53dc87..84f9cfe49 100644
--- a/javax/swing/plaf/metal/MetalScrollButton.java
+++ b/javax/swing/plaf/metal/MetalScrollButton.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
@@ -206,13 +207,13 @@ public class MetalScrollButton extends BasicArrowButton
g.drawLine(w - 2, 2, w - 2, h - 1);
g.setColor(MetalLookAndFeel.getControlHighlight());
- g.drawLine(1, 1, 1, h - 1);
- g.drawLine(1, 1, w - 1, 1);
+ g.drawLine(1, 1, 1, h - 2);
+ g.drawLine(1, 1, w - 3, 1);
g.drawLine(w - 1, 1, w - 1, h - 1);
g.setColor(MetalLookAndFeel.getControl());
g.drawLine(1, h - 1, 1, h - 1);
- g.drawLine(w - 1, 1, w - 1, 1);
+ g.drawLine(w - 2, 1, w - 2, 1);
}
else
{
diff --git a/javax/swing/plaf/metal/MetalScrollPaneUI.java b/javax/swing/plaf/metal/MetalScrollPaneUI.java
index 3e1198b39..31fd19d26 100644
--- a/javax/swing/plaf/metal/MetalScrollPaneUI.java
+++ b/javax/swing/plaf/metal/MetalScrollPaneUI.java
@@ -39,9 +39,13 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import javax.swing.JComponent;
+import javax.swing.JScrollPane;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollPaneUI;
+/**
+ * A UI delegate for the {@link JScrollPane} component.
+ */
public class MetalScrollPaneUI
extends BasicScrollPaneUI
{
@@ -51,7 +55,7 @@ public class MetalScrollPaneUI
private static MetalScrollPaneUI instance = null;
/**
- * Constructs a new instance of MetalScrollPaneUI.
+ * Constructs a new instance of <code>MetalScrollPaneUI</code>.
*/
public MetalScrollPaneUI()
{
@@ -59,11 +63,11 @@ public class MetalScrollPaneUI
}
/**
- * Returns an instance of MetalScrollPaneUI.
+ * Returns a shared instance of <code>MetalScrollPaneUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalScrollPaneUI
+ * @return A shared instance of <code>MetalScrollPaneUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
diff --git a/javax/swing/plaf/metal/MetalSeparatorUI.java b/javax/swing/plaf/metal/MetalSeparatorUI.java
index 6e78ccb70..1d48e9be2 100644
--- a/javax/swing/plaf/metal/MetalSeparatorUI.java
+++ b/javax/swing/plaf/metal/MetalSeparatorUI.java
@@ -38,10 +38,20 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
import javax.swing.JComponent;
+import javax.swing.JSeparator;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSeparatorUI;
+/**
+ * A UI delegate for the {@link JSeparator} component.
+ */
public class MetalSeparatorUI
extends BasicSeparatorUI
{
@@ -51,7 +61,7 @@ public class MetalSeparatorUI
private static MetalSeparatorUI instance = null;
/**
- * Constructs a new instance of MetalSeparatorUI.
+ * Constructs a new instance of <code>MetalSeparatorUI</code>.
*/
public MetalSeparatorUI()
{
@@ -59,11 +69,11 @@ public class MetalSeparatorUI
}
/**
- * Returns an instance of MetalSeparatorUI.
+ * Returns a shared instance of <code>MetalSeparatorUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalSeparatorUI
+ * @return A shared instance of <code>MetalSeparatorUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
@@ -71,4 +81,51 @@ public class MetalSeparatorUI
instance = new MetalSeparatorUI();
return instance;
}
+
+ /**
+ * The separator is made of two lines. The top line will be
+ * the Metal theme color separatorForeground (or left line if it's vertical).
+ * The bottom or right line will be the Metal theme color
+ * separatorBackground.
+ * The two lines will
+ * be centered inside the bounds box. If the separator is horizontal,
+ * then it will be vertically centered, or if it's vertical, it will
+ * be horizontally centered.
+ *
+ * @param g The Graphics object to paint with
+ * @param c The JComponent to paint.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Rectangle r = new Rectangle();
+ SwingUtilities.calculateInnerArea(c, r);
+ Color saved = g.getColor();
+ Color c1 = UIManager.getColor("Separator.foreground");
+ Color c2 = UIManager.getColor("Separator.background");
+ JSeparator s;
+ if (c instanceof JSeparator)
+ s = (JSeparator) c;
+ else
+ return;
+
+ if (s.getOrientation() == JSeparator.HORIZONTAL)
+ {
+ int midAB = r.height / 2;
+ g.setColor(c1);
+ g.drawLine(r.x, r.y + midAB - 1, r.x + r.width, r.y + midAB - 1);
+
+ g.setColor(c2);
+ g.fillRect(r.x, r.y + midAB, r.x + r.width, r.y + midAB);
+ }
+ else
+ {
+ int midAD = r.height / 2 + r.y;
+ g.setColor(c1);
+ g.drawLine(r.x, r.y, r.x, r.y + r.height);
+
+ g.setColor(c2);
+ g.fillRect(r.x + midAD, r.y + r.height, r.x + midAD, r.y + r.height);
+ }
+ g.setColor(saved);
+ }
}
diff --git a/javax/swing/plaf/metal/MetalSliderUI.java b/javax/swing/plaf/metal/MetalSliderUI.java
index bd3212c84..08fb99d21 100644
--- a/javax/swing/plaf/metal/MetalSliderUI.java
+++ b/javax/swing/plaf/metal/MetalSliderUI.java
@@ -56,8 +56,7 @@ import javax.swing.plaf.basic.BasicSliderUI;
/**
* A UI delegate for the {@link JSlider} component.
*/
-public class MetalSliderUI
- extends BasicSliderUI
+public class MetalSliderUI extends BasicSliderUI
{
/**
* A property change handler that updates the rendered component in response
@@ -66,13 +65,14 @@ public class MetalSliderUI
* the {@link MetalLookAndFeel}.
*/
protected class MetalPropertyListener
- extends BasicSliderUI.PropertyChangeHandler
+ extends BasicSliderUI.PropertyChangeHandler
{
/**
* Creates a new listener.
*/
protected MetalPropertyListener()
{
+ // Nothing to do here.
}
/**
@@ -149,11 +149,11 @@ public class MetalSliderUI
}
/**
- * Returns an instance of MetalSliderUI.
+ * Returns a new instance of <code>MetalSliderUI</code>.
*
* @param component the component (ignored).
*
- * @return an instance of MetalSliderUI
+ * @return A new instance of <code>MetalSliderUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
diff --git a/javax/swing/plaf/metal/MetalSplitPaneDivider.java b/javax/swing/plaf/metal/MetalSplitPaneDivider.java
index 60e9c0559..016e09557 100644
--- a/javax/swing/plaf/metal/MetalSplitPaneDivider.java
+++ b/javax/swing/plaf/metal/MetalSplitPaneDivider.java
@@ -78,7 +78,7 @@ class MetalSplitPaneDivider extends BasicSplitPaneDivider
{
//super.paint(g);
Dimension s = getSize();
- MetalUtils.fillMetalPattern(g, 2, 2, s.width - 4, s.height - 4,
+ MetalUtils.fillMetalPattern(splitPane, g, 2, 2, s.width - 4, s.height - 4,
light, dark);
}
}
diff --git a/javax/swing/plaf/metal/MetalSplitPaneUI.java b/javax/swing/plaf/metal/MetalSplitPaneUI.java
index b7ea8984b..b39fb2336 100644
--- a/javax/swing/plaf/metal/MetalSplitPaneUI.java
+++ b/javax/swing/plaf/metal/MetalSplitPaneUI.java
@@ -39,24 +39,22 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import java.awt.Color;
-import java.util.HashMap;
import javax.swing.JComponent;
+import javax.swing.JSplitPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.basic.BasicSplitPaneUI;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
-public class MetalSplitPaneUI
- extends BasicSplitPaneUI
+/**
+ * A UI delegate for the {@link JSplitPane} component.
+ */
+public class MetalSplitPaneUI extends BasicSplitPaneUI
{
-
- /** The UI instances for MetalSplitPaneUIs */
- private static HashMap instances;
-
/**
- * Constructs a new instance of MetalSplitPaneUI.
+ * Constructs a new instance of <code>MetalSplitPaneUI</code>.
*/
public MetalSplitPaneUI()
{
@@ -64,28 +62,15 @@ public class MetalSplitPaneUI
}
/**
- * Returns an instance of MetalSplitPaneUI.
+ * Returns a new instance of <code>MetalSplitPaneUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalSplitPaneUI
+ * @return A new instance of <code>MetalSplitPaneUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
- if (instances == null)
- instances = new HashMap();
-
- Object o = instances.get(component);
- MetalSplitPaneUI instance;
- if (o == null)
- {
- instance = new MetalSplitPaneUI();
- instances.put(component, instance);
- }
- else
- instance = (MetalSplitPaneUI) o;
-
- return instance;
+ return new MetalSplitPaneUI();
}
/**
diff --git a/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/javax/swing/plaf/metal/MetalTabbedPaneUI.java
index 1b5fe144f..68aeaaf7c 100644
--- a/javax/swing/plaf/metal/MetalTabbedPaneUI.java
+++ b/javax/swing/plaf/metal/MetalTabbedPaneUI.java
@@ -40,7 +40,6 @@ package javax.swing.plaf.metal;
import java.awt.Graphics;
import java.awt.LayoutManager;
-import java.util.HashMap;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
@@ -48,11 +47,9 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
/**
- * A UI delegate used for the {@link JTabbedPane} component in the
- * {@link MetalLookAndFeel}.
+ * A UI delegate for the {@link JTabbedPane} component.
*/
-public class MetalTabbedPaneUI
- extends BasicTabbedPaneUI
+public class MetalTabbedPaneUI extends BasicTabbedPaneUI
{
/**
@@ -65,13 +62,14 @@ public class MetalTabbedPaneUI
* public for compatibility.
*/
public class TabbedPaneLayout
- extends BasicTabbedPaneUI.TabbedPaneLayout
+ extends BasicTabbedPaneUI.TabbedPaneLayout
{
/**
* Creates a new instance of the layout manager.
*/
public TabbedPaneLayout()
{
+ // Nothing to do here.
}
/**
@@ -102,9 +100,6 @@ public class MetalTabbedPaneUI
}
}
- /** The shared UI instance for JTabbedPanes. */
- private static HashMap instances = null;
-
/**
* Constructs a new instance of MetalTabbedPaneUI.
*/
@@ -122,20 +117,7 @@ public class MetalTabbedPaneUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instances == null)
- instances = new HashMap();
-
- Object o = instances.get(component);
- MetalTabbedPaneUI instance;
- if (o == null)
- {
- instance = new MetalTabbedPaneUI();
- instances.put(component, instance);
- }
- else
- instance = (MetalTabbedPaneUI) o;
-
- return instance;
+ return new MetalTabbedPaneUI();
}
/**
diff --git a/javax/swing/plaf/metal/MetalTextFieldUI.java b/javax/swing/plaf/metal/MetalTextFieldUI.java
index d6e50e122..6984daecc 100644
--- a/javax/swing/plaf/metal/MetalTextFieldUI.java
+++ b/javax/swing/plaf/metal/MetalTextFieldUI.java
@@ -38,19 +38,16 @@ exception statement from your version. */
package javax.swing.plaf.metal;
-import java.util.HashMap;
-
import javax.swing.JComponent;
+import javax.swing.JTextField;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTextFieldUI;
-public class MetalTextFieldUI
- extends BasicTextFieldUI
+/**
+ * A UI delegate for the {@link JTextField} component.
+ */
+public class MetalTextFieldUI extends BasicTextFieldUI
{
-
- /** The UI instances for MetalTextFieldUIs */
- private static HashMap instances = null;
-
/**
* Constructs a new instance of MetalTextFieldUI.
*/
@@ -60,27 +57,14 @@ public class MetalTextFieldUI
}
/**
- * Returns an instance of MetalTextFieldUI.
+ * Returns a new instance of <code>MetalTextFieldUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalTextFieldUI
+ * @return A new instance of <code>MetalTextFieldUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
- if (instances == null)
- instances = new HashMap();
-
- Object o = instances.get(component);
- MetalTextFieldUI instance;
- if (o == null)
- {
- instance = new MetalTextFieldUI();
- instances.put(component, instance);
- }
- else
- instance = (MetalTextFieldUI) o;
-
- return instance;
+ return new MetalTextFieldUI();
}
}
diff --git a/javax/swing/plaf/metal/MetalToggleButtonUI.java b/javax/swing/plaf/metal/MetalToggleButtonUI.java
index 5079562e8..46a19bdbe 100644
--- a/javax/swing/plaf/metal/MetalToggleButtonUI.java
+++ b/javax/swing/plaf/metal/MetalToggleButtonUI.java
@@ -55,7 +55,7 @@ import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicToggleButtonUI;
/**
- * A UI delegate for {@link JToggleButton} components.
+ * A UI delegate for the {@link JToggleButton} component.
*/
public class MetalToggleButtonUI
extends BasicToggleButtonUI
@@ -71,11 +71,11 @@ public class MetalToggleButtonUI
protected Color disabledTextColor;
/**
- * Returns an instance of MetalToggleButtonUI.
+ * Returns a new instance of <code>MetalToggleButtonUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalToggleButtonUI
+ * @return A new instance of <code>MetalToggleButtonUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
@@ -83,15 +83,11 @@ public class MetalToggleButtonUI
}
/**
- * Constructs a new instance of MetalToggleButtonUI.
+ * Constructs a new instance of <code>MetalToggleButtonUI</code>.
*/
public MetalToggleButtonUI()
{
super();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- focusColor = defaults.getColor(getPropertyPrefix() + "focus");
- selectColor = defaults.getColor(getPropertyPrefix() + "select");
- disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText");
}
/**
@@ -115,9 +111,12 @@ public class MetalToggleButtonUI
}
/**
- * Returns the color for the text label of disabled buttons.
+ * Returns the color for the text label of disabled buttons. The value
+ * is initialised in the {@link #installDefaults(AbstractButton)} method
+ * by reading the <code>ToggleButton.disabledText</code> item from the UI
+ * defaults.
*
- * @return the color for the text label of disabled buttons
+ * @return The color for the text label of disabled buttons.
*/
protected Color getDisabledTextColor()
{
@@ -131,9 +130,11 @@ public class MetalToggleButtonUI
*/
public void installDefaults(AbstractButton b)
{
- // FIXME: for now, this override just changes the visibility of the method
- // in the super-class, to satisfy japi...but there must be something else.
super.installDefaults(b);
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ focusColor = defaults.getColor(getPropertyPrefix() + "focus");
+ selectColor = defaults.getColor(getPropertyPrefix() + "select");
+ disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText");
}
/**
@@ -144,11 +145,14 @@ public class MetalToggleButtonUI
*/
protected void paintButtonPressed(Graphics g, AbstractButton b)
{
- Color saved = g.getColor();
- Rectangle bounds = SwingUtilities.getLocalBounds(b);
- g.setColor(selectColor);
- g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
- g.setColor(saved);
+ if (b.isContentAreaFilled() && b.isOpaque())
+ {
+ Color saved = g.getColor();
+ Rectangle bounds = SwingUtilities.getLocalBounds(b);
+ g.setColor(selectColor);
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ g.setColor(saved);
+ }
}
/**
diff --git a/javax/swing/plaf/metal/MetalToolBarUI.java b/javax/swing/plaf/metal/MetalToolBarUI.java
index 39af0011a..c5ca91399 100644
--- a/javax/swing/plaf/metal/MetalToolBarUI.java
+++ b/javax/swing/plaf/metal/MetalToolBarUI.java
@@ -38,20 +38,73 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.event.ContainerListener;
+import java.beans.PropertyChangeListener;
+
import javax.swing.JComponent;
+import javax.swing.JToolBar;
+import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToolBarUI;
-public class MetalToolBarUI
- extends BasicToolBarUI
+/**
+ * A UI delegate for the {@link JToolBar} component.
+ */
+public class MetalToolBarUI extends BasicToolBarUI
{
+
+ /**
+ * A listener (no longer used) that responds when components are added to or
+ * removed from the {@link JToolBar}. The required behaviour is now
+ * handled in the super class.
+ *
+ * @see MetalToolBarUI#createContainerListener()
+ */
+ protected class MetalContainerListener
+ extends BasicToolBarUI.ToolBarContListener
+ {
+ /**
+ * Creates a new instance.
+ */
+ protected MetalContainerListener()
+ {
+ // Nothing to do here.
+ }
+ }
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for MetalToolBarUIs */
- private static MetalToolBarUI instance = null;
+ /**
+ * A listener (no longer used) that responds to property change events in a
+ * {@link JToolBar} component. The required behaviour is now handled in the
+ * super class.
+ *
+ * @see MetalToolBarUI#createRolloverListener()
+ */
+ protected class MetalRolloverListener
+ extends BasicToolBarUI.PropertyListener
+ {
+ /**
+ * Creates a new instance.
+ */
+ protected MetalRolloverListener()
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * The container listener (an implementation specific field, according to the
+ * spec, and not used in GNU Classpath).
+ */
+ protected ContainerListener contListener;
+
+ /**
+ * The rollover listener (an implementation specific field, according to the
+ * spec, and not used in GNU Classpath).
+ */
+ protected PropertyChangeListener rolloverListener;
/**
- * Constructs a new instance of MetalToolBarUI.
+ * Creates a new instance of this UI delegate.
*/
public MetalToolBarUI()
{
@@ -59,16 +112,51 @@ public class MetalToolBarUI
}
/**
- * Returns an instance of MetalToolBarUI.
+ * Returns a new instance of <code>MetalToolBarUI</code>.
*
- * @param component the component for which we return an UI instance
+ * @param component the component for which we return an UI instance
*
- * @return an instance of MetalToolBarUI
+ * @return A new instance of <code>MetalToolBarUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalToolBarUI();
- return instance;
+ return new MetalToolBarUI();
+ }
+
+ /**
+ * Returns <code>null</code> as permitted by recent versions of the API
+ * specification. Originally it seems this method returned a new instance of
+ * {@link MetalRolloverListener}, but this is now redundant.
+ *
+ * @return <code>null</code>.
+ */
+ protected PropertyChangeListener createRolloverListener()
+ {
+ return null;
+ }
+
+ /**
+ * Returns <code>null</code> as permitted by recent versions of the API
+ * specification. Originally it seems this method returned a new instance of
+ * {@link MetalContainerListener}, but this is now redundant.
+ *
+ * @return <code>null</code>.
+ */
+ protected ContainerListener createContainerListener()
+ {
+ return null;
+ }
+
+ /**
+ * Returns a border with no rollover effect for buttons in the tool bar.
+ *
+ * @return A border.
+ *
+ * @see MetalBorders#getToolbarButtonBorder()
+ */
+ protected Border createNonRolloverBorder()
+ {
+ return MetalBorders.getToolbarButtonBorder();
}
+
}
diff --git a/javax/swing/plaf/metal/MetalToolTipUI.java b/javax/swing/plaf/metal/MetalToolTipUI.java
index c88b6534a..5085d170a 100644
--- a/javax/swing/plaf/metal/MetalToolTipUI.java
+++ b/javax/swing/plaf/metal/MetalToolTipUI.java
@@ -38,32 +38,92 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractButton;
import javax.swing.JComponent;
+import javax.swing.JMenuItem;
+import javax.swing.JToolTip;
+import javax.swing.KeyStroke;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicToolTipUI;
+/**
+ * A UI delegate for the {@link JToolTip} component.
+ */
public class MetalToolTipUI
extends BasicToolTipUI
{
+ /**
+ * The amount of space between the tool tip text and the accelerator
+ * description (if visible).
+ */
+ public static final int padSpaceBetweenStrings = 12;
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for MetalToolTipUIs */
+ /** The shared UI instance. */
private static MetalToolTipUI instance = null;
-
+
+ /** A flag controlling the visibility of the accelerator (if there is one). */
+ private boolean isAcceleratorHidden;
+
+ /** A string representing the accelerator key for the component. */
+ private String acceleratorString;
+
+ /**
+ * The delimiter for the accelerator string.
+ */
+ private String acceleratorDelimiter;
+
+ /** The font for the accelerator string. */
+ private Font acceleratorFont;
+
+ /** The color for the accelerator string. */
+ private Color acceleratorForeground;
+
+ /** The active border. */
+ private Border activeBorder;
+
+ /** The inactive border. */
+ private Border inactiveBorder;
+
/**
- * Constructs a new instance of MetalToolTipUI.
+ * Constructs a new instance of <code>MetalToolTipUI</code>.
*/
public MetalToolTipUI()
{
super();
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ activeBorder = defaults.getBorder("ToolTip.border");
+ inactiveBorder = defaults.getBorder("ToolTip.borderInactive");
+ isAcceleratorHidden = defaults.getBoolean("ToolTip.hideAccelerator");
+ acceleratorFont = defaults.getFont("MenuItem.acceleratorFont");
+ acceleratorForeground = defaults.getColor("MenuItem.acceleratorForeground");
+ acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter");
}
/**
- * Returns an instance of MetalToolTipUI.
+ * Returns a shared instance of the <code>MetalToolTipUI</code> class.
+ * Although this UI delegate does maintain state information, there is never
+ * more than one tool tip visible, so it is OK to use a shared instance.
*
- * @param component the component for which we return an UI instance
+ * @param component the component (a {@link JToolTip}).
*
- * @return an instance of MetalToolTipUI
+ * @return A shared instance of the <code>MetalToolTipUI</code> class.
*/
public static ComponentUI createUI(JComponent component)
{
@@ -71,4 +131,202 @@ public class MetalToolTipUI
instance = new MetalToolTipUI();
return instance;
}
+
+ /**
+ * Returns a string representing the accelerator key (if there is one) for
+ * the component that the tool tip belongs to.
+ *
+ * @return A string representing the accelerator key.
+ */
+ public String getAcceleratorString()
+ {
+ return acceleratorString;
+ }
+
+ /**
+ * Installs the UI for the specified component (a {@link JToolTip}).
+ *
+ * @param c the {@link JToolTip} component.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ Border existingBorder = c.getBorder();
+ if (existingBorder == null || existingBorder instanceof UIResource)
+ {
+ if (c.isEnabled())
+ c.setBorder(activeBorder);
+ else
+ c.setBorder(inactiveBorder);
+ }
+ }
+
+ /**
+ * Clears the defaults set in {@link #installUI(JComponent)}.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ super.uninstallUI(c);
+ if (c.getBorder() instanceof UIResource)
+ c.setBorder(null);
+ }
+
+ /**
+ * Returns <code>true</code> if the accelerator string is hidden, and
+ * <code>false</code> otherwise. This setting is controlled by the
+ * <code>ToolTip.hideAccelerator</code> entry in the UI defaults table.
+ *
+ * @return A boolean.
+ */
+ protected boolean isAcceleratorHidden()
+ {
+ return isAcceleratorHidden;
+ }
+
+ /**
+ * Returns the preferred size for the {@link JToolTip} component.
+ *
+ * @param c the component (a {@link JToolTip}).
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ if (isAcceleratorHidden())
+ return super.getPreferredSize(c);
+ else
+ {
+ Insets insets = c.getInsets();
+ JToolTip tt = (JToolTip) c;
+ String tipText = tt.getTipText();
+ if (tipText != null)
+ {
+ FontMetrics fm = c.getFontMetrics(c.getFont());
+ int prefH = fm.getHeight() + insets.top + insets.bottom;
+ int prefW = fm.stringWidth(tipText) + insets.left + insets.right;
+
+ // this seems to be the first opportunity we have to get the
+ // accelerator string from the component (if it has one)
+ acceleratorString = fetchAcceleratorString(c);
+ if (acceleratorString != null)
+ {
+ prefW += padSpaceBetweenStrings;
+ fm = c.getFontMetrics(acceleratorFont);
+ prefW += fm.stringWidth(acceleratorString);
+ }
+ return new Dimension(prefW, prefH);
+ }
+ else return new Dimension(0, 0);
+ }
+ }
+
+ /**
+ * Paints the tool tip.
+ *
+ * @param g the graphics context.
+ * @param c the {@link JToolTip} component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ JToolTip tip = (JToolTip) c;
+
+ String text = tip.getTipText();
+ Toolkit t = tip.getToolkit();
+ if (text == null)
+ return;
+
+ Rectangle vr = new Rectangle();
+ vr = SwingUtilities.calculateInnerArea(tip, vr);
+ Rectangle ir = new Rectangle();
+ Rectangle tr = new Rectangle();
+ FontMetrics fm = t.getFontMetrics(tip.getFont());
+ int ascent = fm.getAscent();
+ SwingUtilities.layoutCompoundLabel(tip, fm, text, null,
+ SwingConstants.CENTER, SwingConstants.LEFT,
+ SwingConstants.CENTER, SwingConstants.CENTER, vr, ir, tr, 0);
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+
+ g.drawString(text, vr.x, vr.y + ascent);
+
+ // paint accelerator
+ if (acceleratorString != null)
+ {
+ g.setFont(acceleratorFont);
+ g.setColor(acceleratorForeground);
+ fm = t.getFontMetrics(acceleratorFont);
+ int width = fm.stringWidth(acceleratorString);
+ g.drawString(acceleratorString, vr.x + vr.width - width - padSpaceBetweenStrings/2,
+ vr.y + vr.height - fm.getDescent());
+ }
+
+ g.setColor(saved);
+ }
+
+ /**
+ * Returns a string representing the accelerator for the component, or
+ * <code>null</code> if the component has no accelerator.
+ *
+ * @param c the component.
+ *
+ * @return A string representing the accelerator (possibly
+ * <code>null</code>).
+ */
+ private String fetchAcceleratorString(JComponent c)
+ {
+ String result = null;
+ if (c instanceof JToolTip)
+ {
+ JToolTip toolTip = (JToolTip) c;
+ JComponent component = toolTip.getComponent();
+ KeyStroke ks = null;
+ int mne = 0;
+ if (component instanceof JMenuItem)
+ {
+ JMenuItem item = (JMenuItem) component;
+ ks = item.getAccelerator();
+ if (ks == null)
+ mne = item.getMnemonic();
+ }
+ else if (component instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) component;
+ mne = button.getMnemonic();
+ }
+ if (mne > 0)
+ ks = KeyStroke.getKeyStroke(Character.toUpperCase((char) mne),
+ InputEvent.ALT_MASK, false);
+ if (ks != null)
+ result = acceleratorToString(ks);
+ }
+ return result;
+ }
+
+ /**
+ * Returns a string representing an accelerator.
+ *
+ * @param accelerator the accelerator (<code>null</code> not permitted).
+ *
+ * @return A string representing an accelerator.
+ */
+ private String acceleratorToString(KeyStroke accelerator)
+ {
+ // convert keystroke into string format
+ String modifiersText = "";
+ int modifiers = accelerator.getModifiers();
+ char keyChar = accelerator.getKeyChar();
+ int keyCode = accelerator.getKeyCode();
+
+ if (modifiers != 0)
+ modifiersText = KeyEvent.getKeyModifiersText(modifiers)
+ + acceleratorDelimiter;
+
+ if (keyCode == KeyEvent.VK_UNDEFINED)
+ return modifiersText + keyChar;
+ else
+ return modifiersText + KeyEvent.getKeyText(keyCode);
+ }
+
}
diff --git a/javax/swing/plaf/metal/MetalTreeUI.java b/javax/swing/plaf/metal/MetalTreeUI.java
index a5ca3fe11..0ffa0d174 100644
--- a/javax/swing/plaf/metal/MetalTreeUI.java
+++ b/javax/swing/plaf/metal/MetalTreeUI.java
@@ -44,8 +44,8 @@ import java.awt.Rectangle;
import java.awt.event.ComponentListener;
import java.awt.event.FocusListener;
import java.awt.event.KeyListener;
+import java.awt.event.MouseListener;
import java.beans.PropertyChangeListener;
-import java.util.HashMap;
import java.util.Hashtable;
import javax.swing.JComponent;
@@ -56,23 +56,23 @@ import javax.swing.tree.TreeCellEditor;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import javax.swing.event.CellEditorListener;
-import javax.swing.event.MouseInputListener;
import javax.swing.event.TreeExpansionListener;
import javax.swing.event.TreeModelListener;
import javax.swing.event.TreeSelectionListener;
-
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTreeUI;
-public class MetalTreeUI
- extends BasicTreeUI
+/**
+ * A UI delegate for the {@link JTree} component.
+ */
+public class MetalTreeUI extends BasicTreeUI
{
/** Listeners */
private PropertyChangeListener propertyChangeListener;
private FocusListener focusListener;
private TreeSelectionListener treeSelectionListener;
- private MouseInputListener mouseInputListener;
+ private MouseListener mouseListener;
private KeyListener keyListener;
private PropertyChangeListener selectionModelPropertyChangeListener;
private ComponentListener componentListener;
@@ -80,11 +80,8 @@ public class MetalTreeUI
private TreeExpansionListener treeExpansionListener;
private TreeModelListener treeModelListener;
- /** The UI instances for MetalTreeUIs */
- private static HashMap instances = null;
-
/**
- * Constructs a new instance of MetalTreeUI.
+ * Constructs a new instance of <code>MetalTreeUI</code>.
*/
public MetalTreeUI()
{
@@ -92,28 +89,15 @@ public class MetalTreeUI
}
/**
- * Returns an instance of MetalTreeUI.
+ * Returns a new instance of <code>MetalTreeUI</code>.
*
* @param component the component for which we return an UI instance
*
- * @return an instance of MetalTreeUI
+ * @return A new instance of <code>MetalTreeUI</code>.
*/
public static ComponentUI createUI(JComponent component)
{
- if (instances == null)
- instances = new HashMap();
-
- Object o = instances.get(component);
- MetalTreeUI instance;
- if (o == null)
- {
- instance = new MetalTreeUI();
- instances.put(component, instance);
- }
- else
- instance = (MetalTreeUI) o;
-
- return instance;
+ return new MetalTreeUI();
}
/**
@@ -156,6 +140,7 @@ public class MetalTreeUI
rightChildIndent = defaults.getInt("Tree.rightChildIndent");
leftChildIndent = defaults.getInt("Tree.leftChildIndent");
setRowHeight(defaults.getInt("Tree.rowHeight"));
+ tree.setRowHeight(defaults.getInt("Tree.rowHeight"));
tree.requestFocusInWindow(false);
setExpandedIcon(defaults.getIcon("Tree.expandedIcon"));
@@ -168,9 +153,7 @@ public class MetalTreeUI
createdCellEditor = true;
TreeModel mod = tree.getModel();
setModel(mod);
- tree.setRootVisible(true);
- if (mod != null)
- tree.expandPath(new TreePath(mod.getRoot()));
+
treeSelectionModel = tree.getSelectionModel();
drawingCache = new Hashtable();
nodeDimensions = createNodeDimensions();
@@ -178,7 +161,7 @@ public class MetalTreeUI
propertyChangeListener = createPropertyChangeListener();
focusListener = createFocusListener();
treeSelectionListener = createTreeSelectionListener();
- mouseInputListener = new MouseInputHandler(null, null, null);
+ mouseListener = createMouseListener();
keyListener = createKeyListener();
selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener();
componentListener = createComponentListener();
@@ -194,7 +177,7 @@ public class MetalTreeUI
tree.addPropertyChangeListener(propertyChangeListener);
tree.addFocusListener(focusListener);
tree.addTreeSelectionListener(treeSelectionListener);
- tree.addMouseListener(mouseInputListener);
+ tree.addMouseListener(mouseListener);
tree.addKeyListener(keyListener);
tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
tree.addComponentListener(componentListener);
@@ -202,6 +185,13 @@ public class MetalTreeUI
if (treeModel != null)
treeModel.addTreeModelListener(treeModelListener);
+ if (mod != null)
+ {
+ TreePath path = new TreePath(mod.getRoot());
+ if (!tree.isExpanded(path))
+ toggleExpandState(path);
+ }
+
completeUIInstall();
}
@@ -231,7 +221,7 @@ public class MetalTreeUI
tree.removePropertyChangeListener(propertyChangeListener);
tree.removeFocusListener(focusListener);
tree.removeTreeSelectionListener(treeSelectionListener);
- tree.removeMouseListener(mouseInputListener);
+ tree.removeMouseListener(mouseListener);
tree.removeKeyListener(keyListener);
tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
tree.removeComponentListener(componentListener);
diff --git a/javax/swing/plaf/metal/MetalUtils.java b/javax/swing/plaf/metal/MetalUtils.java
index 6480365f8..991518d11 100644
--- a/javax/swing/plaf/metal/MetalUtils.java
+++ b/javax/swing/plaf/metal/MetalUtils.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import java.awt.Color;
+import java.awt.Component;
import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.TexturePaint;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
/**
* Some utility and helper methods for the Metal Look &amp; Feel.
@@ -49,6 +54,21 @@ class MetalUtils
{
/**
+ * The typical metal pattern for use with Graphics2D.
+ */
+ static BufferedImage pattern2D;
+
+ /**
+ * The light color to draw the pattern.
+ */
+ static Color lightColor;
+
+ /**
+ * The dark color to draw to draw the pattern.
+ */
+ static Color darkColor;
+
+ /**
* Fills a rectangle with the typical Metal pattern.
*
* @param g the <code>Graphics</code> context to use
@@ -61,27 +81,74 @@ class MetalUtils
* @param light the light color to use
* @param dark the dark color to use
*/
- static void fillMetalPattern(Graphics g, int x, int y, int w, int h,
+ static void fillMetalPattern(Component c, Graphics g, int x, int y, int w, int h,
Color light, Color dark)
{
- int xOff = 0;
- for (int mY = y; mY < (y + h); mY++)
+ if (g instanceof Graphics2D)
+ fillMetalPattern2D((Graphics2D) g, x, y, w, h, light, dark);
+ else
{
- // set color alternating with every line
- if (((mY - y) % 2) == 0)
- g.setColor(light);
- else
- g.setColor(dark);
-
- for (int mX = x + (xOff); mX < (x + w); mX += 4)
+ int xOff = 0;
+ for (int mY = y; mY < (y + h); mY++)
{
- g.drawLine(mX, mY, mX, mY);
+ // set color alternating with every line
+ if (((mY - y) % 2) == 0)
+ g.setColor(light);
+ else
+ g.setColor(dark);
+
+ for (int mX = x + (xOff); mX < (x + w); mX += 4)
+ {
+ g.drawLine(mX, mY, mX, mY);
+ }
+
+ // increase x offset
+ xOff++;
+ if (xOff > 3)
+ xOff = 0;
}
+ }
+ }
- // increase x offset
- xOff++;
- if (xOff > 3)
- xOff = 0;
- }
+ /**
+ * Fills a rectangle with the typical Metal pattern using Java2D.
+ *
+ * @param g2d the <code>Graphics2D</code> context to use
+ * @param x the X coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param y the Y coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param w the width of the rectangle to fill
+ * @param h the height of the rectangle to fill
+ */
+ static void fillMetalPattern2D(Graphics2D g2d, int x, int y, int w, int h,
+ Color light, Color dark)
+ {
+ if (pattern2D == null || !darkColor.equals(dark) || !lightColor.equals(light))
+ initializePattern(light, dark);
+
+ // Prepare the texture.
+ TexturePaint texture =
+ new TexturePaint(pattern2D, new Rectangle2D.Double(0., 0., 4., 2.));
+ g2d.setPaint(texture);
+ g2d.fillRect(x, y, w, h);
+ }
+
+ /**
+ * Initializes the pattern image.
+ */
+ static void initializePattern(Color light, Color dark)
+ {
+ pattern2D = new BufferedImage(4, 4, BufferedImage.TYPE_INT_RGB);
+ lightColor = light;
+ darkColor = dark;
+ Graphics g = pattern2D.getGraphics();
+ g.setColor(light);
+ g.fillRect(0, 0, 1, 1);
+ g.fillRect(2, 2, 1, 1);
+ g.setColor(dark);
+ g.fillRect(1, 1, 1, 1);
+ g.fillRect(3, 3, 1, 1);
+ g.dispose();
}
}
diff --git a/javax/swing/plaf/metal/OceanTheme.java b/javax/swing/plaf/metal/OceanTheme.java
index 3a837cb5a..85a8cb1ff 100644
--- a/javax/swing/plaf/metal/OceanTheme.java
+++ b/javax/swing/plaf/metal/OceanTheme.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
/**
@@ -195,4 +196,14 @@ public class OceanTheme extends DefaultMetalTheme
{
return SECONDARY3;
}
+
+ /**
+ * Adds customized entries to the UIDefaults table.
+ *
+ * @param defaults the UI defaults table
+ */
+ public void addCustomEntriesToTable(UIDefaults defaults)
+ {
+ defaults.put("Button.rollover", Boolean.TRUE);
+ }
}
diff --git a/javax/swing/plaf/metal/package.html b/javax/swing/plaf/metal/package.html
index 2ea787bb5..8675493b6 100644
--- a/javax/swing/plaf/metal/package.html
+++ b/javax/swing/plaf/metal/package.html
@@ -40,7 +40,16 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.plaf.metal</title></head>
<body>
-<p>Provides a cross-platform look and feel known as "Metal".</p>
-
+<p>Provides a cross-platform look and feel known as "Metal". To install this
+look and feel, add the following code (or something similar)
+near the start of your application:</p>
+<pre>try
+ {
+&nbsp;&nbsp;UIManager.setLookAndFeel(new MetalLookAndFeel());
+ }
+catch (UnsupportedLookAndFeelException e)
+ {
+&nbsp;&nbsp;e.printStackTrace();
+ }</pre>
</body>
</html>
diff --git a/javax/swing/plaf/multi/MultiLookAndFeel.java b/javax/swing/plaf/multi/MultiLookAndFeel.java
index a70a8ff69..2bd358dd0 100644
--- a/javax/swing/plaf/multi/MultiLookAndFeel.java
+++ b/javax/swing/plaf/multi/MultiLookAndFeel.java
@@ -56,6 +56,7 @@ public class MultiLookAndFeel extends LookAndFeel {
*/
public MultiLookAndFeel()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/table/DefaultTableCellRenderer.java b/javax/swing/table/DefaultTableCellRenderer.java
index 349f4baad..ef80a7e22 100644
--- a/javax/swing/table/DefaultTableCellRenderer.java
+++ b/javax/swing/table/DefaultTableCellRenderer.java
@@ -43,8 +43,10 @@ import java.awt.Component;
import java.awt.Rectangle;
import java.io.Serializable;
+import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
+import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
@@ -64,6 +66,7 @@ public class DefaultTableCellRenderer extends JLabel
{
public UIResource()
{
+ super();
}
}
@@ -145,9 +148,17 @@ public class DefaultTableCellRenderer extends JLabel
setBackground(table.getBackground());
setForeground(table.getForeground());
}
+ if (hasFocus)
+ {
+ setBackground(table.getBackground());
+ setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
+ }
+ else
+ setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
setEnabled(table.isEnabled());
setFont(table.getFont());
+
return this;
}
diff --git a/javax/swing/table/JTableHeader.java b/javax/swing/table/JTableHeader.java
index 45586da20..163509a45 100644
--- a/javax/swing/table/JTableHeader.java
+++ b/javax/swing/table/JTableHeader.java
@@ -61,9 +61,14 @@ import javax.accessibility.AccessibleValue;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.UIManager;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.TableColumnModelEvent;
+import javax.swing.event.TableColumnModelListener;
import javax.swing.plaf.TableHeaderUI;
public class JTableHeader extends JComponent
+ implements TableColumnModelListener, Accessible
{
protected class AccessibleJTableHeader extends AccessibleJComponent
{
@@ -305,11 +310,6 @@ public class JTableHeader extends JComponent
private static final long serialVersionUID = 5144633983372967710L;
/**
- * The accessibleContext property.
- */
- AccessibleContext accessibleContext;
-
- /**
* The columnModel property.
*/
protected TableColumnModel columnModel;
@@ -373,17 +373,8 @@ public class JTableHeader extends JComponent
*/
public JTableHeader(TableColumnModel cm)
{
- accessibleContext = new AccessibleJTableHeader();
columnModel = cm == null ? createDefaultColumnModel() : cm;
- draggedColumn = null;
- draggedDistance = 0;
- opaque = true;
- reorderingAllowed = true;
- resizingAllowed = true;
- resizingColumn = null;
- table = null;
- updateTableInRealTime = true;
- cellRenderer = createDefaultRenderer();
+ initializeLocalVars();
updateUI();
}
@@ -504,7 +495,9 @@ public class JTableHeader extends JComponent
*/
public void setColumnModel(TableColumnModel c)
{
+ columnModel.removeColumnModelListener(this);
columnModel = c;
+ columnModel.addColumnModelListener(this);
}
/**
@@ -619,7 +612,7 @@ public class JTableHeader extends JComponent
public Rectangle getHeaderRect(int column)
{
- Rectangle r = getTable().getCellRect(-1, column, true);
+ Rectangle r = getTable().getCellRect(-1, column, false);
r.height = getHeight();
return r;
}
@@ -665,4 +658,88 @@ public class JTableHeader extends JComponent
return -1;
}
+
+ /**
+ * Receives notification when a column is added to the column model.
+ *
+ * @param event the table column model event
+ */
+ public void columnAdded(TableColumnModelEvent event)
+ {
+ // TODO: What else to do here (if anything)?
+ resizeAndRepaint();
+ }
+
+ /**
+ * Receives notification when a column margin changes in the column model.
+ *
+ * @param event the table column model event
+ */
+ public void columnMarginChanged(ChangeEvent event)
+ {
+ // TODO: What else to do here (if anything)?
+ resizeAndRepaint();
+ }
+
+ /**
+ * Receives notification when a column is moved within the column model.
+ *
+ * @param event the table column model event
+ */
+ public void columnMoved(TableColumnModelEvent event)
+ {
+ // TODO: What else to do here (if anything)?
+ resizeAndRepaint();
+ }
+
+ /**
+ * Receives notification when a column is removed from the column model.
+ *
+ * @param event the table column model event
+ */
+ public void columnRemoved(TableColumnModelEvent event)
+ {
+ // TODO: What else to do here (if anything)?
+ resizeAndRepaint();
+ }
+
+ /**
+ * Receives notification when the column selection has changed.
+ *
+ * @param event the table column model event
+ */
+ public void columnSelectionChanged(ListSelectionEvent event)
+ {
+ // TODO: What else to do here (if anything)?
+ resizeAndRepaint();
+ }
+
+ /**
+ * Validates the layout of this table header and repaints it. This is
+ * equivalent to <code>revalidate()</code> followed by
+ * <code>repaint()</code>.
+ */
+ public void resizeAndRepaint()
+ {
+ revalidate();
+ repaint();
+ }
+
+ /**
+ * Initializes the fields and properties of this class with default values.
+ * This is called by the constructors.
+ */
+ protected void initializeLocalVars()
+ {
+ accessibleContext = new AccessibleJTableHeader();
+ draggedColumn = null;
+ draggedDistance = 0;
+ opaque = true;
+ reorderingAllowed = true;
+ resizingAllowed = true;
+ resizingColumn = null;
+ table = null;
+ updateTableInRealTime = true;
+ cellRenderer = createDefaultRenderer();
+ }
}
diff --git a/javax/swing/table/TableColumnModel.java b/javax/swing/table/TableColumnModel.java
index 76a145604..b006f9ad4 100644
--- a/javax/swing/table/TableColumnModel.java
+++ b/javax/swing/table/TableColumnModel.java
@@ -50,6 +50,7 @@ import javax.swing.event.TableColumnModelListener;
*
* @author Andrew Selkirk
*/
+// FIXME: The API documentation in this class is incomplete.
public interface TableColumnModel
{
/**
@@ -107,7 +108,7 @@ public interface TableColumnModel
* @throws IllegalArgumentException if <code>identifier</code> is
* <code>null</code> or there is no column with that identifier.
*/
- int getColumnIndex(Object columnIdentifier);
+ int getColumnIndex(Object identifier);
/**
* Returns the <code>TableColumn</code> at the specified index.
@@ -169,7 +170,6 @@ public interface TableColumnModel
/**
* getSelectionModel
- * @param column TableColumn
*/
ListSelectionModel getSelectionModel();
diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java
index 54213dcb1..b66c895ec 100644
--- a/javax/swing/text/AbstractDocument.java
+++ b/javax/swing/text/AbstractDocument.java
@@ -127,8 +127,29 @@ public abstract class AbstractDocument implements Document, Serializable
* Manages event listeners for this <code>Document</code>.
*/
protected EventListenerList listenerList = new EventListenerList();
+
+ /**
+ * Stores the current writer thread. Used for locking.
+ */
+ private Thread currentWriter = null;
+
+ /**
+ * The number of readers. Used for locking.
+ */
+ private int numReaders = 0;
+
+ /**
+ * Tells if there are one or more writers waiting.
+ */
+ private int numWritersWaiting = 0;
/**
+ * A condition variable that readers and writers wait on.
+ */
+ Object documentCV = new Object();
+
+
+ /**
* Creates a new <code>AbstractDocument</code> with the specified
* {@link Content} model.
*
@@ -347,8 +368,7 @@ public abstract class AbstractDocument implements Document, Serializable
*/
protected Thread getCurrentWriter()
{
- // FIXME: Implement locking!
- return null;
+ return currentWriter;
}
/**
@@ -515,13 +535,18 @@ public abstract class AbstractDocument implements Document, Serializable
// Just return when no text to insert was given.
if (text == null || text.length() == 0)
return;
-
DefaultDocumentEvent event =
new DefaultDocumentEvent(offset, text.length(),
DocumentEvent.EventType.INSERT);
- content.insertString(offset, text);
+
+ writeLock();
+ UndoableEdit undo = content.insertString(offset, text);
insertUpdate(event, attributes);
+ writeUnlock();
+
fireInsertUpdate(event);
+ if (undo != null)
+ fireUndoableEditUpdate(new UndoableEditEvent(this, undo));
}
/**
@@ -565,10 +590,28 @@ public abstract class AbstractDocument implements Document, Serializable
}
/**
- * Blocks until a read lock can be obtained.
+ * Blocks until a read lock can be obtained. Must block if there is
+ * currently a writer modifying the <code>Document</code>.
*/
public void readLock()
{
+ if (currentWriter != null && currentWriter.equals(Thread.currentThread()))
+ return;
+ synchronized (documentCV)
+ {
+ while (currentWriter != null || numWritersWaiting > 0)
+ {
+ try
+ {
+ documentCV.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ throw new Error("interrupted trying to get a readLock");
+ }
+ }
+ numReaders++;
+ }
}
/**
@@ -577,6 +620,40 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public void readUnlock()
{
+ // Note we could have a problem here if readUnlock was called without a
+ // prior call to readLock but the specs simply warn users to ensure that
+ // balance by using a finally block:
+ // readLock()
+ // try
+ // {
+ // doSomethingHere
+ // }
+ // finally
+ // {
+ // readUnlock();
+ // }
+
+ // All that the JDK seems to check for is that you don't call unlock
+ // more times than you've previously called lock, but it doesn't make
+ // sure that the threads calling unlock were the same ones that called lock
+
+ // FIXME: the reference implementation throws a
+ // javax.swing.text.StateInvariantError here
+ if (numReaders == 0)
+ throw new IllegalStateException("document lock failure");
+
+ synchronized (documentCV)
+ {
+ // If currentWriter is not null, the application code probably had a
+ // writeLock and then tried to obtain a readLock, in which case
+ // numReaders wasn't incremented
+ if (currentWriter == null)
+ {
+ numReaders --;
+ if (numReaders == 0 && numWritersWaiting != 0)
+ documentCV.notify();
+ }
+ }
}
/**
@@ -594,10 +671,42 @@ public abstract class AbstractDocument implements Document, Serializable
DefaultDocumentEvent event =
new DefaultDocumentEvent(offset, length,
DocumentEvent.EventType.REMOVE);
+
+ // Here we set up the parameters for an ElementChange, if one
+ // needs to be added to the DocumentEvent later
+ Element root = getDefaultRootElement();
+ int start = root.getElementIndex(offset);
+ int end = root.getElementIndex(offset + length);
+
+ Element[] removed = new Element[end - start + 1];
+ for (int i = start; i <= end; i++)
+ removed[i - start] = root.getElement(i);
+
removeUpdate(event);
- content.remove(offset, length);
+
+ Element[] added = new Element[1];
+ added[0] = root.getElement(start);
+ boolean shouldFire = content.getString(offset, length).length() != 0;
+
+ writeLock();
+ UndoableEdit temp = content.remove(offset, length);
+ writeUnlock();
+
postRemoveUpdate(event);
- fireRemoveUpdate(event);
+
+ GapContent.UndoRemove changes = null;
+ if (content instanceof GapContent)
+ changes = (GapContent.UndoRemove) temp;
+
+ if (changes != null && !(start == end))
+ {
+ // We need to add an ElementChange to our DocumentEvent
+ ElementEdit edit = new ElementEdit (root, start, removed, added);
+ event.addEdit(edit);
+ }
+
+ if (shouldFire)
+ fireRemoveUpdate(event);
}
/**
@@ -712,7 +821,15 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public void render(Runnable runnable)
{
- // FIXME: Implement me!
+ readLock();
+ try
+ {
+ runnable.run();
+ }
+ finally
+ {
+ readUnlock();
+ }
}
/**
@@ -724,6 +841,7 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public void setAsynchronousLoadPriority(int p)
{
+ // TODO: Implement this properly.
}
/**
@@ -738,11 +856,30 @@ public abstract class AbstractDocument implements Document, Serializable
}
/**
- * Blocks until a write lock can be obtained.
+ * Blocks until a write lock can be obtained. Must wait if there are
+ * readers currently reading or another thread is currently writing.
*/
protected void writeLock()
{
- // FIXME: Implement me.
+ if (currentWriter!= null && currentWriter.equals(Thread.currentThread()))
+ return;
+ synchronized (documentCV)
+ {
+ numWritersWaiting++;
+ while (numReaders > 0)
+ {
+ try
+ {
+ documentCV.wait();
+ }
+ catch (InterruptedException ie)
+ {
+ throw new Error("interruped while trying to obtain write lock");
+ }
+ }
+ numWritersWaiting --;
+ currentWriter = Thread.currentThread();
+ }
}
/**
@@ -751,7 +888,14 @@ public abstract class AbstractDocument implements Document, Serializable
*/
protected void writeUnlock()
{
- // FIXME: Implement me.
+ synchronized (documentCV)
+ {
+ if (Thread.currentThread().equals(currentWriter))
+ {
+ currentWriter = null;
+ documentCV.notifyAll();
+ }
+ }
}
/**
@@ -1230,6 +1374,9 @@ public abstract class AbstractDocument implements Document, Serializable
/**
* Returns the resolve parent of this element.
+ * This is taken from the AttributeSet, but if this is null,
+ * this method instead returns the Element's parent's
+ * AttributeSet
*
* @return the resolve parent of this element
*
@@ -1237,7 +1384,9 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public AttributeSet getResolveParent()
{
- return attributes.getResolveParent();
+ if (attributes.getResolveParent() != null)
+ return attributes.getResolveParent();
+ return element_parent.getAttributes();
}
/**
@@ -1407,6 +1556,7 @@ public abstract class AbstractDocument implements Document, Serializable
+ "must not be thrown "
+ "here.");
err.initCause(ex);
+ throw err;
}
b.append("]\n");
}
@@ -1514,19 +1664,30 @@ public abstract class AbstractDocument implements Document, Serializable
*/
public int getElementIndex(int offset)
{
- // If we have no children, return -1.
- if (getElementCount() == 0)
- return - 1;
-
+ // If offset is less than the start offset of our first child,
+ // return 0
+ if (offset < getStartOffset())
+ return 0;
+
// XXX: There is surely a better algorithm
// as beginning from first element each time.
- for (int index = 0; index < children.length; ++index)
+ for (int index = 0; index < children.length - 1; ++index)
{
Element elem = children[index];
if ((elem.getStartOffset() <= offset)
&& (offset < elem.getEndOffset()))
return index;
+ // If the next element's start offset is greater than offset
+ // then we have to return the closest Element, since no Elements
+ // will contain the offset
+ if (children[index + 1].getStartOffset() > offset)
+ {
+ if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset))
+ return index + 1;
+ else
+ return index;
+ }
}
// If offset is greater than the index of the last element, return
@@ -1759,7 +1920,7 @@ public abstract class AbstractDocument implements Document, Serializable
return (DocumentEvent.ElementChange) changes.get(elem);
}
}
-
+
/**
* An implementation of {@link DocumentEvent.ElementChange} to be added
* to {@link DefaultDocumentEvent}s.
diff --git a/javax/swing/text/AttributeSet.java b/javax/swing/text/AttributeSet.java
index 2f1f1890b..01d148c06 100644
--- a/javax/swing/text/AttributeSet.java
+++ b/javax/swing/text/AttributeSet.java
@@ -58,6 +58,7 @@ public interface AttributeSet
*/
static interface CharacterAttribute
{
+ // This interface is a marker interface and has no methods.
}
/**
@@ -65,6 +66,7 @@ public interface AttributeSet
*/
static interface ColorAttribute
{
+ // This interface is a marker interface and has no methods.
}
/**
@@ -72,6 +74,7 @@ public interface AttributeSet
*/
static interface FontAttribute
{
+ // This interface is a marker interface and has no methods.
}
/**
@@ -79,6 +82,7 @@ public interface AttributeSet
*/
static interface ParagraphAttribute
{
+ // This interface is a marker interface and has no methods.
}
/**
@@ -99,7 +103,7 @@ public interface AttributeSet
* <code>false</code> otherwise.
*
* @param name the name of the requested attribute
- * @param the value of the requested attribute
+ * @param value the value of the requested attribute
*
* @return <code>true</code> if this <code>AttributeSet</code> contains
* an attribute with the specified <code>name</code> and
diff --git a/javax/swing/text/BoxView.java b/javax/swing/text/BoxView.java
index bc08626bd..b57df732c 100644
--- a/javax/swing/text/BoxView.java
+++ b/javax/swing/text/BoxView.java
@@ -155,8 +155,9 @@ public class BoxView
* automatically when any of the child view changes its preferences
* via {@link #preferenceChanged(View, boolean, boolean)}.
*
- * The layout will be updated the next time when {@link #setSize()} is
- * called, typically from within the {@link #paint()} method.
+ * The layout will be updated the next time when
+ * {@link #setSize(float, float)} is called, typically from within the
+ * {@link #paint(Graphics, Shape)} method.
*
* Valid values for the axis are {@link View#X_AXIS} and
* {@link View#Y_AXIS}.
@@ -216,7 +217,7 @@ public class BoxView
* @param alloc the allocated region for the child to paint into
* @param index the index of the child to be painted
*
- * @see {@link #childAllocation}
+ * @see #childAllocation(int, Rectangle)
*/
protected void paintChild(Graphics g, Rectangle alloc, int index)
{
@@ -300,14 +301,14 @@ public class BoxView
setSize(bounds.width, bounds.height);
Rectangle inside = getInsideAllocation(a);
-
Rectangle copy = new Rectangle(inside);
int count = getViewCount();
for (int i = 0; i < count; ++i)
{
copy.setBounds(inside);
childAllocation(i, copy);
- paintChild(g, copy, i);
+ if (!copy.isEmpty())
+ paintChild(g, copy, i);
}
}
@@ -357,6 +358,24 @@ public class BoxView
}
/**
+ * Calculates the layout of the children of this <code>BoxView</code> along
+ * the specified axis.
+ *
+ * @param span the target span
+ * @param axis the axis that is examined
+ * @param offsets an empty array, filled with the offsets of the children
+ * @param spans an empty array, filled with the spans of the children
+ */
+ protected void baselineLayout(int span, int axis, int[] offsets,
+ int[] spans)
+ {
+ if (axis == myAxis)
+ layoutMajorAxis(span, axis, offsets, spans);
+ else
+ layoutMinorAxis(span, axis, offsets, spans);
+ }
+
+ /**
* Calculates the size requirements of this <code>BoxView</code> along
* its major axis, that is the axis specified in the constructor.
*
@@ -370,27 +389,8 @@ public class BoxView
protected SizeRequirements calculateMajorAxisRequirements(int axis,
SizeRequirements sr)
{
- if (sr == null)
- sr = new SizeRequirements();
- else
- {
- sr.maximum = 0;
- sr.minimum = 0;
- sr.preferred = 0;
- sr.alignment = 0.5F;
- }
-
- int count = getViewCount();
-
- // Sum up the sizes of the children along the specified axis.
- for (int i = 0; i < count; ++i)
- {
- View child = getView(i);
- sr.minimum += child.getMinimumSpan(axis);
- sr.preferred += child.getPreferredSpan(axis);
- sr.maximum += child.getMaximumSpan(axis);
- }
- return sr;
+ SizeRequirements[] childReqs = getChildRequirements(axis);
+ return SizeRequirements.getTiledSizeRequirements(childReqs);
}
/**
@@ -408,48 +408,8 @@ public class BoxView
protected SizeRequirements calculateMinorAxisRequirements(int axis,
SizeRequirements sr)
{
- if (sr == null)
- sr = new SizeRequirements();
- else
- {
- sr.maximum = 0;
- sr.minimum = 0;
- sr.preferred = 0;
- sr.alignment = 0.5F;
- }
-
- int count = getViewCount();
-
- int aboveBaseline = 0;
- int belowBaseline = 0;
- int aboveBaselineMin = 0;
- int belowBaselineMin = 0;
- int aboveBaselineMax = 0;
- int belowBaselineMax = 0;
-
- for (int i = 0; i < count; ++i)
- {
- View child = getView(i);
- float align = child.getAlignment(axis);
- int pref = (int) child.getPreferredSpan(axis);
- int min = (int) child.getMinimumSpan(axis);
- int max = (int) child.getMaximumSpan(axis);
- aboveBaseline += (int) (align * pref);
- belowBaseline += (int) ((1.F - align) * pref);
- aboveBaselineMin += (int) (align * min);
- belowBaselineMin += (int) ((1.F - align) * min);
- aboveBaselineMax += (int) (align * max);
- belowBaselineMax += (int) ((1.F - align) * max);
- }
- sr.minimum = aboveBaselineMin + belowBaselineMin;
- sr.maximum = aboveBaselineMax + belowBaselineMax;
- sr.preferred = aboveBaseline + belowBaseline;
- if (aboveBaseline == 0)
- sr.alignment = 1.0F;
- else
- sr.alignment = (float) (sr.preferred / aboveBaseline);
-
- return sr;
+ SizeRequirements[] childReqs = getChildRequirements(axis);
+ return SizeRequirements.getAlignedSizeRequirements(childReqs);
}
/**
@@ -564,19 +524,8 @@ public class BoxView
*/
protected void layout(int width, int height)
{
- this.width = width;
- this.height = height;
-
- if (myAxis == X_AXIS)
- {
- layoutMajorAxis(width, X_AXIS, offsetsX, spansX);
- layoutMinorAxis(height, Y_AXIS, offsetsY, spansY);
- }
- else
- {
- layoutMajorAxis(height, Y_AXIS, offsetsY, spansY);
- layoutMinorAxis(width, X_AXIS, offsetsX, spansX);
- }
+ baselineLayout(width, X_AXIS, offsetsX, spansX);
+ baselineLayout(height, Y_AXIS, offsetsY, spansY);
}
/**
@@ -586,28 +535,16 @@ public class BoxView
* to layout the children
* @param axis the axis along which the layout is performed
* @param offsets the array that holds the offsets of the children on exit
- * @param offsets the array that holds the spans of the children on exit
+ * @param spans the array that holds the spans of the children on exit
*/
protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets,
int[] spans)
{
- // Allocate SizeRequirements for each child view.
- int count = getViewCount();
- SizeRequirements[] childReqs = new SizeRequirements[count];
- for (int i = 0; i < count; ++i)
- {
- View view = getView(i);
- childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis),
- (int) view.getPreferredSpan(axis),
- (int) view.getMaximumSpan(axis),
- view.getAlignment(axis));
- }
-
+ SizeRequirements[] childReqs = getChildRequirements(axis);
// Calculate the spans and offsets using the SizeRequirements uility
// methods.
SizeRequirements.calculateTiledPositions(targetSpan, null, childReqs,
offsets, spans);
-
validateLayout(axis);
}
@@ -618,26 +555,21 @@ public class BoxView
* to layout the children
* @param axis the axis along which the layout is performed
* @param offsets the array that holds the offsets of the children on exit
- * @param offsets the array that holds the spans of the children on exit
+ * @param spans the array that holds the spans of the children on exit
*/
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets,
int[] spans)
{
- // Allocate SizeRequirements for each child view.
- int count = getViewCount();
- SizeRequirements[] childReqs = new SizeRequirements[count];
- for (int i = 0; i < count; ++i)
- {
- View view = getView(i);
- childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis),
- (int) view.getPreferredSpan(axis),
- (int) view.getMaximumSpan(axis),
- view.getAlignment(axis));
- }
-
+ SizeRequirements[] childReqs = getChildRequirements(axis);
// Calculate the spans and offsets using the SizeRequirements uility
// methods.
- SizeRequirements.calculateAlignedPositions(targetSpan, null, childReqs,
+ // TODO: This might be an opportunity for performance optimization. Here
+ // we could use a cached instance of SizeRequirements instead of passing
+ // null to baselineRequirements. However, this would involve rewriting
+ // the baselineRequirements() method to not use the SizeRequirements
+ // utility method, since they cannot reuse a cached instance.
+ SizeRequirements total = baselineRequirements(axis, null);
+ SizeRequirements.calculateAlignedPositions(targetSpan, total, childReqs,
offsets, spans);
validateLayout(axis);
}
@@ -687,6 +619,9 @@ public class BoxView
layoutChanged(X_AXIS);
if (this.height != (int) height)
layoutChanged(Y_AXIS);
+
+ this.width = (int) width;
+ this.height = (int) height;
Rectangle outside = new Rectangle(0, 0, this.width, this.height);
Rectangle inside = getInsideAllocation(outside);
@@ -706,4 +641,99 @@ public class BoxView
if (axis == Y_AXIS)
yLayoutValid = true;
}
+
+ /**
+ * Returns the size requirements of this view's children for the major
+ * axis.
+ *
+ * @return the size requirements of this view's children for the major
+ * axis
+ */
+ SizeRequirements[] getChildRequirements(int axis)
+ {
+ // Allocate SizeRequirements for each child view.
+ int count = getViewCount();
+ SizeRequirements[] childReqs = new SizeRequirements[count];
+ for (int i = 0; i < count; ++i)
+ {
+ View view = getView(i);
+ childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis),
+ (int) view.getPreferredSpan(axis),
+ (int) view.getMaximumSpan(axis),
+ view.getAlignment(axis));
+ }
+ return childReqs;
+ }
+
+ /**
+ * Returns the span for the child view with the given index for the specified
+ * axis.
+ *
+ * @param axis the axis to examine, either <code>X_AXIS</code> or
+ * <code>Y_AXIS</code>
+ * @param childIndex the index of the child for for which to return the span
+ *
+ * @return the span for the child view with the given index for the specified
+ * axis
+ */
+ protected int getSpan(int axis, int childIndex)
+ {
+ if (axis == X_AXIS)
+ return spansX[childIndex];
+ else
+ return spansY[childIndex];
+ }
+
+ /**
+ * Returns the offset for the child view with the given index for the
+ * specified axis.
+ *
+ * @param axis the axis to examine, either <code>X_AXIS</code> or
+ * <code>Y_AXIS</code>
+ * @param childIndex the index of the child for for which to return the span
+ *
+ * @return the offset for the child view with the given index for the
+ * specified axis
+ */
+ protected int getOffset(int axis, int childIndex)
+ {
+ if (axis == X_AXIS)
+ return offsetsX[childIndex];
+ else
+ return offsetsY[childIndex];
+ }
+
+ /**
+ * Returns the alignment for this box view for the specified axis. The
+ * axis that is tiled (the major axis) will be requested to be aligned
+ * centered (0.5F). The minor axis alignment depends on the child view's
+ * total alignment.
+ *
+ * @param axis the axis which is examined
+ *
+ * @return the alignment for this box view for the specified axis
+ */
+ public float getAlignment(int axis)
+ {
+ if (axis == myAxis)
+ return 0.5F;
+ else
+ return baselineRequirements(axis, null).alignment;
+ }
+
+ /**
+ * Called by a child View when its preferred span has changed.
+ *
+ * @param width indicates that the preferred width of the child changed.
+ * @param height indicates that the preferred height of the child changed.
+ * @param child the child View.
+ */
+ public void preferenceChanged (View child, boolean width, boolean height)
+ {
+ if (width)
+ xLayoutValid = false;
+ if (height)
+ yLayoutValid = false;
+ super.preferenceChanged(child, width, height);
+ }
}
diff --git a/javax/swing/text/ComponentView.java b/javax/swing/text/ComponentView.java
index e280e7c0c..366dc1c38 100644
--- a/javax/swing/text/ComponentView.java
+++ b/javax/swing/text/ComponentView.java
@@ -43,7 +43,7 @@ import java.awt.Shape;
/**
* A {@link View} implementation that is able to render arbitrary
- * {@link Components}. This uses the attribute
+ * {@link Component}s. This uses the attribute
* {@link StyleConstants#ComponentAttribute} to determine the
* <code>Component</code> that should be rendered. This <code>Component</code>
* becomes a direct child of the <code>JTextComponent</code> that contains
@@ -53,6 +53,7 @@ import java.awt.Shape;
* @author original author unknown
* @author Roman Kennke (roman@kennke.org)
*/
+// FIXME: This class is a complete stub and needs to be implemented properly.
public class ComponentView extends View
{
/**
@@ -118,38 +119,45 @@ public class ComponentView extends View
return 0;
}
- public float getMinimumSpan(int axis)
- {
- return 0;
- }
-
- public float getPreferredSpan(int axis)
- {
- return 0;
- }
-
- public Shape modelToView(int pos, Shape a, Position.Bias b)
- throws BadLocationException
- {
- return null;
- }
-
- public void paint(Graphics g, Shape a)
- {
- }
+ public float getMinimumSpan(int axis)
+ {
+ // TODO: Implement this properly.
+ return 0;
+ }
+
+ public float getPreferredSpan(int axis)
+ {
+ // TODO: Implement this properly.
+ return 0;
+ }
+
+ public Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException
+ {
+ // TODO: Implement this properly.
+ return null;
+ }
- public void setParent(View p)
- {
- }
+ public void paint(Graphics g, Shape a)
+ {
+ // TODO: Implement this properly.
+ }
+
+ public void setParent(View p)
+ {
+ // TODO: Implement this properly.
+ }
- public void setSize(float width, float height)
- {
- }
+ public void setSize(float width, float height)
+ {
+ // TODO: Implement this properly.
+ }
- public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)
- {
- return 0;
- }
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)
+ {
+ // TODO: Implement this properly.
+ return 0;
+ }
/**
* Maps coordinates from the <code>View</code>'s space into a position
diff --git a/javax/swing/text/CompositeView.java b/javax/swing/text/CompositeView.java
index b3dd6123e..6d8ca912f 100644
--- a/javax/swing/text/CompositeView.java
+++ b/javax/swing/text/CompositeView.java
@@ -62,7 +62,7 @@ public abstract class CompositeView
/**
* The allocation of this <code>View</code> minus its insets. This is
* initialized in {@link #getInsideAllocation} and reused and modified in
- * {@link childAllocation}.
+ * {@link #childAllocation(int, Rectangle)}.
*/
Rectangle insideAllocation;
@@ -434,10 +434,16 @@ public abstract class CompositeView
*/
protected int getViewIndexAtPosition(int pos)
{
- // We have one child view allocated for each child element in
- // loadChildren(), so this should work.
- Element el = getElement();
- int index = el.getElementIndex(pos);
+ int index = -1;
+ for (int i = 0; i < children.length; i++)
+ {
+ if (children[i].getStartOffset() <= pos
+ && children[i].getEndOffset() > pos)
+ {
+ index = i;
+ break;
+ }
+ }
return index;
}
@@ -474,8 +480,8 @@ public abstract class CompositeView
insideAllocation = inside;
}
}
- inside.x = alloc.x - insets.left;
- inside.y = alloc.y - insets.top;
+ inside.x = alloc.x + insets.left;
+ inside.y = alloc.y + insets.top;
inside.width = alloc.width - insets.left - insets.right;
inside.height = alloc.height - insets.top - insets.bottom;
return inside;
diff --git a/javax/swing/text/DefaultCaret.java b/javax/swing/text/DefaultCaret.java
index 401e2e08f..e5d28d0b8 100644
--- a/javax/swing/text/DefaultCaret.java
+++ b/javax/swing/text/DefaultCaret.java
@@ -45,10 +45,15 @@ import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.EventListener;
+import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
import javax.swing.event.EventListenerList;
/**
@@ -60,9 +65,128 @@ import javax.swing.event.EventListenerList;
public class DefaultCaret extends Rectangle
implements Caret, FocusListener, MouseListener, MouseMotionListener
{
+ /**
+ * Listens for changes in the text component's document and updates the
+ * caret accordingly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ private class DocumentHandler implements DocumentListener
+ {
+ /**
+ * Receives notification that some text attributes have changed. No action
+ * is taken here.
+ *
+ * @param event the document event
+ */
+ public void changedUpdate(DocumentEvent event)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Receives notification that some text has been inserted from the text
+ * component. The caret is moved forward accordingly.
+ *
+ * @param event the document event
+ */
+ public void insertUpdate(DocumentEvent event)
+ {
+ if (policy == ALWAYS_UPDATE ||
+ (SwingUtilities.isEventDispatchThread() &&
+ policy == UPDATE_WHEN_ON_EDT))
+ {
+ int dot = getDot();
+ setDot(dot + event.getLength());
+ }
+ }
+
+ /**
+ * Receives notification that some text has been removed into the text
+ * component. The caret is moved backwards accordingly.
+ *
+ * @param event the document event
+ */
+ public void removeUpdate(DocumentEvent event)
+ {
+ if (policy == ALWAYS_UPDATE ||
+ (SwingUtilities.isEventDispatchThread() &&
+ policy == UPDATE_WHEN_ON_EDT))
+ {
+ int dot = getDot();
+ setDot(dot - event.getLength());
+ }
+ else if (policy == NEVER_UPDATE)
+ {
+ int docLength = event.getDocument().getLength();
+ if (getDot() > docLength)
+ setDot(docLength);
+ }
+ }
+ }
+
+ /**
+ * Listens for property changes on the text document. This is used to add and
+ * remove our document listener, if the document of the text component has
+ * changed.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ private class PropertyChangeHandler implements PropertyChangeListener
+ {
+
+ /**
+ * Receives notification when a property has changed on the text component.
+ * This adds/removes our document listener from the text component's
+ * document when the document changes.
+ *
+ * @param e the property change event
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals("document"))
+ {
+ Document oldDoc = (Document) e.getOldValue();
+ oldDoc.removeDocumentListener(documentListener);
+ Document newDoc = (Document) e.getNewValue();
+ newDoc.addDocumentListener(documentListener);
+ }
+ }
+
+ }
+
/** The serialization UID (compatible with JDK1.5). */
private static final long serialVersionUID = 4325555698756477346L;
-
+
+ /**
+ * Indicates the Caret position should always be updated after Document
+ * changes even if the updates are not performed on the Event Dispatching
+ * thread.
+ *
+ * @since 1.5
+ */
+ public static final int ALWAYS_UPDATE = 2;
+
+ /**
+ * Indicates the Caret position should not be changed unless the Document
+ * length becomes less than the Caret position, in which case the Caret
+ * is moved to the end of the Document.
+ *
+ * @since 1.5
+ */
+ public static final int NEVER_UPDATE = 1;
+
+ /**
+ * Indicates the Caret position should be updated only if Document changes
+ * are made on the Event Dispatcher thread.
+ *
+ * @since 1.5
+ */
+ public static final int UPDATE_WHEN_ON_EDT = 0;
+
+ /** Keeps track of the current update policy **/
+ int policy = UPDATE_WHEN_ON_EDT;
+
/**
* The <code>ChangeEvent</code> that is fired by {@link #fireStateChanged()}.
*/
@@ -74,6 +198,16 @@ public class DefaultCaret extends Rectangle
protected EventListenerList listenerList = new EventListenerList();
/**
+ * Our document listener.
+ */
+ DocumentListener documentListener;
+
+ /**
+ * Our property listener.
+ */
+ PropertyChangeListener propertyChangeListener;
+
+ /**
* The text component in which this caret is installed.
*/
private JTextComponent textComponent;
@@ -114,6 +248,43 @@ public class DefaultCaret extends Rectangle
private Object highlightEntry;
/**
+ * Sets the Caret update policy.
+ *
+ * @param policy the new policy. Valid values are:
+ * ALWAYS_UPDATE: always update the Caret position, even when Document
+ * updates don't occur on the Event Dispatcher thread.
+ * NEVER_UPDATE: don't update the Caret position unless the Document
+ * length becomes less than the Caret position (then update the
+ * Caret to the end of the Document).
+ * UPDATE_WHEN_ON_EDT: update the Caret position when the
+ * Document updates occur on the Event Dispatcher thread. This is the
+ * default.
+ *
+ * @since 1.5
+ * @throws IllegalArgumentException if policy is not one of the above.
+ */
+ public void setUpdatePolicy (int policy)
+ {
+ if (policy != ALWAYS_UPDATE && policy != NEVER_UPDATE
+ && policy != UPDATE_WHEN_ON_EDT)
+ throw new
+ IllegalArgumentException
+ ("policy must be ALWAYS_UPDATE, NEVER__UPDATE, or UPDATE_WHEN_ON_EDT");
+ this.policy = policy;
+ }
+
+ /**
+ * Gets the caret update policy.
+ *
+ * @return the caret update policy.
+ * @since 1.5
+ */
+ public int getUpdatePolicy ()
+ {
+ return policy;
+ }
+
+ /**
* Moves the caret position when the mouse is dragged over the text
* component, modifying the selection accordingly.
*
@@ -173,6 +344,7 @@ public class DefaultCaret extends Rectangle
*/
public void mouseExited(MouseEvent event)
{
+ // TODO: What to do here, if anything?
}
/**
@@ -186,6 +358,9 @@ public class DefaultCaret extends Rectangle
public void mousePressed(MouseEvent event)
{
// FIXME: Implement this properly.
+ if (!(event.getButton() == MouseEvent.BUTTON1))
+ return;
+ setDot(textComponent.viewToModel(event.getPoint()));
}
/**
@@ -206,6 +381,7 @@ public class DefaultCaret extends Rectangle
*/
public void focusGained(FocusEvent event)
{
+ // TODO: Implement this properly.
}
/**
@@ -215,6 +391,7 @@ public class DefaultCaret extends Rectangle
*/
public void focusLost(FocusEvent event)
{
+ // TODO: Implement this properly.
}
/**
@@ -251,6 +428,10 @@ public class DefaultCaret extends Rectangle
textComponent.removeFocusListener(this);
textComponent.removeMouseListener(this);
textComponent.removeMouseMotionListener(this);
+ textComponent.getDocument().removeDocumentListener(documentListener);
+ documentListener = null;
+ textComponent.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
textComponent = null;
}
@@ -267,6 +448,10 @@ public class DefaultCaret extends Rectangle
textComponent.addFocusListener(this);
textComponent.addMouseListener(this);
textComponent.addMouseMotionListener(this);
+ propertyChangeListener = new PropertyChangeHandler();
+ textComponent.addPropertyChangeListener(propertyChangeListener);
+ documentListener = new DocumentHandler();
+ textComponent.getDocument().addDocumentListener(documentListener);
repaint();
}
@@ -374,10 +559,7 @@ public class DefaultCaret extends Rectangle
*/
protected final void repaint()
{
- // FIXME: Is this good? This possibly causes alot of the component
- // hierarchy to be repainted on every caret blink.
- if (textComponent != null)
- textComponent.repaint();
+ textComponent.repaint(this);
}
/**
@@ -572,8 +754,11 @@ public class DefaultCaret extends Rectangle
*/
public void setVisible(boolean v)
{
- visible = v;
- repaint();
+ if (v != visible)
+ {
+ visible = v;
+ repaint();
+ }
}
/**
diff --git a/javax/swing/text/DefaultEditorKit.java b/javax/swing/text/DefaultEditorKit.java
index 2f901947f..3b3fc1f72 100644
--- a/javax/swing/text/DefaultEditorKit.java
+++ b/javax/swing/text/DefaultEditorKit.java
@@ -222,9 +222,6 @@ public class DefaultEditorKit extends EditorKit
{
t.getDocument().insertString(t.getCaret().getDot(),
event.getActionCommand(), null);
- t.getCaret().setDot(Math.min(t.getCaret().getDot() + 1,
- t.getDocument().getEndPosition()
- .getOffset()));
}
catch (BadLocationException be)
{
@@ -286,6 +283,8 @@ public class DefaultEditorKit extends EditorKit
*/
public void actionPerformed(ActionEvent event)
{
+ // FIXME: Figure out what this Action is supposed to do. Obviously text
+ // that is entered by the user is inserted through DefaultKeyTypedAction.
}
}
@@ -692,6 +691,7 @@ public class DefaultEditorKit extends EditorKit
*/
public DefaultEditorKit()
{
+ // Nothing to do here.
}
/**
@@ -947,15 +947,23 @@ public class DefaultEditorKit extends EditorKit
* @param offset the beginning offset from where to write
* @param len the length of the fragment to write
*
- * @throws BadLocationException if <code>offset</code> or
- * <code>offset + len</code>is an invalid location inside
- * <code>document</code>
+ * @throws BadLocationException if <code>offset</code> is an
+ * invalid location inside <code>document</code>.
* @throws IOException if something goes wrong while writing to
* <code>out</code>
*/
public void write(Writer out, Document document, int offset, int len)
- throws BadLocationException, IOException
+ throws BadLocationException, IOException
{
- // TODO: Implement this properly.
+ // Throw a BLE if offset is invalid
+ if (offset < 0 || offset > document.getLength())
+ throw new BadLocationException("Tried to write to invalid location",
+ offset);
+
+ // If they gave an overly large len, just adjust it
+ if (offset + len > document.getLength())
+ len = document.getLength() - offset;
+
+ out.write(document.getText(offset, len));
}
}
diff --git a/javax/swing/text/DefaultFormatter.java b/javax/swing/text/DefaultFormatter.java
index 16d40c24b..f9e0f10e6 100644
--- a/javax/swing/text/DefaultFormatter.java
+++ b/javax/swing/text/DefaultFormatter.java
@@ -175,7 +175,10 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter
catch (ParseException pe)
{
// if that happens, something serious must be wrong
- throw new AssertionError("values must be parseable");
+ AssertionError ae;
+ ae = new AssertionError("values must be parseable");
+ ae.initCause(pe);
+ throw ae;
}
}
}
diff --git a/javax/swing/text/DefaultHighlighter.java b/javax/swing/text/DefaultHighlighter.java
index c8d874caa..40ea4f80a 100644
--- a/javax/swing/text/DefaultHighlighter.java
+++ b/javax/swing/text/DefaultHighlighter.java
@@ -168,6 +168,7 @@ public class DefaultHighlighter extends LayeredHighlighter
public DefaultHighlighter()
{
+ // Nothing to do here.
}
public boolean getDrawsLayeredHighlights()
@@ -238,6 +239,7 @@ public class DefaultHighlighter extends LayeredHighlighter
Shape viewBounds, JTextComponent editor,
View view)
{
+ // TODO: Implement this properly.
}
public void paint(Graphics g)
diff --git a/javax/swing/text/DefaultStyledDocument.java b/javax/swing/text/DefaultStyledDocument.java
index 765477507..648b0bd4d 100644
--- a/javax/swing/text/DefaultStyledDocument.java
+++ b/javax/swing/text/DefaultStyledDocument.java
@@ -899,6 +899,10 @@ public class DefaultStyledDocument extends AbstractDocument
/**
* Returns the paragraph element for the specified position.
+ * If the position is outside the bounds of the document's root element,
+ * then the closest element is returned. That is the last paragraph if
+ * <code>position >= endIndex</code> or the first paragraph if
+ * <code>position < startIndex</code>.
*
* @param position the position for which to query the paragraph element
*
@@ -907,7 +911,16 @@ public class DefaultStyledDocument extends AbstractDocument
public Element getParagraphElement(int position)
{
BranchElement root = (BranchElement) getDefaultRootElement();
+ int start = root.getStartOffset();
+ int end = root.getEndOffset();
+ if (position >= end)
+ position = end - 1;
+ else if (position < start)
+ position = start;
+
Element par = root.positionToElement(position);
+
+ assert par != null : "The paragraph element must not be null";
return par;
}
@@ -1060,8 +1073,9 @@ public class DefaultStyledDocument extends AbstractDocument
}
catch (BadLocationException ex)
{
- throw new AssertionError("BadLocationException must not be thrown "
- + "here.");
+ AssertionError ae = new AssertionError("Unexpected bad location");
+ ae.initCause(ex);
+ throw ae;
}
int len = 0;
diff --git a/javax/swing/text/EditorKit.java b/javax/swing/text/EditorKit.java
index bd51a866f..8719aee59 100644
--- a/javax/swing/text/EditorKit.java
+++ b/javax/swing/text/EditorKit.java
@@ -48,24 +48,24 @@ import java.io.Writer;
import javax.swing.Action;
import javax.swing.JEditorPane;
-public abstract class EditorKit
- implements Cloneable, Serializable
+public abstract class EditorKit implements Cloneable, Serializable
{
private static final long serialVersionUID = -5044124649345887822L;
public EditorKit()
{
+ // Nothing to do here.
}
public Object clone()
{
try
{
- return super.clone();
+ return super.clone();
}
catch (CloneNotSupportedException e)
{
- return null;
+ return null;
}
}
@@ -74,10 +74,12 @@ public abstract class EditorKit
*/
public void deinstall(JEditorPane c)
{
+ // This default implementation does nothing.
}
public void install(JEditorPane c)
{
+ // This default implementation does nothing.
}
public abstract Caret createCaret();
diff --git a/javax/swing/text/FieldView.java b/javax/swing/text/FieldView.java
index e2e04d7c4..d8a3568e5 100644
--- a/javax/swing/text/FieldView.java
+++ b/javax/swing/text/FieldView.java
@@ -118,7 +118,7 @@ public class FieldView extends PlainView
FontMetrics fm = getFontMetrics();
if (axis == Y_AXIS)
- return fm.getHeight();
+ return super.getPreferredSpan(axis);
String text;
Element elem = getElement();
@@ -134,7 +134,7 @@ public class FieldView extends PlainView
text = "";
}
- return fm.stringWidth(text);
+ return fm.stringWidth(text) + 30;
}
public int getResizeWeight(int axis)
@@ -159,18 +159,21 @@ public class FieldView extends PlainView
{
Shape newAlloc = adjustAllocation(shape);
super.insertUpdate(ev, newAlloc, vf);
+ getContainer().repaint();
}
public void removeUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
{
Shape newAlloc = adjustAllocation(shape);
super.removeUpdate(ev, newAlloc, vf);
+ getContainer().repaint();
}
public void changedUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
{
Shape newAlloc = adjustAllocation(shape);
super.removeUpdate(ev, newAlloc, vf);
+ getContainer().repaint();
}
public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias)
diff --git a/javax/swing/text/FlowView.java b/javax/swing/text/FlowView.java
index a6ef89efb..5f23ba987 100644
--- a/javax/swing/text/FlowView.java
+++ b/javax/swing/text/FlowView.java
@@ -42,6 +42,7 @@ import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
+import java.util.Iterator;
import java.util.Vector;
import javax.swing.event.DocumentEvent;
@@ -71,6 +72,7 @@ public abstract class FlowView extends BoxView
*/
public FlowStrategy()
{
+ // Nothing to do here.
}
/**
@@ -137,7 +139,7 @@ public abstract class FlowView extends BoxView
* Performs the layout for the whole view. By default this rebuilds
* all the physical views from the logical views of the managed FlowView.
*
- * This is called by {@link FlowLayout#layout} to update the layout of
+ * This is called by {@link FlowView#layout} to update the layout of
* the view.
*
* @param fv the flow view for which we perform the layout
@@ -183,11 +185,17 @@ public abstract class FlowView extends BoxView
{
View child = createView(fv, offset, spanLeft, rowIndex);
if (child == null)
- break;
+ {
+ offset = -1;
+ break;
+ }
int span = (int) child.getPreferredSpan(flowAxis);
if (span > spanLeft)
- break;
+ {
+ offset = -1;
+ break;
+ }
row.append(child);
spanLeft -= span;
@@ -204,7 +212,7 @@ public abstract class FlowView extends BoxView
* not fit in the available span and also cannot be broken down).
*
* @param fv the flow view
- * @param startOffset the start offset for the view to be created
+ * @param offset the start offset for the view to be created
* @param spanLeft the available span
* @param rowIndex the index of the row
*
@@ -218,13 +226,15 @@ public abstract class FlowView extends BoxView
View logicalView = getLogicalView(fv);
int viewIndex = logicalView.getViewIndex(offset, Position.Bias.Forward);
+ if (viewIndex == -1)
+ return null;
+
View child = logicalView.getView(viewIndex);
int flowAxis = fv.getFlowAxis();
int span = (int) child.getPreferredSpan(flowAxis);
if (span <= spanLeft)
return child;
-
else if (child.getBreakWeight(flowAxis, offset, spanLeft)
> BadBreakWeight)
// FIXME: What to do with the pos parameter here?
@@ -326,7 +336,19 @@ public abstract class FlowView extends BoxView
*/
public int getViewIndex(int pos, Position.Bias b)
{
- return getElement().getElementIndex(pos);
+ int index = -1;
+ int i = 0;
+ for (Iterator it = children.iterator(); it.hasNext(); i++)
+ {
+ View child = (View) it.next();
+ if (child.getStartOffset() >= pos
+ && child.getEndOffset() < pos)
+ {
+ index = i;
+ break;
+ }
+ }
+ return index;
}
/**
@@ -478,7 +500,7 @@ public abstract class FlowView extends BoxView
* The real children are created at layout time and each represent one
* row.
*
- * This method is called by {@link #setParent} in order to initialize
+ * This method is called by {@link View#setParent} in order to initialize
* the view.
*
* @param vf the view factory to use for creating the child views
@@ -502,7 +524,7 @@ public abstract class FlowView extends BoxView
/**
* Performs the layout of this view. If the span along the flow axis changed,
- * this first calls {@link FlowStrategy.layout} in order to rebuild the
+ * this first calls {@link FlowStrategy#layout} in order to rebuild the
* rows of this view. Then the superclass's behaviour is called to arrange
* the rows within the box.
*
diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java
index 5c8f81865..439365e59 100644
--- a/javax/swing/text/GapContent.java
+++ b/javax/swing/text/GapContent.java
@@ -45,6 +45,9 @@ import java.util.Iterator;
import java.util.ListIterator;
import java.util.Vector;
+import javax.swing.undo.AbstractUndoableEdit;
+import javax.swing.undo.CannotRedoException;
+import javax.swing.undo.CannotUndoException;
import javax.swing.undo.UndoableEdit;
/**
@@ -116,7 +119,7 @@ public class GapContent
public int getOffset()
{
// Check precondition.
- assert mark <= gapStart || mark > gapEnd : "mark: " + mark
+ assert mark <= gapStart || mark >= gapEnd : "mark: " + mark
+ ", gapStart: " + gapStart
+ ", gapEnd: " + gapEnd;
@@ -127,6 +130,83 @@ public class GapContent
}
}
+ class UndoInsertString extends AbstractUndoableEdit
+ {
+ public int where, length;
+ String text;
+ public UndoInsertString(int start, int len)
+ {
+ where = start;
+ length = len;
+ }
+
+ public void undo () throws CannotUndoException
+ {
+ super.undo();
+ try
+ {
+ text = getString(where, length);
+ remove(where, length);
+ }
+ catch (BadLocationException ble)
+ {
+ throw new CannotUndoException();
+ }
+ }
+
+ public void redo () throws CannotUndoException
+ {
+ super.redo();
+ try
+ {
+ insertString(where, text);
+ }
+ catch (BadLocationException ble)
+ {
+ throw new CannotRedoException();
+ }
+ }
+
+ }
+
+ class UndoRemove extends AbstractUndoableEdit
+ {
+ public int where;
+ String text;
+ public UndoRemove(int start, String removedText)
+ {
+ where = start;
+ text = removedText;
+ }
+
+ public void undo () throws CannotUndoException
+ {
+ super.undo();
+ try
+ {
+ insertString(where, text);
+ }
+ catch (BadLocationException ble)
+ {
+ throw new CannotUndoException();
+ }
+ }
+
+ public void redo () throws CannotUndoException
+ {
+ super.redo();
+ try
+ {
+ remove(where, text.length());
+ }
+ catch (BadLocationException ble)
+ {
+ throw new CannotRedoException();
+ }
+ }
+
+ }
+
/** The serialization UID (compatible with JDK1.5). */
private static final long serialVersionUID = -6226052713477823730L;
@@ -218,8 +298,7 @@ public class GapContent
* @param where the position where the string is inserted
* @param str the string that is to be inserted
*
- * @return an UndoableEdit object (currently not supported, so
- * <code>null</code> is returned)
+ * @return an UndoableEdit object
*
* @throws BadLocationException if <code>where</code> is not a valid
* location in the buffer
@@ -235,9 +314,9 @@ public class GapContent
throw new BadLocationException("the where argument cannot be greater"
+ " than the content length", where);
- replace(where, 0, str.toCharArray(), str.length());
+ replace(where, 0, str.toCharArray(), strLen);
- return null;
+ return new UndoInsertString(where, strLen);
}
/**
@@ -246,8 +325,7 @@ public class GapContent
* @param where the position where the content is to be removed
* @param nitems number of characters to be removed
*
- * @return an UndoableEdit object (currently not supported, so
- * <code>null</code> is returned)
+ * @return an UndoableEdit object
*
* @throws BadLocationException if <code>where</code> is not a valid
* location in the buffer
@@ -264,9 +342,10 @@ public class GapContent
throw new BadLocationException("where + nitems cannot be greater"
+ " than the content length", where + nitems);
+ String removedText = getString(where, nitems);
replace(where, nitems, null, 0);
- return null;
+ return new UndoRemove(where, removedText);
}
/**
@@ -379,7 +458,6 @@ public class GapContent
if (index < 0)
index = -(index + 1);
positions.add(index, pos);
-
return pos;
}
@@ -398,12 +476,7 @@ public class GapContent
int delta = newSize - gapEnd + gapStart;
// Update the marks after the gapEnd.
- Vector v = getPositionsInRange(null, gapEnd, buffer.length - gapEnd);
- for (Iterator i = v.iterator(); i.hasNext();)
- {
- GapContentPosition p = (GapContentPosition) i.next();
- p.mark += delta;
- }
+ adjustPositionsInRange(gapEnd, buffer.length - gapEnd, delta);
// Copy the data around.
char[] newBuf = (char[]) allocateArray(length() + newSize);
@@ -426,18 +499,11 @@ public class GapContent
return;
int newGapEnd = newGapStart + gapEnd - gapStart;
-
if (newGapStart < gapStart)
{
// Update the positions between newGapStart and (old) gapStart. The marks
// must be shifted by (gapEnd - gapStart).
- Vector v = getPositionsInRange(null, newGapStart + 1,
- gapStart - newGapStart + 1);
- for (Iterator i = v.iterator(); i.hasNext();)
- {
- GapContentPosition p = (GapContentPosition) i.next();
- p.mark += gapEnd - gapStart;
- }
+ adjustPositionsInRange(newGapStart, gapStart - newGapStart, gapEnd - gapStart);
System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart
- newGapStart);
gapStart = newGapStart;
@@ -447,18 +513,14 @@ public class GapContent
{
// Update the positions between newGapEnd and (old) gapEnd. The marks
// must be shifted by (gapEnd - gapStart).
- Vector v = getPositionsInRange(null, gapEnd,
- newGapEnd - gapEnd);
- for (Iterator i = v.iterator(); i.hasNext();)
- {
- GapContentPosition p = (GapContentPosition) i.next();
- p.mark -= gapEnd - gapStart;
- }
+ adjustPositionsInRange(gapEnd, newGapEnd - gapEnd, -(gapEnd - gapStart));
System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart
- gapStart);
gapStart = newGapStart;
gapEnd = newGapEnd;
}
+ if (gapStart == 0)
+ resetMarksAtZero();
}
/**
@@ -476,12 +538,7 @@ public class GapContent
assert newGapStart < gapStart : "The new gap start must be less than the "
+ "old gap start.";
- Vector v = getPositionsInRange(null, newGapStart, gapStart - newGapStart);
- for (Iterator i = v.iterator(); i.hasNext();)
- {
- GapContentPosition p = (GapContentPosition) i.next();
- p.mark = gapStart;
- }
+ setPositionsInRange(newGapStart, gapStart - newGapStart, gapStart);
gapStart = newGapStart;
}
@@ -500,12 +557,7 @@ public class GapContent
assert newGapEnd > gapEnd : "The new gap end must be greater than the "
+ "old gap end.";
- Vector v = getPositionsInRange(null, gapEnd, newGapEnd - gapEnd);
- for (Iterator i = v.iterator(); i.hasNext();)
- {
- GapContentPosition p = (GapContentPosition) i.next();
- p.mark = newGapEnd + 1;
- }
+ setPositionsInRange(gapEnd, newGapEnd - gapEnd, newGapEnd + 1);
gapEnd = newGapEnd;
}
@@ -530,9 +582,11 @@ public class GapContent
protected void replace(int position, int rmSize, Object addItems,
int addSize)
{
+ if (gapStart != position)
+ shiftGap(position);
// Remove content
- shiftGap(position);
- shiftGapEndUp(gapEnd + rmSize);
+ if (rmSize > 0)
+ shiftGapEndUp(gapEnd + rmSize);
// If gap is too small, enlarge the gap.
if ((gapEnd - gapStart) <= addSize)
@@ -588,21 +642,121 @@ public class GapContent
int index1 = Collections.binarySearch(positions,
new GapContentPosition(offset));
- int index2 = Collections.binarySearch(positions,
- new GapContentPosition(endOffset));
if (index1 < 0)
index1 = -(index1 + 1);
- if (index2 < 0)
- index2 = -(index2 + 1);
for (ListIterator i = positions.listIterator(index1); i.hasNext();)
{
- if (i.nextIndex() > index2)
- break;
-
GapContentPosition p = (GapContentPosition) i.next();
+ if (p.mark > endOffset)
+ break;
if (p.mark >= offset && p.mark <= endOffset)
res.add(p);
}
return res;
}
+
+ /**
+ * Sets the mark of all <code>Position</code>s that are in the range
+ * specified by <code>offset</code> and </code>length</code> within
+ * the buffer array to <code>value</code>
+ *
+ * @param offset the start offset of the range to search
+ * @param length the length of the range to search
+ * @param value the new value for each mark
+ */
+ void setPositionsInRange(int offset, int length, int value)
+ {
+ int endOffset = offset + length;
+
+ int index1 = Collections.binarySearch(positions,
+ new GapContentPosition(offset));
+ if (index1 < 0)
+ index1 = -(index1 + 1);
+ for (ListIterator i = positions.listIterator(index1); i.hasNext();)
+ {
+ GapContentPosition p = (GapContentPosition) i.next();
+ if (p.mark > endOffset)
+ break;
+
+ if (p.mark >= offset && p.mark <= endOffset)
+ p.mark = value;
+ }
+ }
+
+ /**
+ * Adjusts the mark of all <code>Position</code>s that are in the range
+ * specified by <code>offset</code> and </code>length</code> within
+ * the buffer array by <code>increment</code>
+ *
+ * @param offset the start offset of the range to search
+ * @param length the length of the range to search
+ * @param incr the increment
+ */
+ void adjustPositionsInRange(int offset, int length, int incr)
+ {
+ int endOffset = offset + length;
+
+ int index1 = Collections.binarySearch(positions,
+ new GapContentPosition(offset));
+ if (index1 < 0)
+ index1 = -(index1 + 1);
+ for (ListIterator i = positions.listIterator(index1); i.hasNext();)
+ {
+ GapContentPosition p = (GapContentPosition) i.next();
+ if (p.mark > endOffset)
+ break;
+
+ if (p.mark >= offset && p.mark <= endOffset)
+ p.mark += incr;
+ }
+ }
+
+ /**
+ * Resets all <code>Position</code> that have an offset of <code>0</code>,
+ * to also have an array index of <code>0</code>. This might be necessary
+ * after a call to <code>shiftGap(0)</code>, since then the marks at offset
+ * <code>0</code> get shifted to <code>gapEnd</code>.
+ */
+ protected void resetMarksAtZero()
+ {
+ if (gapStart != 0)
+ return;
+
+ setPositionsInRange(gapEnd, 0, 0);
+ }
+
+ /**
+ * Outputs debugging info to System.err. It prints out the buffer array,
+ * the gapStart is marked by a &lt; sign, the gapEnd is marked by a &gt;
+ * sign and each position is marked by a # sign.
+ */
+ private void dump()
+ {
+ System.err.println("GapContent debug information");
+ System.err.println("buffer length: " + buffer.length);
+ System.err.println("gap start: " + gapStart);
+ System.err.println("gap end: " + gapEnd);
+ for (int i = 0; i < buffer.length; i++)
+ {
+ if (i == gapStart)
+ System.err.print('<');
+ if (i == gapEnd)
+ System.err.print('>');
+
+ if (!Character.isISOControl(buffer[i]))
+ System.err.print(buffer[i]);
+ else
+ System.err.print('.');
+ }
+ System.err.println();
+ }
+
+ private void dumpPositions()
+ {
+ for (Iterator i = positions.iterator(); i.hasNext();)
+ {
+ GapContentPosition pos = (GapContentPosition) i.next();
+ System.err.println("position at: " + pos.mark);
+ }
+ }
}
diff --git a/javax/swing/text/GlyphView.java b/javax/swing/text/GlyphView.java
index 6ffab23c4..b516d20e4 100644
--- a/javax/swing/text/GlyphView.java
+++ b/javax/swing/text/GlyphView.java
@@ -44,6 +44,7 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
+import java.awt.Toolkit;
import java.text.BreakIterator;
import javax.swing.SwingConstants;
@@ -71,6 +72,7 @@ public class GlyphView extends View implements TabableView, Cloneable
*/
public GlyphPainter()
{
+ // Nothing to do here.
}
/**
@@ -258,7 +260,7 @@ public class GlyphView extends View implements TabableView, Cloneable
public float getHeight(GlyphView view)
{
Font font = view.getFont();
- FontMetrics metrics = view.getContainer().getFontMetrics(font);
+ FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(font);
float height = metrics.getHeight();
return height;
}
@@ -377,7 +379,7 @@ public class GlyphView extends View implements TabableView, Cloneable
{
Element el = view.getElement();
Font font = view.getFont();
- FontMetrics fm = view.getContainer().getFontMetrics(font);
+ FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font);
Segment txt = view.getText(p0, p1);
int span = Utilities.getTabbedTextWidth(txt, fm, (int) x, te, p0);
return span;
@@ -664,8 +666,11 @@ public class GlyphView extends View implements TabableView, Cloneable
}
catch (BadLocationException ex)
{
- throw new AssertionError("BadLocationException must not be thrown "
- + "here");
+ AssertionError ae;
+ ae = new AssertionError("BadLocationException must not be thrown "
+ + "here");
+ ae.initCause(ex);
+ throw ae;
}
FontMetrics fm = null; // Fetch font metrics somewhere.
return Utilities.getTabbedTextWidth(seg, fm, 0, null, p0);
@@ -712,8 +717,11 @@ public class GlyphView extends View implements TabableView, Cloneable
}
catch (BadLocationException ex)
{
- throw new AssertionError("BadLocationException should not be "
- + "thrown here. p0 = " + p0 + ", p1 = " + p1);
+ AssertionError ae;
+ ae = new AssertionError("BadLocationException should not be "
+ + "thrown here. p0 = " + p0 + ", p1 = " + p1);
+ ae.initCause(ex);
+ throw ae;
}
return txt;
diff --git a/javax/swing/text/JTextComponent.java b/javax/swing/text/JTextComponent.java
index 63dbf2a4b..be68cd5d7 100644
--- a/javax/swing/text/JTextComponent.java
+++ b/javax/swing/text/JTextComponent.java
@@ -53,6 +53,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputMethodListener;
import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
@@ -89,6 +90,7 @@ public abstract class JTextComponent extends JComponent
/**
* AccessibleJTextComponent
*/
+ // FIXME: This inner class is a complete stub and needs to be implemented.
public class AccessibleJTextComponent extends AccessibleJComponent
implements AccessibleText, CaretListener, DocumentListener
{
@@ -99,6 +101,7 @@ public abstract class JTextComponent extends JComponent
*/
public AccessibleJTextComponent()
{
+ // Nothing to do here.
}
/**
@@ -321,7 +324,7 @@ public abstract class JTextComponent extends JComponent
{
Caret c = caret;
if (c != null)
- c.setVisible(!c.isVisible());
+ c.setVisible(!c.isVisible());
}
/**
@@ -332,13 +335,13 @@ public abstract class JTextComponent extends JComponent
stop();
Caret c = caret;
if (c != null)
- {
- setDelay(c.getBlinkRate());
- if (editable)
- start();
- else
- c.setVisible(false);
- }
+ {
+ setDelay(c.getBlinkRate());
+ if (editable)
+ start();
+ else
+ c.setVisible(false);
+ }
}
}
@@ -628,23 +631,23 @@ public abstract class JTextComponent extends JComponent
int end = textComponent.getSelectionEnd();
if (start == end)
- return;
+ return;
try
- {
- // Copy text to clipboard.
- String data = textComponent.getDocument().getText(start, end);
- StringSelection selection = new StringSelection(data);
- clipboard.setContents(selection, null);
-
- // Delete selected text on cut action.
- if (action == MOVE)
- doc.remove(start, end - start);
- }
+ {
+ // Copy text to clipboard.
+ String data = textComponent.getDocument().getText(start, end);
+ StringSelection selection = new StringSelection(data);
+ clipboard.setContents(selection, null);
+
+ // Delete selected text on cut action.
+ if (action == MOVE)
+ doc.remove(start, end - start);
+ }
catch (BadLocationException e)
- {
- // Ignore this and do nothing.
- }
+ {
+ // Ignore this and do nothing.
+ }
}
public int getSourceActions()
@@ -658,30 +661,30 @@ public abstract class JTextComponent extends JComponent
DataFlavor[] flavors = transferable.getTransferDataFlavors();
if (flavors == null)
- return false;
+ return false;
for (int i = 0; i < flavors.length; ++i)
- if (flavors[i].equals(DataFlavor.stringFlavor))
- flavor = flavors[i];
+ if (flavors[i].equals(DataFlavor.stringFlavor))
+ flavor = flavors[i];
if (flavor == null)
- return false;
+ return false;
try
- {
- JTextComponent textComponent = (JTextComponent) component;
- String data = (String) transferable.getTransferData(flavor);
- textComponent.replaceSelection(data);
- return true;
- }
+ {
+ JTextComponent textComponent = (JTextComponent) component;
+ String data = (String) transferable.getTransferData(flavor);
+ textComponent.replaceSelection(data);
+ return true;
+ }
catch (IOException e)
- {
- // Ignored.
- }
+ {
+ // Ignored.
+ }
catch (UnsupportedFlavorException e)
- {
- // Ignored.
- }
+ {
+ // Ignored.
+ }
return false;
}
@@ -1018,12 +1021,17 @@ public abstract class JTextComponent extends JComponent
{
try
{
- doc.remove(0, doc.getLength());
- doc.insertString(0, text, null);
+ if (doc instanceof AbstractDocument)
+ ((AbstractDocument) doc).replace(0, doc.getLength(), text, null);
+ else
+ {
+ doc.remove(0, doc.getLength());
+ doc.insertString(0, text, null);
+ }
}
catch (BadLocationException e)
{
- // This can never happen.
+ // This can never happen.
}
}
@@ -1041,12 +1049,12 @@ public abstract class JTextComponent extends JComponent
try
{
- return doc.getText(0, doc.getLength());
+ return doc.getText(0, doc.getLength());
}
catch (BadLocationException e)
{
- // This should never happen.
- return "";
+ // This should never happen.
+ return "";
}
}
@@ -1077,12 +1085,12 @@ public abstract class JTextComponent extends JComponent
{
try
{
- return doc.getText(getSelectionStart(), getSelectionEnd());
+ return doc.getText(getSelectionStart(), getSelectionEnd());
}
catch (BadLocationException e)
{
- // This should never happen.
- return null;
+ // This should never happen.
+ return null;
}
}
@@ -1420,28 +1428,28 @@ public abstract class JTextComponent extends JComponent
// If content is empty delete selection.
if (content == null)
{
- caret.setDot(dot);
- return;
+ caret.setDot(dot);
+ return;
}
try
{
- int start = getSelectionStart();
- int end = getSelectionEnd();
-
- // Remove selected text.
- if (dot != mark)
- doc.remove(start, end - start);
-
- // Insert new text.
- doc.insertString(start, content, null);
-
- // Set dot to new position.
- setCaretPosition(start + content.length());
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
+
+ // Remove selected text.
+ if (dot != mark)
+ doc.remove(start, end - start);
+
+ // Insert new text.
+ doc.insertString(start, content, null);
+
+ // Set dot to new position.
+ setCaretPosition(start + content.length());
}
catch (BadLocationException e)
{
- // This should never happen.
+ // This should never happen.
}
}
@@ -1575,15 +1583,15 @@ public abstract class JTextComponent extends JComponent
// Install default TransferHandler if none set.
if (getTransferHandler() == null)
{
- if (defaultTransferHandler == null)
- defaultTransferHandler = new DefaultTransferHandler();
-
- setTransferHandler(defaultTransferHandler);
+ if (defaultTransferHandler == null)
+ defaultTransferHandler = new DefaultTransferHandler();
+
+ setTransferHandler(defaultTransferHandler);
}
// Perform action.
ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
- action.getValue(Action.NAME).toString());
+ action.getValue(Action.NAME).toString());
action.actionPerformed(event);
}
@@ -1667,5 +1675,20 @@ public abstract class JTextComponent extends JComponent
throws IOException
{
output.write(getText());
- }
+ }
+
+ /**
+ * Returns the tooltip text for this text component for the given mouse
+ * event. This forwards the call to
+ * {@link TextUI#getToolTipText(JTextComponent, Point)}.
+ *
+ * @param ev the mouse event
+ *
+ * @return the tooltip text for this text component for the given mouse
+ * event
+ */
+ public String getToolTipText(MouseEvent ev)
+ {
+ return getUI().getToolTipText(this, ev.getPoint());
+ }
}
diff --git a/javax/swing/text/LabelView.java b/javax/swing/text/LabelView.java
index a10391613..4890735b9 100644
--- a/javax/swing/text/LabelView.java
+++ b/javax/swing/text/LabelView.java
@@ -38,10 +38,57 @@ exception statement from your version. */
package javax.swing.text;
-// TODO: Implement this class.
-public class LabelView
- extends GlyphView
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Shape;
+
+import javax.swing.event.DocumentEvent;
+
+/**
+ * A {@link GlyphView} that caches the textattributes for most effective
+ * rendering.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class LabelView extends GlyphView
{
+
+ /**
+ * The background color.
+ */
+ Color background;
+
+ /**
+ * The foreground color.
+ */
+ Color foreground;
+
+ /**
+ * The background color.
+ */
+ Font font;
+
+ /**
+ * The strikethrough flag.
+ */
+ boolean strikeThrough;
+
+ /**
+ * The underline flag.
+ */
+ boolean underline;
+
+ /**
+ * The subscript flag.
+ */
+ boolean subscript;
+
+ /**
+ * The superscript flag.
+ */
+ boolean superscript;
+
/**
* Creates a new <code>GlyphView</code> for the given <code>Element</code>.
*
@@ -50,5 +97,194 @@ public class LabelView
public LabelView(Element element)
{
super(element);
+ setPropertiesFromAttributes();
+ }
+
+ /**
+ * Loads the properties of this label view from the element's text
+ * attributes. This method is called from the constructor and the
+ * {@link #changedUpdate} method
+ */
+ protected void setPropertiesFromAttributes()
+ {
+ Element el = getElement();
+ AttributeSet atts = el.getAttributes();
+ background = StyleConstants.getBackground(atts);
+ foreground = StyleConstants.getForeground(atts);
+ strikeThrough = StyleConstants.isStrikeThrough(atts);
+ subscript = StyleConstants.isSubscript(atts);
+ superscript = StyleConstants.isSuperscript(atts);
+ underline = StyleConstants.isUnderline(atts);
+
+ // Determine the font.
+ String family = StyleConstants.getFontFamily(atts);
+ int size = StyleConstants.getFontSize(atts);
+ int style = Font.PLAIN;
+ if (StyleConstants.isBold(atts))
+ style |= Font.BOLD;
+ if (StyleConstants.isItalic(atts))
+ style |= Font.ITALIC;
+ font = new Font(family, style, size);
+ }
+
+ /**
+ * Receives notification when text attributes change in the chunk of
+ * text that this view is responsible for. This simply calls
+ * {@link #setPropertiesFromAttributes()}.
+ *
+ * @param e the document event
+ * @param a the allocation of this view
+ * @param vf the view factory to use for creating new views
+ */
+ public void changedUpdate(DocumentEvent e, Shape a, ViewFactory vf)
+ {
+ setPropertiesFromAttributes();
+ }
+
+ /**
+ * Returns the background color for the glyphs.
+ *
+ * @return the background color for the glyphs
+ */
+ public Color getBackground()
+ {
+ return background;
+ }
+
+ /**
+ * Sets the background color for the glyphs. A value of <code>null</code>
+ * means the background of the parent view should shine through.
+ *
+ * @param bg the background to set or <code>null</code>
+ *
+ * @since 1.5
+ */
+ protected void setBackground(Color bg)
+ {
+ background = bg;
+ }
+
+ /**
+ * Returns the foreground color for the glyphs.
+ *
+ * @return the foreground color for the glyphs
+ */
+ public Color getForeground()
+ {
+ return foreground;
+ }
+
+ /**
+ * Returns the font for the glyphs.
+ *
+ * @return the font for the glyphs
+ */
+ public Font getFont()
+ {
+ return font;
+ }
+
+ /**
+ * Returns the font metrics of the current font.
+ *
+ * @return the font metrics of the current font
+ *
+ * @deprecated this is not used anymore
+ */
+ protected FontMetrics getFontMetrics()
+ {
+ return getContainer().getGraphics().getFontMetrics(font);
+ }
+
+ /**
+ * Returns <code>true</code> if the glyphs are rendered underlined,
+ * <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if the glyphs are rendered underlined,
+ * <code>false</code> otherwise
+ */
+ public boolean isUnderline()
+ {
+ return underline;
+ }
+
+ /**
+ * Sets the underline flag.
+ *
+ * @param flag <code>true</code> if the glyphs are rendered underlined,
+ * <code>false</code> otherwise
+ */
+ protected void setUnderline(boolean flag)
+ {
+ underline = flag;
+ }
+
+ /**
+ * Returns <code>true</code> if the glyphs are rendered as subscript,
+ * <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if the glyphs are rendered as subscript,
+ * <code>false</code> otherwise
+ */
+ public boolean isSubscript()
+ {
+ return subscript;
+ }
+
+ /**
+ * Sets the subscript flag.
+ *
+ * @param flag <code>true</code> if the glyphs are rendered as subscript,
+ * <code>false</code> otherwise
+ */
+ protected void setSubscript(boolean flag)
+ {
+ subscript = flag;
+ }
+
+ /**
+ * Returns <code>true</code> if the glyphs are rendered as superscript,
+ * <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if the glyphs are rendered as superscript,
+ * <code>false</code> otherwise
+ */
+ public boolean isSuperscript()
+ {
+ return superscript;
+ }
+
+ /**
+ * Sets the superscript flag.
+ *
+ * @param flag <code>true</code> if the glyphs are rendered as superscript,
+ * <code>false</code> otherwise
+ */
+ protected void setSuperscript(boolean flag)
+ {
+ superscript = flag;
+ }
+
+ /**
+ * Returns <code>true</code> if the glyphs are rendered strike-through,
+ * <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if the glyphs are rendered strike-through,
+ * <code>false</code> otherwise
+ */
+ public boolean isStrikeThrough()
+ {
+ return strikeThrough;
+ }
+
+ /**
+ * Sets the strike-through flag.
+ *
+ * @param flag <code>true</code> if the glyphs are rendered strike-through,
+ * <code>false</code> otherwise
+ */
+ protected void setStrikeThrough(boolean flag)
+ {
+ strikeThrough = flag;
}
}
diff --git a/javax/swing/text/LayoutQueue.java b/javax/swing/text/LayoutQueue.java
index 83433b6ee..b0c84b972 100644
--- a/javax/swing/text/LayoutQueue.java
+++ b/javax/swing/text/LayoutQueue.java
@@ -57,6 +57,7 @@ public class LayoutQueue
*/
public LayoutQueue()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/text/ParagraphView.java b/javax/swing/text/ParagraphView.java
index 6c6006a2a..6fb121f94 100644
--- a/javax/swing/text/ParagraphView.java
+++ b/javax/swing/text/ParagraphView.java
@@ -59,6 +59,11 @@ public class ParagraphView extends FlowView implements TabExpander
{
super(el, X_AXIS);
}
+ public float getAlignment(int axis)
+ {
+ // FIXME: This is very likely not 100% correct. Work this out.
+ return 0.0F;
+ }
}
/**
@@ -86,4 +91,29 @@ public class ParagraphView extends FlowView implements TabExpander
{
return new Row(getElement());
}
+
+ /**
+ * Returns the alignment for this paragraph view for the specified axis.
+ * For the X_AXIS the paragraph view will be aligned at it's left edge
+ * (0.0F). For the Y_AXIS the paragraph view will be aligned at the
+ * center of it's first row.
+ *
+ * @param axis the axis which is examined
+ *
+ * @return the alignment for this paragraph view for the specified axis
+ */
+ public float getAlignment(int axis)
+ {
+ if (axis == X_AXIS)
+ return 0.0F;
+ else if (getViewCount() > 0)
+ {
+
+ float prefHeight = getPreferredSpan(Y_AXIS);
+ float firstRowHeight = getView(0).getPreferredSpan(Y_AXIS);
+ return (firstRowHeight / 2.F) / prefHeight;
+ }
+ else
+ return 0.0F;
+ }
}
diff --git a/javax/swing/text/PlainDocument.java b/javax/swing/text/PlainDocument.java
index 71070e92d..9e600c4c9 100644
--- a/javax/swing/text/PlainDocument.java
+++ b/javax/swing/text/PlainDocument.java
@@ -132,8 +132,8 @@ public class PlainDocument extends AbstractDocument
// collapse elements if the removal spans more than 1 line
Element newEl = createLeafElement(rootElement,
SimpleAttributeSet.EMPTY,
- start, end - len);
- rootElement.replace(i1, i2 - i1, new Element[]{ newEl });
+ start, end);
+ rootElement.replace(i1, i2 - i1 + 1, new Element[]{ newEl });
}
}
@@ -147,4 +147,28 @@ public class PlainDocument extends AbstractDocument
Element root = getDefaultRootElement();
return root.getElement(root.getElementIndex(pos));
}
+
+ /**
+ * Inserts a string into the document. If the document property
+ * '<code>filterNewLines</code>' is set to <code>Boolean.TRUE</code>, then
+ * all newlines in the inserted string are replaced by space characters,
+ * otherwise the superclasses behaviour is executed.
+ *
+ * Inserting content causes a write lock to be acquired during this method
+ * call.
+ *
+ * @param offs the offset at which to insert the string
+ * @param str the string to be inserted
+ * @param atts the text attributes of the string to be inserted
+ *
+ * @throws BadLocationException
+ */
+ public void insertString(int offs, String str, AttributeSet atts)
+ throws BadLocationException
+ {
+ String string = str;
+ if (Boolean.TRUE.equals(getProperty("filterNewlines")))
+ string = str.replaceAll("\n", " ");
+ super.insertString(offs, string, atts);
+ }
}
diff --git a/javax/swing/text/PlainView.java b/javax/swing/text/PlainView.java
index b93d9a4f1..07351ade9 100644
--- a/javax/swing/text/PlainView.java
+++ b/javax/swing/text/PlainView.java
@@ -46,8 +46,10 @@ import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
-public class PlainView extends View
- implements TabExpander
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentEvent.ElementChange;
+
+public class PlainView extends View implements TabExpander
{
Color selectedColor;
Color unselectedColor;
@@ -59,8 +61,19 @@ public class PlainView extends View
Font font;
+ /** The length of the longest line in the Document **/
+ float maxLineLength = -1;
+
+ /** The longest line in the Document **/
+ Element longestLine = null;
+
protected FontMetrics metrics;
+ /**
+ * The instance returned by {@link #getLineBuffer()}.
+ */
+ private transient Segment lineBuffer;
+
public PlainView(Element elem)
{
super(elem);
@@ -110,7 +123,7 @@ public class PlainView extends View
// Get the rectangle for position.
Element line = getElement().getElement(lineIndex);
int lineStart = line.getStartOffset();
- Segment segment = new Segment();
+ Segment segment = getLineBuffer();
document.getText(lineStart, position - lineStart, segment);
int xoffset = Utilities.getTabbedTextWidth(segment, metrics, rect.x,
this, lineStart);
@@ -135,7 +148,9 @@ public class PlainView extends View
}
catch (BadLocationException e)
{
- // This should never happen.
+ AssertionError ae = new AssertionError("Unexpected bad location");
+ ae.initCause(e);
+ throw ae;
}
}
@@ -143,7 +158,7 @@ public class PlainView extends View
throws BadLocationException
{
g.setColor(selectedColor);
- Segment segment = new Segment();
+ Segment segment = getLineBuffer();
getDocument().getText(p0, p1 - p0, segment);
return Utilities.drawTabbedText(segment, x, y, g, this, 0);
}
@@ -157,7 +172,7 @@ public class PlainView extends View
else
g.setColor(disabledColor);
- Segment segment = new Segment();
+ Segment segment = getLineBuffer();
getDocument().getText(p0, p1 - p0, segment);
return Utilities.drawTabbedText(segment, x, y, g, this, segment.offset);
}
@@ -188,9 +203,19 @@ public class PlainView extends View
}
}
+ /**
+ * Returns the tab size of a tab. Checks the Document's
+ * properties for PlainDocument.tabSizeAttribute and returns it if it is
+ * defined, otherwise returns 8.
+ *
+ * @return the tab size.
+ */
protected int getTabSize()
{
- return 8;
+ Object tabSize = getDocument().getProperty(PlainDocument.tabSizeAttribute);
+ if (tabSize == null)
+ return 8;
+ return ((Integer)tabSize).intValue();
}
/**
@@ -203,10 +228,54 @@ public class PlainView extends View
*/
public float nextTabStop(float x, int tabStop)
{
- float tabSizePixels = getTabSize() + metrics.charWidth('m');
+ float tabSizePixels = getTabSize() * metrics.charWidth('m');
return (float) (Math.floor(x / tabSizePixels) + 1) * tabSizePixels;
}
+ /**
+ * Returns the length of the longest line, used for getting the span
+ * @return the length of the longest line
+ */
+ float determineMaxLineLength()
+ {
+ // if the longest line is cached, return the cached value
+ if (maxLineLength != -1)
+ return maxLineLength;
+
+ // otherwise we have to go through all the lines and find it
+ Element el = getElement();
+ Segment seg = getLineBuffer();
+ float span = 0;
+ for (int i = 0; i < el.getElementCount(); i++)
+ {
+ Element child = el.getElement(i);
+ int start = child.getStartOffset();
+ int end = child.getEndOffset();
+ try
+ {
+ el.getDocument().getText(start, end - start, seg);
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError ae = new AssertionError("Unexpected bad location");
+ ae.initCause(ex);
+ throw ae;
+ }
+
+ if (seg == null || seg.array == null || seg.count == 0)
+ continue;
+
+ int width = metrics.charsWidth(seg.array, seg.offset, seg.count);
+ if (width > span)
+ {
+ longestLine = child;
+ span = width;
+ }
+ }
+ maxLineLength = span;
+ return maxLineLength;
+ }
+
public float getPreferredSpan(int axis)
{
if (axis != X_AXIS && axis != Y_AXIS)
@@ -217,36 +286,16 @@ public class PlainView extends View
float span = 0;
Element el = getElement();
- Document doc = el.getDocument();
- Segment seg = new Segment();
switch (axis)
{
case X_AXIS:
- // calculate the maximum of the line's widths
- for (int i = 0; i < el.getElementCount(); i++)
- {
- Element child = el.getElement(i);
- int start = child.getStartOffset();
- int end = child.getEndOffset();
- try {
- doc.getText(start, start + end, seg);
- }
- catch (BadLocationException ex)
- {
- // throw new ClasspathAssertionError
- // ("no BadLocationException should be thrown here");
- }
- int width = metrics.charsWidth(seg.array, seg.offset, seg.count);
- span = Math.max(span, width);
- }
- break;
+ span = determineMaxLineLength();
case Y_AXIS:
default:
span = metrics.getHeight() * el.getElementCount();
break;
}
-
return span;
}
@@ -264,8 +313,221 @@ public class PlainView extends View
*/
public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
{
- // FIXME: not implemented
- return 0;
+ Rectangle rec = a.getBounds();
+ Document doc = getDocument();
+ Element root = doc.getDefaultRootElement();
+
+ // PlainView doesn't support line-wrapping so we can find out which
+ // Element was clicked on just by the y-position
+ int lineClicked = (int) (y - rec.y) / metrics.getHeight();
+ if (lineClicked >= root.getElementCount())
+ return getEndOffset() - 1;
+
+ Element line = root.getElement(lineClicked);
+ Segment s = getLineBuffer();
+
+ int start = line.getStartOffset();
+ int end = line.getEndOffset();
+ try
+ {
+ doc.getText(start, end - start, s);
+ }
+ catch (BadLocationException ble)
+ {
+ AssertionError ae = new AssertionError("Unexpected bad location");
+ ae.initCause(ble);
+ throw ae;
+ }
+
+ int pos = Utilities.getTabbedTextOffset(s, metrics, rec.x, (int)x, this, start);
+ return Math.max (0, pos);
+ }
+
+ /**
+ * Since insertUpdate and removeUpdate each deal with children
+ * Elements being both added and removed, they both have to perform
+ * the same checks. So they both simply call this method.
+ * @param changes the DocumentEvent for the changes to the Document.
+ * @param a the allocation of the View.
+ * @param f the ViewFactory to use for rebuilding.
+ */
+ protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f)
+ {
+ Element el = getElement();
+ ElementChange ec = changes.getChange(el);
+
+ // If ec is null then no lines were added or removed, just
+ // repaint the changed line
+ if (ec == null)
+ {
+ int line = getElement().getElementIndex(changes.getOffset());
+ damageLineRange(line, line, a, getContainer());
+ return;
+ }
+
+ Element[] removed = ec.getChildrenRemoved();
+ Element[] newElements = ec.getChildrenAdded();
+
+ // If no Elements were added or removed, we just want to repaint
+ // the area containing the line that was modified
+ if (removed == null && newElements == null)
+ {
+ int line = getElement().getElementIndex(changes.getOffset());
+ damageLineRange(line, line, a, getContainer());
+ return;
+ }
+
+ // Check to see if we removed the longest line, if so we have to
+ // search through all lines and find the longest one again
+ if (removed != null)
+ {
+ for (int i = 0; i < removed.length; i++)
+ if (removed[i].equals(longestLine))
+ {
+ // reset maxLineLength and search through all lines for longest one
+ maxLineLength = -1;
+ determineMaxLineLength();
+ ((JTextComponent)getContainer()).repaint();
+ return;
+ }
+ }
+
+ // If we've reached here, that means we haven't removed the longest line
+ if (newElements == null)
+ {
+ // No lines were added, just repaint the container and exit
+ ((JTextComponent)getContainer()).repaint();
+ return;
+ }
+
+ // Make sure we have the metrics
+ updateMetrics();
+
+ // If we've reached here, that means we haven't removed the longest line
+ // and we have added at least one line, so we have to check if added lines
+ // are longer than the previous longest line
+ Segment seg = getLineBuffer();
+ float longestNewLength = 0;
+ Element longestNewLine = null;
+
+ // Loop through the added lines to check their length
+ for (int i = 0; i < newElements.length; i++)
+ {
+ Element child = newElements[i];
+ int start = child.getStartOffset();
+ int end = child.getEndOffset();
+ try
+ {
+ el.getDocument().getText(start, end - start, seg);
+ }
+ catch (BadLocationException ex)
+ {
+ AssertionError ae = new AssertionError("Unexpected bad location");
+ ae.initCause(ex);
+ throw ae;
+ }
+
+ if (seg == null || seg.array == null || seg.count == 0)
+ continue;
+
+ int width = metrics.charsWidth(seg.array, seg.offset, seg.count);
+ if (width > longestNewLength)
+ {
+ longestNewLine = child;
+ longestNewLength = width;
+ }
+ }
+
+ // Check if the longest of the new lines is longer than our previous
+ // longest line, and if so update our values
+ if (longestNewLength > maxLineLength)
+ {
+ maxLineLength = longestNewLength;
+ longestLine = longestNewLine;
+ }
+ // Repaint the container
+ ((JTextComponent)getContainer()).repaint();
+ }
+
+ /**
+ * This method is called when something is inserted into the Document
+ * that this View is displaying.
+ *
+ * @param changes the DocumentEvent for the changes.
+ * @param a the allocation of the View
+ * @param f the ViewFactory used to rebuild
+ */
+ public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f)
+ {
+ updateDamage(changes, a, f);
+ }
+
+ /**
+ * This method is called when something is removed from the Document
+ * that this View is displaying.
+ *
+ * @param changes the DocumentEvent for the changes.
+ * @param a the allocation of the View
+ * @param f the ViewFactory used to rebuild
+ */
+ public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f)
+ {
+ updateDamage(changes, a, f);
+ }
+
+ /**
+ * This method is called when attributes were changed in the
+ * Document in a location that this view is responsible for.
+ */
+ public void changedUpdate (DocumentEvent changes, Shape a, ViewFactory f)
+ {
+ updateDamage(changes, a, f);
+ }
+
+ /**
+ * Repaint the given line range. This is called from insertUpdate,
+ * changedUpdate, and removeUpdate when no new lines were added
+ * and no lines were removed, to repaint the line that was
+ * modified.
+ *
+ * @param line0 the start of the range
+ * @param line1 the end of the range
+ * @param a the rendering region of the host
+ * @param host the Component that uses this View (used to call repaint
+ * on that Component)
+ *
+ * @since 1.4
+ */
+ protected void damageLineRange (int line0, int line1, Shape a, Component host)
+ {
+ if (a == null)
+ return;
+
+ Rectangle rec0 = lineToRect(a, line0);
+ Rectangle rec1 = lineToRect(a, line1);
+
+ if (rec0 == null || rec1 == null)
+ // something went wrong, repaint the entire host to be safe
+ host.repaint();
+ else
+ {
+ Rectangle repaintRec = rec0.union(rec1);
+ host.repaint();
+ }
+ }
+
+ /**
+ * Provides a {@link Segment} object, that can be used to fetch text from
+ * the document.
+ *
+ * @returna {@link Segment} object, that can be used to fetch text from
+ * the document
+ */
+ protected Segment getLineBuffer()
+ {
+ if (lineBuffer == null)
+ lineBuffer = new Segment();
+ return lineBuffer;
}
}
diff --git a/javax/swing/text/Segment.java b/javax/swing/text/Segment.java
index 92d850016..84e0e700f 100644
--- a/javax/swing/text/Segment.java
+++ b/javax/swing/text/Segment.java
@@ -39,8 +39,7 @@ package javax.swing.text;
import java.text.CharacterIterator;
-public class Segment
- implements Cloneable, CharacterIterator
+public class Segment implements Cloneable, CharacterIterator
{
private boolean partialReturn;
private int current;
@@ -51,6 +50,7 @@ public class Segment
public Segment()
{
+ // Nothing to do here.
}
public Segment(char[] array, int offset, int count)
diff --git a/javax/swing/text/SimpleAttributeSet.java b/javax/swing/text/SimpleAttributeSet.java
index 61cf5e97c..0c9f607b1 100644
--- a/javax/swing/text/SimpleAttributeSet.java
+++ b/javax/swing/text/SimpleAttributeSet.java
@@ -87,8 +87,30 @@ public class SimpleAttributeSet
return s;
}
+ /**
+ * Returns true if the given name and value represent an attribute
+ * found either in this AttributeSet or in its resolve parent hierarchy.
+ * @param name the key for the attribute
+ * @param value the value for the attribute
+ * @return true if the attribute is found here or in this set's resolve
+ * parent hierarchy
+ */
public boolean containsAttribute(Object name, Object value)
{
+ return (tab.containsKey(name) && tab.get(name).equals(value)) ||
+ (getResolveParent() != null && getResolveParent().
+ containsAttribute(name, value));
+ }
+
+ /**
+ * Returns true if the given name and value are found in this AttributeSet.
+ * Does not check the resolve parent.
+ * @param name the key for the attribute
+ * @param value the value for the attribute
+ * @return true if the attribute is found in this AttributeSet
+ */
+ boolean containsAttributeLocally(Object name, Object value)
+ {
return tab.containsKey(name)
&& tab.get(name).equals(value);
}
@@ -160,11 +182,15 @@ public class SimpleAttributeSet
{
return tab.isEmpty();
}
-
+
+ /**
+ * Returns true if the given set has the same number of attributes
+ * as this set and <code>containsAttributes(attr)</code> returns
+ * true.
+ */
public boolean isEqual(AttributeSet attr)
{
- return attr != null
- && attr.containsAttributes(this)
+ return getAttributeCount() == attr.getAttributeCount()
&& this.containsAttributes(attr);
}
@@ -173,9 +199,21 @@ public class SimpleAttributeSet
tab.remove(name);
}
+ /**
+ * Removes attributes from this set if they are found in the
+ * given set. Only attributes whose key AND value are removed.
+ * Removes attributes only from this set, not from the resolving parent.
+ */
public void removeAttributes(AttributeSet attributes)
{
- removeAttributes(attributes.getAttributeNames());
+ Enumeration e = attributes.getAttributeNames();
+ while (e.hasMoreElements())
+ {
+ Object name = e.nextElement();
+ Object val = attributes.getAttribute(name);
+ if (containsAttributeLocally(name, val))
+ removeAttribute(name);
+ }
}
public void removeAttributes(Enumeration names)
diff --git a/javax/swing/text/StyleContext.java b/javax/swing/text/StyleContext.java
index fba15f6fd..d73f430b0 100644
--- a/javax/swing/text/StyleContext.java
+++ b/javax/swing/text/StyleContext.java
@@ -306,9 +306,14 @@ public class StyleContext
return attrs[i+1];
}
- Object p = getResolveParent();
- if (p != null && p instanceof AttributeSet)
- return (((AttributeSet)p).getAttribute(key));
+ // Check the resolve parent, unless we're looking for the
+ // ResolveAttribute, which would cause an infinite loop
+ if (!(key.equals(ResolveAttribute)))
+ {
+ Object p = getResolveParent();
+ if (p != null && p instanceof AttributeSet)
+ return (((AttributeSet)p).getAttribute(key));
+ }
return null;
}
diff --git a/javax/swing/text/StyledDocument.java b/javax/swing/text/StyledDocument.java
index ea277540f..168e1b116 100644
--- a/javax/swing/text/StyledDocument.java
+++ b/javax/swing/text/StyledDocument.java
@@ -45,101 +45,96 @@ import java.awt.Font;
* @author Andrew Selkirk
* @version 1.0
*/
-public interface StyledDocument extends Document {
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * addStyle
- * @param nm TODO
- * @param rent TODO
- * @returns Style
- */
- Style addStyle(String nm, Style parent);
-
- /**
- * removeStyle
- * @param nm TODO
- */
- void removeStyle(String nm);
-
- /**
- * getStyle
- * @param nm TODO
- * @returns Style
- */
- Style getStyle(String nm);
-
- /**
- * setCharacterAttributes
- * @param offset TODO
- * @param length TODO
- * @param set TODO
- * @param replace TODO
- */
- void setCharacterAttributes(int offset, int length,
- AttributeSet set, boolean replace);
-
- /**
- * setParagraphAttributes
- * @param offset TODO
- * @param length TODO
- * @param set TODO
- * @param replace TODO
- */
- void setParagraphAttributes(int offset, int length,
- AttributeSet set, boolean replace);
-
- /**
- * getLogicalStyle
- * @param position TODO
- * @returns Style
- */
- Style getLogicalStyle(int position);
-
- /**
- * setLogicalStyle
- * @param position TODO
- * @param style TODO
- */
- void setLogicalStyle(int position, Style style);
-
- /**
- * getParagraphElement
- * @param position TODO
- * @returns Element
- */
- Element getParagraphElement(int position);
-
- /**
- * getCharacterElement
- * @param position TODO
- * @returns Element
- */
- Element getCharacterElement(int position);
-
- /**
- * getForeground
- * @param set TODO
- * @returns Color
- */
- Color getForeground(AttributeSet set);
-
- /**
- * getBackground
- * @param set TODO
- * @returns Color
- */
- Color getBackground(AttributeSet set);
-
- /**
- * getFont
- * @param set TODO
- * @returns Font
- */
- Font getFont(AttributeSet set);
-
-
-} // StyledDocument
+public interface StyledDocument extends Document
+{
+ /**
+ * addStyle
+ * @param nm TODO
+ * @param parent TODO
+ * @returns Style
+ */
+ Style addStyle(String nm, Style parent);
+
+ /**
+ * removeStyle
+ * @param nm TODO
+ */
+ void removeStyle(String nm);
+
+ /**
+ * getStyle
+ * @param nm TODO
+ * @returns Style
+ */
+ Style getStyle(String nm);
+
+ /**
+ * setCharacterAttributes
+ * @param offset TODO
+ * @param length TODO
+ * @param set TODO
+ * @param replace TODO
+ */
+ void setCharacterAttributes(int offset, int length, AttributeSet set,
+ boolean replace);
+
+ /**
+ * setParagraphAttributes
+ * @param offset TODO
+ * @param length TODO
+ * @param set TODO
+ * @param replace TODO
+ */
+ void setParagraphAttributes(int offset, int length, AttributeSet set,
+ boolean replace);
+
+ /**
+ * getLogicalStyle
+ * @param position TODO
+ * @returns Style
+ */
+ Style getLogicalStyle(int position);
+
+ /**
+ * setLogicalStyle
+ * @param position TODO
+ * @param style TODO
+ */
+ void setLogicalStyle(int position, Style style);
+
+ /**
+ * getParagraphElement
+ * @param position TODO
+ * @returns Element
+ */
+ Element getParagraphElement(int position);
+
+ /**
+ * getCharacterElement
+ * @param position TODO
+ * @returns Element
+ */
+ Element getCharacterElement(int position);
+
+ /**
+ * getForeground
+ * @param set TODO
+ * @returns Color
+ */
+ Color getForeground(AttributeSet set);
+
+ /**
+ * getBackground
+ * @param set TODO
+ * @returns Color
+ */
+ Color getBackground(AttributeSet set);
+
+ /**
+ * getFont
+ * @param set TODO
+ * @returns Font
+ */
+ Font getFont(AttributeSet set);
+
+}
diff --git a/javax/swing/text/Utilities.java b/javax/swing/text/Utilities.java
index 02d98c3b2..cdbe9f98e 100644
--- a/javax/swing/text/Utilities.java
+++ b/javax/swing/text/Utilities.java
@@ -40,6 +40,7 @@ package javax.swing.text;
import java.awt.FontMetrics;
import java.awt.Graphics;
+import java.text.BreakIterator;
/**
* A set of utilities to deal with text. This is used by several other classes
@@ -231,10 +232,17 @@ public class Utilities
// At the end of the for loop, this holds the requested model location
int pos;
int currentX = x0;
- for (pos = p0; pos < s.getEndIndex(); pos++)
+
+ for (pos = p0; pos < s.count; pos++)
{
- char nextChar = s.array[pos];
- if (nextChar != '\n')
+ char nextChar = s.array[s.offset+pos];
+ if (nextChar == 0)
+ {
+ if (! round)
+ pos--;
+ break;
+ }
+ if (nextChar != '\t')
currentX += fm.charWidth(nextChar);
else
{
@@ -243,7 +251,7 @@ public class Utilities
else
currentX = (int) te.nextTabStop(currentX, pos);
}
- if (currentX >= x)
+ if (currentX > x)
{
if (! round)
pos--;
@@ -280,4 +288,238 @@ public class Utilities
{
return getTabbedTextOffset(s, fm, x0, x, te, p0, true);
}
+
+ /**
+ * Finds the start of the next word for the given offset.
+ *
+ * @param c
+ * the text component
+ * @param offs
+ * the offset in the document
+ * @return the location in the model of the start of the next word.
+ * @throws BadLocationException
+ * if the offset is invalid.
+ */
+ public static final int getNextWord(JTextComponent c, int offs)
+ throws BadLocationException
+ {
+ if (offs < 0 || offs > (c.getText().length() - 1))
+ throw new BadLocationException("invalid offset specified", offs);
+ String text = c.getText();
+ BreakIterator wb = BreakIterator.getWordInstance();
+ wb.setText(text);
+ int last = wb.following(offs);
+ int current = wb.next();
+ while (current != BreakIterator.DONE)
+ {
+ for (int i = last; i < current; i++)
+ {
+ // FIXME: Should use isLetter(int) and text.codePointAt(int)
+ // instead, but isLetter(int) isn't implemented yet
+ if (Character.isLetter(text.charAt(i)))
+ return last;
+ }
+ last = current;
+ current = wb.next();
+ }
+ return BreakIterator.DONE;
+ }
+
+ /**
+ * Finds the start of the previous word for the given offset.
+ *
+ * @param c
+ * the text component
+ * @param offs
+ * the offset in the document
+ * @return the location in the model of the start of the previous word.
+ * @throws BadLocationException
+ * if the offset is invalid.
+ */
+ public static final int getPreviousWord(JTextComponent c, int offs)
+ throws BadLocationException
+ {
+ if (offs < 0 || offs > (c.getText().length() - 1))
+ throw new BadLocationException("invalid offset specified", offs);
+ String text = c.getText();
+ BreakIterator wb = BreakIterator.getWordInstance();
+ wb.setText(text);
+ int last = wb.preceding(offs);
+ int current = wb.previous();
+
+ while (current != BreakIterator.DONE)
+ {
+ for (int i = last; i < offs; i++)
+ {
+ // FIXME: Should use isLetter(int) and text.codePointAt(int)
+ // instead, but isLetter(int) isn't implemented yet
+ if (Character.isLetter(text.charAt(i)))
+ return last;
+ }
+ last = current;
+ current = wb.previous();
+ }
+ return 0;
+ }
+
+ /**
+ * Finds the start of a word for the given location.
+ * @param c the text component
+ * @param offs the offset location
+ * @return the location of the word beginning
+ * @throws BadLocationException if the offset location is invalid
+ */
+ public static final int getWordStart(JTextComponent c, int offs)
+ throws BadLocationException
+ {
+ if (offs < 0 || offs >= c.getText().length())
+ throw new BadLocationException("invalid offset specified", offs);
+
+ String text = c.getText();
+ BreakIterator wb = BreakIterator.getWordInstance();
+ wb.setText(text);
+ if (wb.isBoundary(offs))
+ return offs;
+ return wb.preceding(offs);
+ }
+
+ /**
+ * Finds the end of a word for the given location.
+ * @param c the text component
+ * @param offs the offset location
+ * @return the location of the word end
+ * @throws BadLocationException if the offset location is invalid
+ */
+ public static final int getWordEnd(JTextComponent c, int offs)
+ throws BadLocationException
+ {
+ if (offs < 0 || offs >= c.getText().length())
+ throw new BadLocationException("invalid offset specified", offs);
+
+ String text = c.getText();
+ BreakIterator wb = BreakIterator.getWordInstance();
+ wb.setText(text);
+ return wb.following(offs);
+ }
+
+ /**
+ * Get the model position of the end of the row that contains the
+ * specified model position. Return null if the given JTextComponent
+ * does not have a size.
+ * @param c the JTextComponent
+ * @param offs the model position
+ * @return the model position of the end of the row containing the given
+ * offset
+ * @throws BadLocationException if the offset is invalid
+ */
+ public static final int getRowEnd(JTextComponent c, int offs)
+ throws BadLocationException
+ {
+ String text = c.getText();
+ if (text == null)
+ return -1;
+
+ // Do a binary search for the smallest position X > offs
+ // such that that character at positino X is not on the same
+ // line as the character at position offs
+ int high = offs + ((text.length() - 1 - offs) / 2);
+ int low = offs;
+ int oldHigh = text.length() + 1;
+ while (true)
+ {
+ if (c.modelToView(high).y != c.modelToView(offs).y)
+ {
+ oldHigh = high;
+ high = low + ((high + 1 - low) / 2);
+ if (oldHigh == high)
+ return high - 1;
+ }
+ else
+ {
+ low = high;
+ high += ((oldHigh - high) / 2);
+ if (low == high)
+ return low;
+ }
+ }
+ }
+
+ /**
+ * Get the model position of the start of the row that contains the specified
+ * model position. Return null if the given JTextComponent does not have a
+ * size.
+ *
+ * @param c the JTextComponent
+ * @param offs the model position
+ * @return the model position of the start of the row containing the given
+ * offset
+ * @throws BadLocationException if the offset is invalid
+ */
+ public static final int getRowStart(JTextComponent c, int offs)
+ throws BadLocationException
+ {
+ String text = c.getText();
+ if (text == null)
+ return -1;
+
+ // Do a binary search for the greatest position X < offs
+ // such that the character at position X is not on the same
+ // row as the character at position offs
+ int high = offs;
+ int low = 0;
+ int oldLow = 0;
+ while (true)
+ {
+ if (c.modelToView(low).y != c.modelToView(offs).y)
+ {
+ oldLow = low;
+ low = high - ((high + 1 - low) / 2);
+ if (oldLow == low)
+ return low + 1;
+ }
+ else
+ {
+ high = low;
+ low -= ((low - oldLow) / 2);
+ if (low == high)
+ return low;
+ }
+ }
+ }
+
+ /**
+ * Determine where to break the text in the given Segment, attempting to find
+ * a word boundary.
+ * @param s the Segment that holds the text
+ * @param metrics the font metrics used for calculating the break point
+ * @param x0 starting view location representing the start of the text
+ * @param x the target view location
+ * @param e the TabExpander used for expanding tabs (if this is null tabs
+ * are expanded to 1 space)
+ * @param startOffset the offset in the Document of the start of the text
+ * @return the offset at which we should break the text
+ */
+ public static final int getBreakLocation(Segment s, FontMetrics metrics,
+ int x0, int x, TabExpander e,
+ int startOffset)
+ {
+ int mark = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset);
+ BreakIterator breaker = BreakIterator.getWordInstance();
+ breaker.setText(s.toString());
+
+ // If mark is equal to the end of the string, just use that position
+ if (mark == s.count)
+ return mark;
+
+ // Try to find a word boundary previous to the mark at which we
+ // can break the text
+ int preceding = breaker.preceding(mark + 1);
+
+ if (preceding != 0)
+ return preceding;
+ else
+ // If preceding is 0 we couldn't find a suitable word-boundary so
+ // just break it on the character boundary
+ return mark;
+ }
}
diff --git a/javax/swing/text/View.java b/javax/swing/text/View.java
index 9cea4ecb0..7b3039cfb 100644
--- a/javax/swing/text/View.java
+++ b/javax/swing/text/View.java
@@ -86,9 +86,9 @@ public abstract class View implements SwingConstants
{
View parent = getParent();
if (parent == null)
- throw new AssertionError("The parent of a View must not be null.");
-
- return parent.getContainer();
+ return null;
+ else
+ return parent.getContainer();
}
public Document getDocument()
@@ -507,6 +507,30 @@ public abstract class View implements SwingConstants
}
/**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * This method is deprecated and calls
+ * {@link #modelToView(int, Position.Bias, int, Position.Bias, Shape)} with
+ * a bias of {@link Position.Bias#Forward}.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ *
+ * @deprecated Use {@link #modelToView(int, Shape, Position.Bias)} instead.
+ */
+ public Shape modelToView(int pos, Shape a) throws BadLocationException
+ {
+ return modelToView(pos, a, Position.Bias.Forward);
+ }
+
+ /**
* Maps coordinates from the <code>View</code>'s space into a position
* in the document model.
*
@@ -520,6 +544,25 @@ public abstract class View implements SwingConstants
*/
public abstract int viewToModel(float x, float y, Shape a, Position.Bias[] b);
+ /**
+ * Maps coordinates from the <code>View</code>'s space into a position
+ * in the document model. This method is deprecated and only there for
+ * compatibility.
+ *
+ * @param x the x coordinate in the view space
+ * @param y the y coordinate in the view space
+ * @param a the allocation of this <code>View</code>
+ *
+ * @return the position in the document that corresponds to the screen
+ * coordinates <code>x, y</code>
+ *
+ * @deprecated Use {@link #viewToModel(float, float, Shape, Position.Bias[])}
+ * instead.
+ */
+ public int viewToModel(float x, float y, Shape a)
+ {
+ return viewToModel(x, y, a, new Position.Bias[0]);
+ }
/**
* Dumps the complete View hierarchy. This method can be used for debugging
diff --git a/javax/swing/text/WrappedPlainView.java b/javax/swing/text/WrappedPlainView.java
new file mode 100644
index 000000000..02200d254
--- /dev/null
+++ b/javax/swing/text/WrappedPlainView.java
@@ -0,0 +1,547 @@
+/* WrappedPlainView.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.Shape;
+
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.Position.Bias;
+
+/**
+ * @author abalkiss
+ *
+ */
+public class WrappedPlainView extends BoxView implements TabExpander
+{
+ /** The color for selected text **/
+ Color selectedColor;
+
+ /** The color for unselected text **/
+ Color unselectedColor;
+
+ /** The color for disabled components **/
+ Color disabledColor;
+
+ /** Stores the font metrics **/
+ protected FontMetrics metrics;
+
+ /** Whether or not to wrap on word boundaries **/
+ boolean wordWrap;
+
+ /** A ViewFactory that creates WrappedLines **/
+ ViewFactory viewFactory = new WrappedLineCreator();
+
+ /**
+ * The instance returned by {@link #getLineBuffer()}.
+ */
+ private transient Segment lineBuffer;
+
+ public WrappedPlainView (Element elem)
+ {
+ this (elem, false);
+ }
+
+ public WrappedPlainView (Element elem, boolean wordWrap)
+ {
+ super (elem, Y_AXIS);
+ this.wordWrap = wordWrap;
+ }
+
+ /**
+ * Provides access to the Segment used for retrievals from the Document.
+ * @return the Segment.
+ */
+ protected final Segment getLineBuffer()
+ {
+ if (lineBuffer == null)
+ lineBuffer = new Segment();
+ return lineBuffer;
+ }
+
+ /**
+ * Returns the next tab stop position after a given reference position.
+ *
+ * This implementation ignores the <code>tabStop</code> argument.
+ *
+ * @param x the current x position in pixels
+ * @param tabStop the position within the text stream that the tab occured at
+ */
+ public float nextTabStop(float x, int tabStop)
+ {
+ JTextComponent host = (JTextComponent)getContainer();
+ float tabSizePixels = getTabSize()
+ * host.getFontMetrics(host.getFont()).charWidth('m');
+ return (float) (Math.floor(x / tabSizePixels) + 1) * tabSizePixels;
+ }
+
+ /**
+ * Returns the tab size for the Document based on
+ * PlainDocument.tabSizeAttribute, defaulting to 8 if this property is
+ * not defined
+ *
+ * @return the tab size.
+ */
+ protected int getTabSize()
+ {
+ Object tabSize = getDocument().getProperty(PlainDocument.tabSizeAttribute);
+ if (tabSize == null)
+ return 8;
+ return ((Integer)tabSize).intValue();
+ }
+
+ /**
+ * Draws a line of text, suppressing white space at the end and expanding
+ * tabs. Calls drawSelectedText and drawUnselectedText.
+ * @param p0 starting document position to use
+ * @param p1 ending document position to use
+ * @param g graphics context
+ * @param x starting x position
+ * @param y starting y position
+ */
+ protected void drawLine(int p0, int p1, Graphics g, int x, int y)
+ {
+ try
+ {
+ drawUnselectedText(g, x, y, p0, p1);
+ }
+ catch (BadLocationException ble)
+ {
+ // shouldn't happen
+ }
+ }
+
+ /**
+ * Renders the range of text as selected text. Just paints the text
+ * in the color specified by the host component. Assumes the highlighter
+ * will render the selected background.
+ * @param g the graphics context
+ * @param x the starting X coordinate
+ * @param y the starting Y coordinate
+ * @param p0 the starting model location
+ * @param p1 the ending model location
+ * @return the X coordinate of the end of the text
+ * @throws BadLocationException if the given range is invalid
+ */
+ protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1)
+ throws BadLocationException
+ {
+ g.setColor(selectedColor);
+ Segment segment = getLineBuffer();
+ getDocument().getText(p0, p1 - p0, segment);
+ return Utilities.drawTabbedText(segment, x, y, g, this, 0);
+ }
+
+ /**
+ * Renders the range of text as normal unhighlighted text.
+ * @param g the graphics context
+ * @param x the starting X coordinate
+ * @param y the starting Y coordinate
+ * @param p0 the starting model location
+ * @param p1 the end model location
+ * @return the X location of the end off the range
+ * @throws BadLocationException if the range given is invalid
+ */
+ protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1)
+ throws BadLocationException
+ {
+ JTextComponent textComponent = (JTextComponent) getContainer();
+ if (textComponent.isEnabled())
+ g.setColor(unselectedColor);
+ else
+ g.setColor(disabledColor);
+
+ Segment segment = getLineBuffer();
+ getDocument().getText(p0, p1 - p0, segment);
+ return Utilities.drawTabbedText(segment, x, y, g, this, segment.offset);
+ }
+
+ /**
+ * Loads the children to initiate the view. Called by setParent.
+ * Creates a WrappedLine for each child Element.
+ */
+ protected void loadChildren (ViewFactory f)
+ {
+ Element root = getElement();
+ int numChildren = root.getElementCount();
+ if (numChildren == 0)
+ return;
+
+ View[] children = new View[numChildren];
+ for (int i = 0; i < numChildren; i++)
+ children[i] = new WrappedLine(root.getElement(i));
+ replace(0, 0, children);
+ }
+
+ /**
+ * Calculates the break position for the text between model positions
+ * p0 and p1. Will break on word boundaries or character boundaries
+ * depending on the break argument given in construction of this
+ * WrappedPlainView. Used by the nested WrappedLine class to determine
+ * when to start the next logical line.
+ * @param p0 the start model position
+ * @param p1 the end model position
+ * @return the model position at which to break the text
+ */
+ protected int calculateBreakPosition(int p0, int p1)
+ {
+ Container c = getContainer();
+ Rectangle alloc = c.getBounds();
+ updateMetrics();
+ try
+ {
+ getDocument().getText(p0, p1 - p0, getLineBuffer());
+ }
+ catch (BadLocationException ble)
+ {
+ // this shouldn't happen
+ }
+ // FIXME: Should we account for the insets of the container?
+ if (wordWrap)
+ return p0
+ + Utilities.getBreakLocation(lineBuffer, metrics, alloc.x,
+ alloc.x + alloc.width, this, 0);
+ else
+ {
+ return p0
+ + Utilities.getTabbedTextOffset(lineBuffer, metrics, alloc.x,
+ alloc.x + alloc.width, this, 0);
+ }
+ }
+
+ void updateMetrics()
+ {
+ Container component = getContainer();
+ metrics = component.getFontMetrics(component.getFont());
+ }
+
+ /**
+ * Determines the preferred span along the given axis. Implemented to
+ * cache the font metrics and then call the super classes method.
+ */
+ public float getPreferredSpan (int axis)
+ {
+ updateMetrics();
+ return super.getPreferredSpan(axis);
+ }
+
+ /**
+ * Called when something was inserted. Overridden so that
+ * the view factory creates WrappedLine views.
+ */
+ public void insertUpdate (DocumentEvent e, Shape a, ViewFactory f)
+ {
+ super.insertUpdate(e, a, viewFactory);
+ // FIXME: could improve performance by repainting only the necessary area
+ getContainer().repaint();
+ }
+
+ /**
+ * Called when something is removed. Overridden so that
+ * the view factory creates WrappedLine views.
+ */
+ public void removeUpdate (DocumentEvent e, Shape a, ViewFactory f)
+ {
+ super.removeUpdate(e, a, viewFactory);
+ // FIXME: could improve performance by repainting only the necessary area
+ getContainer().repaint();
+ }
+
+ /**
+ * Called when the portion of the Document that this View is responsible
+ * for changes. Overridden so that the view factory creates
+ * WrappedLine views.
+ */
+ public void changedUpdate (DocumentEvent e, Shape a, ViewFactory f)
+ {
+ super.changedUpdate(e, a, viewFactory);
+ // FIXME: could improve performance by repainting only the necessary area
+ getContainer().repaint();
+ }
+
+ class WrappedLineCreator implements ViewFactory
+ {
+ // Creates a new WrappedLine
+ public View create(Element elem)
+ {
+ return new WrappedLine(elem);
+ }
+ }
+
+ /**
+ * Renders the <code>Element</code> that is associated with this
+ * <code>View</code>. Caches the metrics and then calls
+ * super.paint to paint all the child views.
+ *
+ * @param g the <code>Graphics</code> context to render to
+ * @param a the allocated region for the <code>Element</code>
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ updateMetrics();
+ super.paint(g, a);
+ }
+
+ /**
+ * Sets the size of the View. Implemented to update the metrics
+ * and then call super method.
+ */
+ public void setSize (float width, float height)
+ {
+ updateMetrics();
+ super.setSize(width, height);
+ }
+
+ class WrappedLine extends View
+ {
+ /** Used to cache the number of lines for this View **/
+ int numLines;
+
+ public WrappedLine(Element elem)
+ {
+ super(elem);
+ determineNumLines();
+ }
+
+ /**
+ * Renders this (possibly wrapped) line using the given Graphics object
+ * and on the given rendering surface.
+ */
+ public void paint(Graphics g, Shape s)
+ {
+ // Ensure metrics are up-to-date.
+ updateMetrics();
+ JTextComponent textComponent = (JTextComponent) getContainer();
+
+ g.setFont(textComponent.getFont());
+ selectedColor = textComponent.getSelectedTextColor();
+ unselectedColor = textComponent.getForeground();
+ disabledColor = textComponent.getDisabledTextColor();
+
+ Rectangle rect = s.getBounds();
+ int lineHeight = metrics.getHeight();
+
+ int end = getEndOffset();
+ int currStart = getStartOffset();
+ int currEnd;
+ while (currStart < end)
+ {
+ currEnd = calculateBreakPosition(currStart, end);
+ drawLine(currStart, currEnd, g, rect.x, rect.y);
+ rect.y += lineHeight;
+ if (currEnd == currStart)
+ currStart ++;
+ else
+ currStart = currEnd;
+ }
+ }
+
+ /**
+ * Determines the number of logical lines that the Element
+ * needs to be displayed
+ * @return the number of lines needed to display the Element
+ */
+ int determineNumLines()
+ {
+ int end = getEndOffset();
+ if (end == 0)
+ return 0;
+
+ numLines = 0;
+ int breakPoint;
+ for (int i = getStartOffset(); i < end;)
+ {
+ numLines ++;
+ // careful: check that there's no off-by-one problem here
+ // depending on which position calculateBreakPosition returns
+ breakPoint = calculateBreakPosition(i, end);
+ if (breakPoint == i)
+ i ++;
+ else
+ i = breakPoint;
+ }
+ return numLines;
+ }
+
+ /**
+ * Determines the preferred span for this view along the given axis.
+ *
+ * @param axis the axis (either X_AXIS or Y_AXIS)
+ *
+ * @return the preferred span along the given axis.
+ * @throws IllegalArgumentException if axis is not X_AXIS or Y_AXIS
+ */
+ public float getPreferredSpan(int axis)
+ {
+ if (axis == X_AXIS)
+ return getWidth();
+ else if (axis == Y_AXIS)
+ return numLines * metrics.getHeight();
+
+ throw new IllegalArgumentException("Invalid axis for getPreferredSpan: "
+ + axis);
+ }
+
+ /**
+ * Provides a mapping from model space to view space.
+ *
+ * @param pos the position in the model
+ * @param a the region into which the view is rendered
+ * @param b the position bias (forward or backward)
+ *
+ * @return a box in view space that represents the given position
+ * in model space
+ * @throws BadLocationException if the given model position is invalid
+ */
+ public Shape modelToView(int pos, Shape a, Bias b) throws BadLocationException
+ {
+ Segment s = getLineBuffer();
+ int lineHeight = metrics.getHeight();
+ Rectangle rect = a.getBounds();
+
+ // Return a rectangle with width 1 and height equal to the height
+ // of the text
+ rect.height = lineHeight;
+ rect.width = 1;
+
+ int currLineStart = getStartOffset();
+ int end = getEndOffset();
+
+ if (pos < currLineStart || pos >= end)
+ throw new BadLocationException("invalid offset", pos);
+
+ while (true)
+ {
+ int currLineEnd = calculateBreakPosition(currLineStart, end);
+ // If pos is between currLineStart and currLineEnd then just find
+ // the width of the text from currLineStart to pos and add that
+ // to rect.x
+ if (pos >= currLineStart && pos < currLineEnd || pos == end - 1)
+ {
+ try
+ {
+ getDocument().getText(currLineStart, pos - currLineStart, s);
+ }
+ catch (BadLocationException ble)
+ {
+ // Shouldn't happen
+ }
+ rect.x += Utilities.getTabbedTextWidth(s, metrics, rect.x, WrappedPlainView.this, currLineStart);
+ return rect;
+ }
+ // Increment rect.y so we're checking the next logical line
+ rect.y += lineHeight;
+
+ // Increment currLineStart to the model position of the start
+ // of the next logical line
+ if (currLineEnd == currLineStart)
+ currLineStart = end;
+ else
+ currLineStart = currLineEnd;
+ }
+
+ }
+
+ /**
+ * Provides a mapping from view space to model space.
+ *
+ * @param x the x coordinate in view space
+ * @param y the y coordinate in view space
+ * @param a the region into which the view is rendered
+ * @param b the position bias (forward or backward)
+ *
+ * @return the location in the model that best represents the
+ * given point in view space
+ */
+ public int viewToModel(float x, float y, Shape a, Bias[] b)
+ {
+ Segment s = getLineBuffer();
+ Rectangle rect = a.getBounds();
+ int currLineStart = getStartOffset();
+ int end = getEndOffset();
+ int lineHeight = metrics.getHeight();
+ if (y < rect.y)
+ return currLineStart;
+ if (y > rect.y + rect.height)
+ return end - 1;
+
+ while (true)
+ {
+ int currLineEnd = calculateBreakPosition(currLineStart, end);
+ // If we're at the right y-position that means we're on the right
+ // logical line and we should look for the character
+ if (y >= rect.y && y < rect.y + lineHeight)
+ {
+ // Check if the x position is to the left or right of the text
+ if (x < rect.x)
+ return currLineStart;
+ if (x > rect.x + rect.width)
+ return currLineEnd - 1;
+
+ try
+ {
+ getDocument().getText(currLineStart, end - currLineStart, s);
+ }
+ catch (BadLocationException ble)
+ {
+ // Shouldn't happen
+ }
+ int mark = Utilities.getTabbedTextOffset(s, metrics, rect.x,
+ (int) x,
+ WrappedPlainView.this,
+ currLineStart);
+ return currLineStart + mark;
+ }
+ // Increment rect.y so we're checking the next logical line
+ rect.y += lineHeight;
+
+ // Increment currLineStart to the model position of the start
+ // of the next logical line
+ if (currLineEnd == currLineStart)
+ currLineStart = end;
+ else
+ currLineStart = currLineEnd;
+ }
+ }
+ }
+}
diff --git a/javax/swing/text/html/CSS.java b/javax/swing/text/html/CSS.java
index f02ceb89b..029ad26f8 100644
--- a/javax/swing/text/html/CSS.java
+++ b/javax/swing/text/html/CSS.java
@@ -34,8 +34,11 @@ or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing.text.html;
+import java.util.HashMap;
+
/**
* Provides CSS attributes to be used by the HTML view classes. The constants
* defined here are used as keys for text attributes for use in
@@ -45,6 +48,30 @@ package javax.swing.text.html;
*/
public class CSS
{
+ /**
+ * Returns an array of all CSS attributes.
+ *
+ * @return All available CSS.Attribute objects.
+ */
+ public static CSS.Attribute[] getAllAttributeKeys()
+ {
+ Object[] src = Attribute.attributeMap.values().toArray();
+ CSS.Attribute[] dst = new CSS.Attribute[ src.length ];
+ System.arraycopy(src, 0, dst, 0, src.length);
+ return dst;
+ }
+
+ /**
+ * Returns an a given CSS attribute.
+ *
+ * @param name - The name of the attribute.
+ * @return The CSS attribute with the given name, or <code>null</code> if
+ * no attribute with that name exists.
+ */
+ public static CSS.Attribute getAttribute(String name)
+ {
+ return (CSS.Attribute)Attribute.attributeMap.get( name );
+ }
public static final class Attribute
{
@@ -377,6 +404,11 @@ public class CSS
String defaultValue;
/**
+ * A HashMap of all attributes.
+ */
+ static HashMap attributeMap;
+
+ /**
* Creates a new Attribute instance with the specified values.
*
* @param attr the attribute string
@@ -388,6 +420,9 @@ public class CSS
attStr = attr;
isInherited = inherited;
defaultValue = def;
+ if( attributeMap == null)
+ attributeMap = new HashMap();
+ attributeMap.put( attr, this );
}
/**
diff --git a/javax/swing/text/html/HTML.java b/javax/swing/text/html/HTML.java
index fa458ef45..09bf553b5 100644
--- a/javax/swing/text/html/HTML.java
+++ b/javax/swing/text/html/HTML.java
@@ -945,22 +945,22 @@ public class HTML
* This tag is not included into the array, returned by getAllTags().
* toString() returns 'comment'. HTML reader synthesizes this tag.
*/
- public static final Tag COMMENT = new Tag("comment", SYNTETIC);
+ public static final Tag COMMENT = new Tag("comment", SYNTHETIC);
/**
* All text content is labeled with this tag.
* This tag is not included into the array, returned by getAllTags().
* toString() returns 'content'. HTML reader synthesizes this tag.
*/
- public static final Tag CONTENT = new Tag("content", SYNTETIC);
+ public static final Tag CONTENT = new Tag("content", SYNTHETIC);
/**
* All text content must be in a paragraph element.
* If a paragraph didn't exist when content was encountered,
* a paragraph is manufactured.
- * toString() returns 'implied'. HTML reader synthesizes this tag.
+ * toString() returns 'p-implied'. HTML reader synthesizes this tag.
*/
- public static final Tag IMPLIED = new Tag("implied", SYNTETIC);
+ public static final Tag IMPLIED = new Tag("p-implied", SYNTHETIC);
final String name;
final int flags;
@@ -1144,7 +1144,7 @@ public class HTML
*/
boolean isSyntetic()
{
- return (flags & SYNTETIC) != 0;
+ return (flags & SYNTHETIC) != 0;
}
private static void unexpected(Exception ex)
@@ -1185,7 +1185,7 @@ public class HTML
static final int BREAKS = 1;
static final int BLOCK = 2;
static final int PREFORMATTED = 4;
- static final int SYNTETIC = 8;
+ static final int SYNTHETIC = 8;
private static Map<String,Tag> tagMap;
private static Map<String,Attribute> attrMap;
@@ -1196,6 +1196,7 @@ public class HTML
*/
public HTML()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/text/html/HTMLDocument.java b/javax/swing/text/html/HTMLDocument.java
index a95e496ec..d048a04e6 100644
--- a/javax/swing/text/html/HTMLDocument.java
+++ b/javax/swing/text/html/HTMLDocument.java
@@ -38,7 +38,14 @@ exception statement from your version. */
package javax.swing.text.html;
+import java.net.URL;
+
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.AttributeSet;
import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.Element;
+import javax.swing.text.ElementIterator;
+import javax.swing.text.html.HTML.Tag;
/**
* TODO: This class is not yet completetely implemented.
@@ -47,7 +54,215 @@ import javax.swing.text.DefaultStyledDocument;
*/
public class HTMLDocument extends DefaultStyledDocument
{
+ /** A key for document properies. The value for the key is
+ * a Vector of Strings of comments not found in the body.
+ */
+ public static final String AdditionalComments = "AdditionalComments";
+ URL baseURL = null;
+ boolean preservesUnknownTags = true;
+
+ /**
+ * Returns the location against which to resolve relative URLs.
+ * This is the document's URL if the document was loaded from a URL.
+ * If a <code>base</code> tag is found, it will be used.
+ * @return the base URL
+ */
+ public URL getBase()
+ {
+ return baseURL;
+ }
+
+ /**
+ * Sets the location against which to resolve relative URLs.
+ * @param u the new base URL
+ */
+ public void setBase(URL u)
+ {
+ baseURL = u;
+ //TODO: also set the base of the StyleSheet
+ }
+
+ /**
+ * Returns whether or not the parser preserves unknown HTML tags.
+ * @return true if the parser preserves unknown tags
+ */
+ public boolean getPreservesUnknownTags()
+ {
+ return preservesUnknownTags;
+ }
+
+ /**
+ * Sets the behaviour of the parser when it encounters unknown HTML tags.
+ * @param preservesTags true if the parser should preserve unknown tags.
+ */
+ public void setPreservesUnknownTags(boolean preservesTags)
+ {
+ preservesUnknownTags = preservesTags;
+ }
+
+ /**
+ * An iterator to iterate through LeafElements in the document.
+ */
+ class LeafIterator extends Iterator
+ {
+ HTML.Tag tag;
+ HTMLDocument doc;
+ ElementIterator it;
+
+ public LeafIterator (HTML.Tag t, HTMLDocument d)
+ {
+ doc = d;
+ tag = t;
+ it = new ElementIterator(doc);
+ }
+
+ /**
+ * Return the attributes for the tag associated with this iteartor
+ * @return the AttributeSet
+ */
+ public AttributeSet getAttributes()
+ {
+ if (it.current() != null)
+ return it.current().getAttributes();
+ return null;
+ }
+
+ /**
+ * Get the end of the range for the current occurrence of the tag
+ * being defined and having the same attributes.
+ * @return the end of the range
+ */
+ public int getEndOffset()
+ {
+ if (it.current() != null)
+ return it.current().getEndOffset();
+ return -1;
+ }
+
+ /**
+ * Get the start of the range for the current occurrence of the tag
+ * being defined and having the same attributes.
+ * @return the start of the range (-1 if it can't be found).
+ */
+
+ public int getStartOffset()
+ {
+ if (it.current() != null)
+ return it.current().getStartOffset();
+ return -1;
+ }
+
+ /**
+ * Advance the iterator to the next LeafElement .
+ */
+ public void next()
+ {
+ it.next();
+ while (it.current()!= null && !it.current().isLeaf())
+ it.next();
+ }
+
+ /**
+ * Indicates whether or not the iterator currently represents an occurrence
+ * of the tag.
+ * @return true if the iterator currently represents an occurrence of the
+ * tag.
+ */
+ public boolean isValid()
+ {
+ return it.current() != null;
+ }
+
+ /**
+ * Type of tag for this iterator.
+ */
+ public Tag getTag()
+ {
+ return tag;
+ }
+
+ }
+
public void processHTMLFrameHyperlinkEvent(HTMLFrameHyperlinkEvent event)
{
+ // TODO: Implement this properly.
+ }
+
+ /**
+ * Gets an iterator for the given HTML.Tag.
+ * @param t the requested HTML.Tag
+ * @return the Iterator
+ */
+ public HTMLDocument.Iterator getIterator (HTML.Tag t)
+ {
+ return new HTMLDocument.LeafIterator(t, this);
+ }
+
+ /**
+ * An iterator over a particular type of tag.
+ */
+ public abstract static class Iterator
+ {
+ /**
+ * Return the attribute set for this tag.
+ * @return the <code>AttributeSet</code> (null if none found).
+ */
+ public abstract AttributeSet getAttributes();
+
+ /**
+ * Get the end of the range for the current occurrence of the tag
+ * being defined and having the same attributes.
+ * @return the end of the range
+ */
+ public abstract int getEndOffset();
+
+ /**
+ * Get the start of the range for the current occurrence of the tag
+ * being defined and having the same attributes.
+ * @return the start of the range (-1 if it can't be found).
+ */
+ public abstract int getStartOffset();
+
+ /**
+ * Move the iterator forward.
+ */
+ public abstract void next();
+
+ /**
+ * Indicates whether or not the iterator currently represents an occurrence
+ * of the tag.
+ * @return true if the iterator currently represents an occurrence of the
+ * tag.
+ */
+ public abstract boolean isValid();
+
+ /**
+ * Type of tag this iterator represents.
+ * @return the tag.
+ */
+ public abstract HTML.Tag getTag();
+ }
+
+ public class BlockElement extends AbstractDocument.BranchElement
+ {
+ public BlockElement (Element parent, AttributeSet a)
+ {
+ super (parent, a);
+ }
+
+ /**
+ * Gets the resolving parent. Since HTML attributes are not
+ * inherited at the model level, this returns null.
+ */
+ public AttributeSet getResolveParent()
+ {
+ return null;
+ }
+
+ public String getName()
+ {
+ //FIXME: this is supposed to do something different from the super class
+ return super.getName();
+ }
}
}
diff --git a/javax/swing/text/html/HTMLEditorKit.java b/javax/swing/text/html/HTMLEditorKit.java
index c0182fe6a..a52d96c74 100644
--- a/javax/swing/text/html/HTMLEditorKit.java
+++ b/javax/swing/text/html/HTMLEditorKit.java
@@ -43,8 +43,10 @@ import java.io.Reader;
import java.io.Serializable;
import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.StyledEditorKit;
+import javax.swing.text.html.parser.ParserDelegator;
/**
* This class is NOT implemented. This file currently holds only
@@ -96,9 +98,9 @@ public class HTMLEditorKit
/**
* The parser calls this method after it finishes parsing the document.
*/
- public void flush()
- throws BadLocationException
+ public void flush() throws BadLocationException
{
+ // TODO: What to do here, if anything?
}
/**
@@ -108,6 +110,7 @@ public class HTMLEditorKit
*/
public void handleComment(char[] comment, int position)
{
+ // TODO: What to do here, if anything?
}
/**
@@ -118,6 +121,7 @@ public class HTMLEditorKit
*/
public void handleEndOfLineString(String end_of_line)
{
+ // TODO: What to do here, if anything?
}
/**
@@ -129,6 +133,7 @@ public class HTMLEditorKit
*/
public void handleEndTag(HTML.Tag tag, int position)
{
+ // TODO: What to do here, if anything?
}
/**
@@ -139,6 +144,7 @@ public class HTMLEditorKit
*/
public void handleError(String message, int position)
{
+ // TODO: What to do here, if anything?
}
/**
@@ -149,9 +155,9 @@ public class HTMLEditorKit
* @param position The tag position in the text being parsed.
*/
public void handleSimpleTag(HTML.Tag tag, MutableAttributeSet attributes,
- int position
- )
+ int position)
{
+ // TODO: What to do here, if anything?
}
/**
@@ -165,6 +171,7 @@ public class HTMLEditorKit
int position
)
{
+ // TODO: What to do here, if anything?
}
/**
@@ -174,6 +181,7 @@ public class HTMLEditorKit
*/
public void handleText(char[] text, int position)
{
+ // TODO: What to do here, if anything?
}
}
@@ -247,4 +255,26 @@ public class HTMLEditorKit
* The "ident paragraph right" action.
*/
public static final String PARA_INDENT_RIGHT = "html-para-indent-right";
-} \ No newline at end of file
+
+ /**
+ * Create a text storage model for this type of editor.
+ *
+ * @return the model
+ */
+ public Document createDefaultDocument()
+ {
+ HTMLDocument document = new HTMLDocument();
+ return document;
+ }
+
+ /**
+ * Get the parser that this editor kit uses for reading HTML streams. This
+ * method can be overridden to use the alternative parser.
+ *
+ * @return the HTML parser (by default, {@link ParserDelegator}).
+ */
+ protected Parser getParser()
+ {
+ return new ParserDelegator();
+ }
+}
diff --git a/javax/swing/text/html/HTMLFrameHyperlinkEvent.java b/javax/swing/text/html/HTMLFrameHyperlinkEvent.java
index dc0ab10a8..e146965d7 100644
--- a/javax/swing/text/html/HTMLFrameHyperlinkEvent.java
+++ b/javax/swing/text/html/HTMLFrameHyperlinkEvent.java
@@ -41,7 +41,6 @@ package javax.swing.text.html;
import java.net.URL;
import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.text.Element;
/**
@@ -50,8 +49,7 @@ import javax.swing.text.Element;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class HTMLFrameHyperlinkEvent
- extends HyperlinkEvent
+public class HTMLFrameHyperlinkEvent extends HyperlinkEvent
{
private final String target_frame;
diff --git a/javax/swing/text/html/parser/ContentModel.java b/javax/swing/text/html/parser/ContentModel.java
index deb7b1602..70e9c2acb 100644
--- a/javax/swing/text/html/parser/ContentModel.java
+++ b/javax/swing/text/html/parser/ContentModel.java
@@ -95,9 +95,12 @@ public final class ContentModel
*/
public int type;
- /** Create a content model initializing all fields to default values. */
+ /**
+ * Create a content model initializing all fields to default values.
+ */
public ContentModel()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/text/html/parser/DTD.java b/javax/swing/text/html/parser/DTD.java
index 42bf2e570..6e7aeb407 100644
--- a/javax/swing/text/html/parser/DTD.java
+++ b/javax/swing/text/html/parser/DTD.java
@@ -592,8 +592,7 @@ public class DTD
* @param name the name of the entity
* @param type the type of the entity, a bitwise combination
* of GENERAL, PARAMETER, SYSTEM and PUBLIC.
- * @throws an error if the parameter is both GENERAL and PARAMETER
- * of both PUBLIC and SYSTEM.
+ *
* @return the created entity
*/
private Entity newEntity(String name, int type)
diff --git a/javax/swing/text/html/parser/DocumentParser.java b/javax/swing/text/html/parser/DocumentParser.java
index 164297f18..062606d17 100644
--- a/javax/swing/text/html/parser/DocumentParser.java
+++ b/javax/swing/text/html/parser/DocumentParser.java
@@ -168,6 +168,7 @@ public class DocumentParser
* specific packages, write your own DTD or obtain the working instance
* of parser in other way, for example, by calling
* {@link javax.swing.text.html.HTMLEditorKit#getParser()}.
+ *
* @param a_dtd a DTD to use.
*/
public DocumentParser(DTD a_dtd)
@@ -212,6 +213,7 @@ public class DocumentParser
*/
protected void handleComment(char[] comment)
{
+ // This default implementation does nothing.
}
/**
@@ -224,6 +226,7 @@ public class DocumentParser
protected void handleEmptyTag(TagElement tag)
throws javax.swing.text.ChangedCharSetException
{
+ // This default implementation does nothing.
}
/**
@@ -234,11 +237,13 @@ public class DocumentParser
*/
protected void handleEndTag(TagElement tag)
{
+ // This default implementation does nothing.
}
/* Handle error that has occured in the given line. */
protected void handleError(int line, String message)
{
+ // This default implementation does nothing.
}
/**
@@ -249,6 +254,7 @@ public class DocumentParser
*/
protected void handleStartTag(TagElement tag)
{
+ // This default implementation does nothing.
}
/**
@@ -257,5 +263,6 @@ public class DocumentParser
*/
protected void handleText(char[] text)
{
+ // This default implementation does nothing.
}
}
diff --git a/javax/swing/text/html/parser/Element.java b/javax/swing/text/html/parser/Element.java
index 098983c69..c07c07f54 100644
--- a/javax/swing/text/html/parser/Element.java
+++ b/javax/swing/text/html/parser/Element.java
@@ -148,10 +148,10 @@ public final class Element
/**
* The default constructor must have package level access in this
* class. Use DTD.defineElement(..) to create an element when required.
- * @todo MAKE THIS PACKAGE in the final version. Now the Parser needs it!
*/
Element()
{
+ // Nothing to do here.
}
/**
diff --git a/javax/swing/text/html/parser/Parser.java b/javax/swing/text/html/parser/Parser.java
index 7ff6853da..a88e9ce19 100644
--- a/javax/swing/text/html/parser/Parser.java
+++ b/javax/swing/text/html/parser/Parser.java
@@ -256,6 +256,7 @@ public class Parser
*/
protected void endTag(boolean omitted)
{
+ // This default implementation does nothing.
}
/**
@@ -310,6 +311,7 @@ public class Parser
*/
protected void handleComment(char[] comment)
{
+ // This default implementation does nothing.
}
/**
@@ -333,6 +335,7 @@ public class Parser
protected void handleEmptyTag(TagElement tag)
throws ChangedCharSetException
{
+ // This default implementation does nothing.
}
/**
@@ -343,11 +346,13 @@ public class Parser
*/
protected void handleEndTag(TagElement tag)
{
+ // This default implementation does nothing.
}
/* Handle error that has occured in the given line. */
protected void handleError(int line, String message)
{
+ // This default implementation does nothing.
}
/**
@@ -358,6 +363,7 @@ public class Parser
*/
protected void handleStartTag(TagElement tag)
{
+ // This default implementation does nothing.
}
/**
@@ -376,6 +382,7 @@ public class Parser
*/
protected void handleText(char[] text)
{
+ // This default implementation does nothing.
}
/**
@@ -387,6 +394,7 @@ public class Parser
*/
protected void handleTitle(char[] title)
{
+ // This default implementation does nothing.
}
/**
@@ -420,6 +428,7 @@ public class Parser
*/
protected void markFirstTime(Element element)
{
+ // This default implementation does nothing.
}
/**
@@ -432,5 +441,6 @@ public class Parser
protected void startTag(TagElement tag)
throws ChangedCharSetException
{
+ // This default implementation does nothing.
}
}
diff --git a/javax/swing/tree/DefaultMutableTreeNode.java b/javax/swing/tree/DefaultMutableTreeNode.java
index 4a7da7d82..d767e8b88 100644
--- a/javax/swing/tree/DefaultMutableTreeNode.java
+++ b/javax/swing/tree/DefaultMutableTreeNode.java
@@ -45,7 +45,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.NoSuchElementException;
diff --git a/javax/swing/tree/DefaultTreeCellEditor.java b/javax/swing/tree/DefaultTreeCellEditor.java
index 91096ad19..2891a778e 100644
--- a/javax/swing/tree/DefaultTreeCellEditor.java
+++ b/javax/swing/tree/DefaultTreeCellEditor.java
@@ -47,7 +47,6 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
-import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
@@ -56,12 +55,8 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.EventObject;
-import javax.swing.CellRendererPane;
import javax.swing.DefaultCellEditor;
import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
@@ -354,9 +349,9 @@ public class DefaultTreeCellEditor
/**
* Configures the editing component whenever it is null.
*
- * @param tree- the tree to configure to component for.
- * @param renderer- the renderer used to set up the nodes
- * @param editor- the editor used
+ * @param tree the tree to configure to component for.
+ * @param renderer the renderer used to set up the nodes
+ * @param editor the editor used
*/
private void configureEditingComponent(JTree tree,
DefaultTreeCellRenderer renderer,
@@ -607,7 +602,7 @@ public class DefaultTreeCellEditor
/**
* Messaged when the timer fires, this will start the editing session.
*
- * @param @param e - the event that characterizes the action.
+ * @param e the event that characterizes the action.
*/
public void actionPerformed(ActionEvent e)
{
diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index 609592a73..b6205c5db 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/javax/swing/tree/DefaultTreeModel.java
@@ -299,6 +299,7 @@ public class DefaultTreeModel
public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent,
int index)
{
+ newChild.setParent(parent);
parent.insert(newChild, index);
int[] childIndices = new int[1];
childIndices[0] = index;
diff --git a/javax/swing/tree/TreeCellRenderer.java b/javax/swing/tree/TreeCellRenderer.java
index ebbe3fa91..a1808c9ee 100644
--- a/javax/swing/tree/TreeCellRenderer.java
+++ b/javax/swing/tree/TreeCellRenderer.java
@@ -46,22 +46,24 @@ import javax.swing.JTree;
* TreeCellRenderer public interface
* @author Andrew Selkirk
*/
-public interface TreeCellRenderer {
+public interface TreeCellRenderer
+{
- /**
- * getTreeCellRendererComponent
- * @param tree TODO
- * @param value TODO
- * @param selected TODO
- * @param expanded TODO
- * @param leaf TODO
- * @param row TODO
- * @param us TODO
- * @returns TODO
- */
- Component getTreeCellRendererComponent(JTree tree,
- Object value, boolean selected, boolean expanded,
- boolean leaf, int row, boolean hasFocus);
+ /**
+ * getTreeCellRendererComponent
+ * @param tree TODO
+ * @param value TODO
+ * @param selected TODO
+ * @param expanded TODO
+ * @param leaf TODO
+ * @param row TODO
+ * @param hasFocus TODO
+ * @returns TODO
+ */
+ Component getTreeCellRendererComponent(JTree tree, Object value,
+ boolean selected, boolean expanded,
+ boolean leaf, int row,
+ boolean hasFocus);
-} // TreeCellRenderer
+}
diff --git a/javax/swing/tree/TreeModel.java b/javax/swing/tree/TreeModel.java
index 759aaac58..ec1884efd 100644
--- a/javax/swing/tree/TreeModel.java
+++ b/javax/swing/tree/TreeModel.java
@@ -44,66 +44,62 @@ import javax.swing.event.TreeModelListener;
* TreeModel public interface
* @author Andrew Selkirk
*/
-public interface TreeModel {
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * getRoot
- * @returns Object
- */
- Object getRoot();
-
- /**
- * getChild
- * @param parent TODO
- * @param index TODO
- * @returns Object
- */
- Object getChild(Object parent, int index);
-
- /**
- * getChildCount
- * @param parent TODO
- * @returns int
- */
- int getChildCount(Object parent);
-
- /**
- * isLeaf
- * @param node TODO
- * @returns boolean
- */
- boolean isLeaf(Object node);
-
- /**
- * valueForPathChanged
- * @param path TODO
- * @param newvalue TODO
- */
- void valueForPathChanged(TreePath path, Object newvalue);
-
- /**
- * getIndexOfChild
- * @param parent TODO
- * @param ild TODO
- * @returns int
- */
- int getIndexOfChild(Object parent, Object child);
-
- /**
- * addTreeModelListener
- * @param listener TODO
- */
- void addTreeModelListener(TreeModelListener listener);
-
- /**
- * removeTreeModelListener
- * @param listener TODO
- */
- void removeTreeModelListener(TreeModelListener listener);
-
-
-} // TreeModel
+public interface TreeModel
+{
+ /**
+ * getRoot
+ * @returns Object
+ */
+ Object getRoot();
+
+ /**
+ * getChild
+ * @param parent TODO
+ * @param index TODO
+ * @returns Object
+ */
+ Object getChild(Object parent, int index);
+
+ /**
+ * getChildCount
+ * @param parent TODO
+ * @returns int
+ */
+ int getChildCount(Object parent);
+
+ /**
+ * isLeaf
+ * @param node TODO
+ * @returns boolean
+ */
+ boolean isLeaf(Object node);
+
+ /**
+ * valueForPathChanged
+ * @param path TODO
+ * @param newvalue TODO
+ */
+ void valueForPathChanged(TreePath path, Object newvalue);
+
+ /**
+ * getIndexOfChild
+ * @param parent TODO
+ * @param child TODO
+ * @returns int
+ */
+ int getIndexOfChild(Object parent, Object child);
+
+ /**
+ * addTreeModelListener
+ * @param listener TODO
+ */
+ void addTreeModelListener(TreeModelListener listener);
+
+ /**
+ * removeTreeModelListener
+ * @param listener TODO
+ */
+ void removeTreeModelListener(TreeModelListener listener);
+
+
+}
diff --git a/javax/swing/undo/CannotRedoException.java b/javax/swing/undo/CannotRedoException.java
index 7d70a38c2..5f2264835 100644
--- a/javax/swing/undo/CannotRedoException.java
+++ b/javax/swing/undo/CannotRedoException.java
@@ -44,13 +44,13 @@ package javax.swing.undo;
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
*/
-public class CannotRedoException
- extends RuntimeException
+public class CannotRedoException extends RuntimeException
{
/**
* Constructs a new instance of a <code>CannotRedoException</code>.
*/
public CannotRedoException()
{
+ super();
}
}
diff --git a/javax/swing/undo/CannotUndoException.java b/javax/swing/undo/CannotUndoException.java
index 9fc0ec3bd..8d08cda68 100644
--- a/javax/swing/undo/CannotUndoException.java
+++ b/javax/swing/undo/CannotUndoException.java
@@ -53,5 +53,6 @@ public class CannotUndoException
*/
public CannotUndoException()
{
+ super();
}
}
diff --git a/javax/xml/namespace/QName.java b/javax/xml/namespace/QName.java
index 7b8b194c3..19700b32e 100644
--- a/javax/xml/namespace/QName.java
+++ b/javax/xml/namespace/QName.java
@@ -1,5 +1,5 @@
/* QName.java - An XML qualified name.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.xml.namespace;
+import java.io.Serializable;
+
import javax.xml.XMLConstants;
/**
@@ -47,14 +49,15 @@ import javax.xml.XMLConstants;
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
* @since 1.3
*/
-public class QName
+public class QName implements Serializable
{
+ private static final long serialVersionUID = 4418622981026545151L;
private final String namespaceURI;
private final String localPart;
private final String prefix;
- private final String qName;
- int hashCode = -1;
+ private transient String qName;
+ transient int hashCode = -1;
public QName(String namespaceURI, String localPart)
{
@@ -78,21 +81,6 @@ public class QName
this.namespaceURI = namespaceURI;
this.localPart = localPart;
this.prefix = prefix;
-
- StringBuffer buf = new StringBuffer();
- if (namespaceURI.length() > 0)
- {
- buf.append('{');
- buf.append(namespaceURI);
- buf.append('}');
- }
- if (prefix.length() > 0)
- {
- buf.append(prefix);
- buf.append(':');
- }
- buf.append(localPart);
- qName = buf.toString();
}
public QName(String localPart)
@@ -115,7 +103,7 @@ public class QName
return prefix;
}
- public boolean equals(Object obj)
+ public final boolean equals(Object obj)
{
if (obj instanceof QName)
{
@@ -129,19 +117,29 @@ public class QName
public final int hashCode()
{
if (hashCode == -1)
- {
- StringBuffer buf = new StringBuffer();
- buf.append('{');
- buf.append(namespaceURI);
- buf.append('}');
- buf.append(localPart);
- hashCode = buf.toString().hashCode();
- }
+ hashCode = localPart.hashCode() ^ namespaceURI.hashCode();
return hashCode;
}
- public String toString()
+ public synchronized String toString()
{
+ if (qName == null)
+ {
+ StringBuffer buf = new StringBuffer();
+ if (namespaceURI.length() > 0)
+ {
+ buf.append('{');
+ buf.append(namespaceURI);
+ buf.append('}');
+ }
+ if (prefix.length() > 0)
+ {
+ buf.append(prefix);
+ buf.append(':');
+ }
+ buf.append(localPart);
+ qName = buf.toString();
+ }
return qName;
}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 765e0e236..8326d97c8 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -44,7 +44,7 @@ JAVAH = $(USER_JAVAH) -jni -classpath .:$(USER_CLASSLIB)
if INSTALL_GLIBJ_ZIP
-pkgdata_DATA = glibj.zip
+glibj_DATA = glibj.zip
endif # INSTALL_GLIBJ_ZIP
@@ -77,7 +77,7 @@ endif # INSTALL_CLASS_FILES
glibj.zip: classes compile-classes resources
if test "$(ZIP)" != ""; then $(ZIP) -r -D glibj.zip gnu java javax org META-INF > /dev/null; fi
-resources:
+resources: copy-vmresources.sh
if ! [ -e gnu ]; then mkdir gnu; fi
if ! [ -e gnu/java ]; then mkdir gnu/java; fi
if ! [ -e gnu/java/locale ]; then mkdir gnu/java/locale; fi
@@ -91,6 +91,7 @@ resources:
@list='$(metafiles)'; for p in $$list; do \
cp $(top_srcdir)/resource/$$p $$p; \
done
+ @$(SHELL) ./copy-vmresources.sh
@list='$(iconfiles)'; for p in $$list; do \
cp $(top_srcdir)/$$p $$p; \
done
@@ -149,6 +150,7 @@ clean-local:
-rm -rf java
-rm -rf javax
-rm -rf org
+ -rm -rf com
-rm -rf META-INF
-rm -rf lists
-rm -f Makefile.deps
diff --git a/lib/copy-vmresources.sh.in b/lib/copy-vmresources.sh.in
new file mode 100644
index 000000000..f51247693
--- /dev/null
+++ b/lib/copy-vmresources.sh.in
@@ -0,0 +1,40 @@
+#! @SHELL@
+# @configure_input@
+
+vmdirs=`echo "@vm_classes@" | sed 's%:% %g'`
+destMetaDir=`pwd`/META-INF
+destResDir=`pwd`
+
+for p in ${vmdirs}; do
+ if test -d $p/META-INF; then
+ (cd $p/META-INF;
+ dirs=`find -name "CVS" -prune -o -type d -print`;
+ for u in ${dirs}; do
+ mkdir -p ${destMetaDir}/${u};
+ done;
+ files=`find -name "CVS" -prune -o -type f -print`;
+ for u in ${files}; do
+ cp ${u} ${destMetaDir}/${u};
+ done
+ );
+ fi;
+
+ (cd ${p};
+ resfiles=`find ${p} -name "*.properties"`
+ resdirs=
+ for i in ${resfiles}; do
+ a=`basename ${i}`;
+ b=`echo ${i} | sed "s%${a}%%g"`;
+ resdirs="${resdirs} ${b}";
+ done;
+ resnewdirs=`echo ${resdirs} | uniq`;
+
+ for u in ${resnewdirs}; do
+ mkdir -p ${destResDir}/${u};
+ done
+
+ for f in ${resfiles}; do
+ echo ${f} ${destResDir}/${f};
+ done
+ )
+done
diff --git a/lib/gen-classlist.sh.in b/lib/gen-classlist.sh.in
index b22deced4..2f2dfc8a8 100755
--- a/lib/gen-classlist.sh.in
+++ b/lib/gen-classlist.sh.in
@@ -24,7 +24,7 @@ vm_dirlist=`echo "@vm_classes@" | sed -e 's/:/ /g'`
echo "Adding java source files from VM directory $vm_dirlist"
for dir in $vm_dirlist; do
(cd $dir
- for subdir in java javax gnu org; do
+ for subdir in java javax gnu org com; do
if test -d $subdir; then
@FIND@ $subdir -name '*.java' -print
fi
diff --git a/lib/split-for-gcj.sh b/lib/split-for-gcj.sh
index 0f5ffaff2..f69b79797 100755
--- a/lib/split-for-gcj.sh
+++ b/lib/split-for-gcj.sh
@@ -31,7 +31,7 @@ test -d lists || mkdir lists
for dir in java javax gnu org; do
fgrep /$dir/ classes | while read file; do
pkg=`echo "$file " | sed -n -e "s,^.*/\($dir/.*\)/[^/]*$,\1,p"`
- list=lists/`echo $pkg | sed -e 's,/,-,g'`
+ list=lists/`echo $pkg | sed -e 's,/,-,g' | cut -f1-3 -d-`
echo "$file" >> ${list}.list.1
f2=`echo "$file" | sed -n -e "s,^.*/\($dir/.*\)$,\1,p"`
f2=`echo "$f2" | sed -e 's/.java$//'`.class
diff --git a/m4/acattribute.m4 b/m4/acattribute.m4
new file mode 100644
index 000000000..7b490d4b7
--- /dev/null
+++ b/m4/acattribute.m4
@@ -0,0 +1,25 @@
+dnl modified AC_C_INLINE from autoconf/c.m4
+
+AN_IDENTIFIER([attribute], [AC_C_ATTRIBUTE])
+AC_DEFUN([AC_C_ATTRIBUTE],
+[AC_CACHE_CHECK([for __attribute__], ac_cv_c_attribute,
+[
+AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+[void foo(void) __attribute__ ((__noreturn__));]
+)],
+[ac_cv_c_attribute=yes],
+[ac_cv_c_attribute=no]
+)
+])
+AH_VERBATIM([attribute],
+[/* Define to `__attribute__' to nothing if it's not supported. */
+#undef __attribute__])
+case $ac_cv_c_attribute in
+ yes) ;;
+ no)
+ cat >>confdefs.h <<_ACEOF
+#define __attribute__(x) /* nothing */
+_ACEOF
+ ;;
+esac
+])# AC_C_ATTRIBUTE
diff --git a/native/fdlibm/java-assert.h b/native/fdlibm/java-assert.h
index 6f178bd9e..ad512ad13 100644
--- a/native/fdlibm/java-assert.h
+++ b/native/fdlibm/java-assert.h
@@ -1,4 +1,4 @@
-// java-assert.h - Header file holding assertion definitions. -*- c++ -*-
+/* java-assert.h - Header file holding assertion definitions. -*- c++ -*- */
/* Copyright (C) 1998, 1999 Free Software Foundation
@@ -11,7 +11,9 @@ details. */
#ifndef __JAVA_ASSERT_H__
#define __JAVA_ASSERT_H__
-// This is a libgcj implementation header.
+#include <config.h>
+
+/* This is a libgcj implementation header. */
void _Jv_Abort (const char *, const char *, int, const char *)
__attribute__ ((__noreturn__));
diff --git a/native/jawt/Makefile.am b/native/jawt/Makefile.am
index 9caa03d47..6c5c871b8 100644
--- a/native/jawt/Makefile.am
+++ b/native/jawt/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libjawtgnu.la
+nativelib_LTLIBRARIES = libjawtgnu.la
libjawtgnu_la_SOURCES = jawt.c
libjawtgnu_la_LIBADD = $(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
diff --git a/native/jni/Makefile.am b/native/jni/Makefile.am
index fce6b1a6f..64cd35a51 100644
--- a/native/jni/Makefile.am
+++ b/native/jni/Makefile.am
@@ -4,6 +4,14 @@ if CREATE_CORE_JNI_LIBRARIES
JNIDIRS = java-io java-lang java-net java-nio java-util
endif
+if CREATE_ALSA_LIBRARIES
+ ALSADIR = midi-alsa
+endif
+
+if CREATE_DSSI_LIBRARIES
+ DSSIDIR = midi-dssi
+endif
+
if CREATE_GTK_PEER_LIBRARIES
GTKDIR = gtk-peer
endif
@@ -16,9 +24,10 @@ if CREATE_XMLJ_LIBRARY
XMLJDIR = xmlj
endif
-SUBDIRS = classpath $(JNIDIRS) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR)
+SUBDIRS = classpath $(JNIDIRS) \
+ $(ALSADIR) $(DSSIDIR) $(GTKDIR) $(CLASSPATH_QT_PEER_DIR) $(XMLJDIR)
DIST_SUBDIRS = classpath java-io java-lang java-net java-nio java-util \
- gtk-peer qt-peer xmlj
+ gtk-peer qt-peer xmlj midi-alsa midi-dssi
all-local:
cd $(top_srcdir) && $(SHELL) ./scripts/check_jni_methods.sh
diff --git a/native/jni/classpath/Makefile.am b/native/jni/classpath/Makefile.am
index 2baa60abc..a26ab832b 100644
--- a/native/jni/classpath/Makefile.am
+++ b/native/jni/classpath/Makefile.am
@@ -5,7 +5,6 @@ noinst_LTLIBRARIES = libclasspath.la
libclasspath_la_SOURCES = jcl.c jcl.h \
jnilink.c jnilink.h \
- primlib.c primlib.h \
native_state.c native_state.h
AM_LDFLAGS = @CLASSPATH_MODULE@
diff --git a/native/jni/classpath/primlib.c b/native/jni/classpath/primlib.c
deleted file mode 100644
index e6773ba53..000000000
--- a/native/jni/classpath/primlib.c
+++ /dev/null
@@ -1,724 +0,0 @@
-/* primlib.c
- 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-#include <jnilink.h>
-#include <primlib.h>
-#include <jcl.h>
-
-static jclass nativeWrapClass[PRIMLIB_NUMTYPES] =
- { NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL
-};
-
-static jclass nativeTypeClass[PRIMLIB_NUMTYPES] =
- { NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL
-};
-
-static jmethodID nativeWrapClassConstructor[PRIMLIB_NUMTYPES] =
- { NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL
-};
-
-static jmethodID nativeWrapClassAccessor[PRIMLIB_NUMTYPES] =
- { NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL
-};
-
-static const char *nativeWrapClassName[PRIMLIB_NUMTYPES] = {
- NULL,
- NULL,
- "java/lang/Boolean",
- "java/lang/Byte",
- "java/lang/Character",
- "java/lang/Short",
- "java/lang/Integer",
- "java/lang/Long",
- "java/lang/Float",
- "java/lang/Double",
- "java/lang/Void",
- NULL
-};
-
-static const char *nativeWrapClassConstructorSig[PRIMLIB_NUMTYPES] = {
- NULL,
- NULL,
- "(Z)V",
- "(B)V",
- "(C)V",
- "(S)V",
- "(I)V",
- "(J)V",
- "(F)V",
- "(D)V",
- "()V",
- NULL
-};
-
-static const char *nativeWrapClassAccessorName[PRIMLIB_NUMTYPES] = {
- NULL,
- NULL,
- "booleanValue",
- "byteValue",
- "charValue",
- "shortValue",
- "intValue",
- "longValue",
- "floatValue",
- "doubleValue",
- NULL,
- NULL
-};
-
-static const char *nativeWrapClassAccessorSig[PRIMLIB_NUMTYPES] = {
- NULL,
- NULL,
- "()Z",
- "()B",
- "()C",
- "()S",
- "()I",
- "()J",
- "()F",
- "()D",
- NULL,
- NULL
-};
-
-
-JNIEXPORT jclass JNICALL
-PRIMLIB_GetNativeWrapClass (JNIEnv * env, int reflectType)
-{
- return LINK_LinkClass (env, nativeWrapClass[reflectType],
- nativeWrapClassName[reflectType]);
-}
-
-static jclass
-ActuallyGetNativeTypeClass (JNIEnv * env, int reflectType)
-{
- jclass wrapClass;
- jfieldID typeField;
-
- wrapClass = PRIMLIB_GetNativeWrapClass (env, reflectType);
- if (wrapClass == NULL)
- return NULL;
- typeField =
- (*env)->GetStaticFieldID (env, wrapClass, "TYPE", "Ljava/lang/Class");
- if (typeField == NULL)
- return NULL;
- return (*env)->GetStaticObjectField (env, wrapClass, typeField);
-}
-
-JNIEXPORT jclass JNICALL
-PRIMLIB_GetNativeTypeClass (JNIEnv * env, int reflectType)
-{
- return LINK_LinkKnownClass (env, nativeTypeClass[reflectType],
- ActuallyGetNativeTypeClass (env, reflectType));
-}
-
-JNIEXPORT jmethodID JNICALL
-PRIMLIB_GetNativeWrapClassConstructor (JNIEnv * env, int reflectType)
-{
- PRIMLIB_GetNativeWrapClass (env, reflectType);
- return LINK_LinkConstructor (env, nativeWrapClassConstructor[reflectType],
- nativeWrapClass[reflectType],
- nativeWrapClassConstructorSig[reflectType]);
-}
-
-JNIEXPORT jmethodID JNICALL
-PRIMLIB_GetNativeWrapClassAccessor (JNIEnv * env, int reflectType)
-{
- PRIMLIB_GetNativeWrapClass (env, reflectType);
- return LINK_LinkMethod (env, nativeWrapClassAccessor[reflectType],
- nativeWrapClass[reflectType],
- nativeWrapClassAccessorName[reflectType],
- nativeWrapClassAccessorSig[reflectType]);
-}
-
-
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapBoolean (JNIEnv * env, jboolean b)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_BOOLEAN);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BOOLEAN),
- construct, b);
-}
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapByte (JNIEnv * env, jbyte b)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_BYTE);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE),
- construct, b);
-}
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapChar (JNIEnv * env, jchar c)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_CHAR);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_CHAR),
- construct, c);
-}
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapShort (JNIEnv * env, jshort s)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_SHORT);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_SHORT),
- construct, s);
-}
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapInt (JNIEnv * env, jint i)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_INT);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_INT),
- construct, i);
-}
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapLong (JNIEnv * env, jlong l)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_LONG);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_LONG),
- construct, l);
-}
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapFloat (JNIEnv * env, jfloat f)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_FLOAT);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_FLOAT),
- construct, f);
-}
-
-JNIEXPORT jobject JNICALL
-PRIMLIB_WrapDouble (JNIEnv * env, jdouble d)
-{
- jmethodID construct =
- PRIMLIB_GetNativeWrapClassConstructor (env, PRIMLIB_DOUBLE);
- JCL_RETHROW_EXCEPTION (env);
- return (*env)->NewObject (env,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_DOUBLE),
- construct, d);
-}
-
-
-JNIEXPORT jboolean JNICALL
-PRIMLIB_UnwrapBoolean (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BOOLEAN)))
- {
- return PRIMLIB_GetBooleanObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return JNI_FALSE;
- }
-}
-
-JNIEXPORT jbyte JNICALL
-PRIMLIB_UnwrapByte (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj, PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE)))
- {
- return PRIMLIB_GetByteObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return 0;
- }
-}
-
-JNIEXPORT jshort JNICALL
-PRIMLIB_UnwrapShort (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_SHORT)))
- {
- return PRIMLIB_GetShortObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE)))
- {
- return (jshort) PRIMLIB_GetByteObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return 0;
- }
-}
-
-JNIEXPORT jchar JNICALL
-PRIMLIB_UnwrapChar (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj, PRIMLIB_GetNativeWrapClass (env, PRIMLIB_CHAR)))
- {
- return PRIMLIB_GetCharObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return 0;
- }
-}
-
-JNIEXPORT jint JNICALL
-PRIMLIB_UnwrapInt (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj, PRIMLIB_GetNativeWrapClass (env, PRIMLIB_INT)))
- {
- return PRIMLIB_GetIntObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_SHORT)))
- {
- return (jint) PRIMLIB_GetShortObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_CHAR)))
- {
- return (jint) PRIMLIB_GetCharObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE)))
- {
- return (jint) PRIMLIB_GetByteObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return 0;
- }
-}
-
-JNIEXPORT jlong JNICALL
-PRIMLIB_UnwrapLong (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj, PRIMLIB_GetNativeWrapClass (env, PRIMLIB_LONG)))
- {
- return PRIMLIB_GetLongObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_INT)))
- {
- return (jlong) PRIMLIB_GetIntObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_SHORT)))
- {
- return (jlong) PRIMLIB_GetShortObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_CHAR)))
- {
- return (jlong) PRIMLIB_GetCharObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE)))
- {
- return (jlong) PRIMLIB_GetByteObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return 0;
- }
-}
-
-JNIEXPORT jfloat JNICALL
-PRIMLIB_UnwrapFloat (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_FLOAT)))
- {
- return PRIMLIB_GetFloatObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_LONG)))
- {
- return (jfloat) PRIMLIB_GetLongObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_INT)))
- {
- return (jfloat) PRIMLIB_GetIntObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_SHORT)))
- {
- return (jfloat) PRIMLIB_GetShortObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_CHAR)))
- {
- return (jfloat) PRIMLIB_GetCharObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE)))
- {
- return (jfloat) PRIMLIB_GetByteObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return 0;
- }
-}
-
-JNIEXPORT jdouble JNICALL
-PRIMLIB_UnwrapDouble (JNIEnv * env, jobject obj)
-{
- if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_DOUBLE)))
- {
- return PRIMLIB_GetDoubleObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_FLOAT)))
- {
- return (jdouble) PRIMLIB_GetFloatObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_LONG)))
- {
- return (jdouble) PRIMLIB_GetLongObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_INT)))
- {
- return (jdouble) PRIMLIB_GetIntObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_SHORT)))
- {
- return (jdouble) PRIMLIB_GetShortObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_CHAR)))
- {
- return (jdouble) PRIMLIB_GetCharObjectValue (env, obj);
- }
- else if ((*env)->
- IsInstanceOf (env, obj,
- PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE)))
- {
- return (jdouble) PRIMLIB_GetByteObjectValue (env, obj);
- }
- else
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct type.");
- return 0;
- }
-}
-
-JNIEXPORT jint JNICALL
-PRIMLIB_GetReflectiveWrapperType (JNIEnv * env, jobject obj)
-{
- jclass typeClass;
- if (obj == NULL)
- {
- return PRIMLIB_NULL;
- }
-
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_DOUBLE);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_DOUBLE;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_FLOAT);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_FLOAT;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_LONG);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_LONG;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_INT);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_INT;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_CHAR);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_CHAR;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_SHORT);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_SHORT;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BYTE);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_BYTE;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_BOOLEAN);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_BOOLEAN;
- }
- typeClass = PRIMLIB_GetNativeWrapClass (env, PRIMLIB_VOID);
- if ((*env)->IsInstanceOf (env, obj, typeClass))
- {
- return PRIMLIB_VOID;
- }
- return PRIMLIB_OBJECT;
-}
-
-JNIEXPORT jint JNICALL
-PRIMLIB_GetReflectiveType (JNIEnv * env, jclass returnType)
-{
- jclass typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_DOUBLE);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_DOUBLE;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_FLOAT);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_FLOAT;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_LONG);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_LONG;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_INT);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_INT;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_CHAR);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_CHAR;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_SHORT);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_SHORT;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_BYTE);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_BYTE;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_BOOLEAN);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_BOOLEAN;
- }
- typeClass = PRIMLIB_GetNativeTypeClass (env, PRIMLIB_VOID);
- if ((*env)->IsAssignableFrom (env, returnType, typeClass))
- {
- return PRIMLIB_VOID;
- }
- return PRIMLIB_OBJECT;
-}
-
-
-JNIEXPORT jboolean JNICALL
-PRIMLIB_GetBooleanObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_BOOLEAN);
- return (*env)->CallBooleanMethod (env, obj, acc);
-}
-
-JNIEXPORT jbyte JNICALL
-PRIMLIB_GetByteObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_BYTE);
- return (*env)->CallByteMethod (env, obj, acc);
-}
-
-JNIEXPORT jshort JNICALL
-PRIMLIB_GetShortObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_SHORT);
- return (*env)->CallShortMethod (env, obj, acc);
-}
-
-JNIEXPORT jchar JNICALL
-PRIMLIB_GetCharObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_CHAR);
- return (*env)->CallCharMethod (env, obj, acc);
-}
-
-JNIEXPORT jint JNICALL
-PRIMLIB_GetIntObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_INT);
- return (*env)->CallIntMethod (env, obj, acc);
-}
-
-JNIEXPORT jlong JNICALL
-PRIMLIB_GetLongObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_LONG);
- return (*env)->CallLongMethod (env, obj, acc);
-}
-
-JNIEXPORT jfloat JNICALL
-PRIMLIB_GetFloatObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_FLOAT);
- return (*env)->CallFloatMethod (env, obj, acc);
-}
-
-JNIEXPORT jdouble JNICALL
-PRIMLIB_GetDoubleObjectValue (JNIEnv * env, jobject obj)
-{
- jmethodID acc = PRIMLIB_GetNativeWrapClassAccessor (env, PRIMLIB_DOUBLE);
- return (*env)->CallDoubleMethod (env, obj, acc);
-}
-
-
-
-JNIEXPORT jvalue JNICALL
-PRIMLIB_UnwrapJValue (JNIEnv * env, jobject obj, jclass classType)
-{
- jvalue retval;
- jint objType = PRIMLIB_GetReflectiveType (env, classType);
- if (objType == PRIMLIB_BOOLEAN)
- {
- retval.z = PRIMLIB_UnwrapBoolean (env, obj);
- }
- else if (objType == PRIMLIB_BYTE)
- {
- retval.b = PRIMLIB_UnwrapByte (env, obj);
- }
- else if (objType == PRIMLIB_CHAR)
- {
- retval.c = PRIMLIB_UnwrapChar (env, obj);
- }
- else if (objType == PRIMLIB_SHORT)
- {
- retval.s = PRIMLIB_UnwrapShort (env, obj);
- }
- else if (objType == PRIMLIB_INT)
- {
- retval.i = PRIMLIB_UnwrapInt (env, obj);
- }
- else if (objType == PRIMLIB_LONG)
- {
- retval.j = PRIMLIB_UnwrapLong (env, obj);
- }
- else if (objType == PRIMLIB_FLOAT)
- {
- retval.f = PRIMLIB_UnwrapFloat (env, obj);
- }
- else if (objType == PRIMLIB_DOUBLE)
- {
- retval.d = PRIMLIB_UnwrapDouble (env, obj);
- }
- else
- {
- if (obj != NULL && !(*env)->IsInstanceOf (env, obj, classType))
- {
- JCL_ThrowException (env, "java/lang/IllegalArgumentException",
- "Argument not of correct object type.");
- return retval;
- }
- retval.l = obj;
- }
- return retval;
-}
diff --git a/native/jni/classpath/primlib.h b/native/jni/classpath/primlib.h
deleted file mode 100644
index 3cdaaa4a1..000000000
--- a/native/jni/classpath/primlib.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* primlib.h
- 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-#ifndef __PRIMLIB_H__
-#define __PRIMLIB_H__
-
-#include <jni.h>
-
-#define PRIMLIB_UNKNOWN 0
-#define PRIMLIB_OBJECT 1
-#define PRIMLIB_BOOLEAN 2
-#define PRIMLIB_BYTE 3
-#define PRIMLIB_CHAR 4
-#define PRIMLIB_SHORT 5
-#define PRIMLIB_INT 6
-#define PRIMLIB_LONG 7
-#define PRIMLIB_FLOAT 8
-#define PRIMLIB_DOUBLE 9
-#define PRIMLIB_VOID 10
-#define PRIMLIB_NULL 11
-#define PRIMLIB_NUMTYPES 12
-
-/* Low-level primitive class accessor functions. */
-JNIEXPORT jclass JNICALL PRIMLIB_GetNativeWrapClass (JNIEnv * env,
- int reflectType);
-JNIEXPORT jclass JNICALL PRIMLIB_GetNativeTypeClass (JNIEnv * env,
- int reflectType);
-JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassConstructor (JNIEnv *
- env,
- int
- reflectType);
-JNIEXPORT jmethodID JNICALL PRIMLIB_GetNativeWrapClassAccessor (JNIEnv * env,
- int
- reflectType);
-
-/* Type discovery functions: WrapperType finds out j.l.Boolean/Byte/etc., and
- Type finds out j.l.Boolean.TYPE, etc.
-*/
-JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveWrapperType (JNIEnv * env,
- jobject obj);
-JNIEXPORT jint JNICALL PRIMLIB_GetReflectiveType (JNIEnv * env,
- jclass returnType);
-
-/* Constructor functions. */
-JNIEXPORT jobject JNICALL PRIMLIB_WrapBoolean (JNIEnv * env, jboolean b);
-JNIEXPORT jobject JNICALL PRIMLIB_WrapByte (JNIEnv * env, jbyte b);
-JNIEXPORT jobject JNICALL PRIMLIB_WrapChar (JNIEnv * env, jchar c);
-JNIEXPORT jobject JNICALL PRIMLIB_WrapShort (JNIEnv * env, jshort s);
-JNIEXPORT jobject JNICALL PRIMLIB_WrapInt (JNIEnv * env, jint i);
-JNIEXPORT jobject JNICALL PRIMLIB_WrapLong (JNIEnv * env, jlong l);
-JNIEXPORT jobject JNICALL PRIMLIB_WrapFloat (JNIEnv * env, jfloat f);
-JNIEXPORT jobject JNICALL PRIMLIB_WrapDouble (JNIEnv * env, jdouble d);
-
-/* Widening conversion unwrapping functions. */
-JNIEXPORT jboolean JNICALL PRIMLIB_UnwrapBoolean (JNIEnv * env, jobject obj);
-JNIEXPORT jbyte JNICALL PRIMLIB_UnwrapByte (JNIEnv * env, jobject obj);
-JNIEXPORT jshort JNICALL PRIMLIB_UnwrapShort (JNIEnv * env, jobject obj);
-JNIEXPORT jchar JNICALL PRIMLIB_UnwrapChar (JNIEnv * env, jobject obj);
-JNIEXPORT jint JNICALL PRIMLIB_UnwrapInt (JNIEnv * env, jobject obj);
-JNIEXPORT jlong JNICALL PRIMLIB_UnwrapLong (JNIEnv * env, jobject obj);
-JNIEXPORT jfloat JNICALL PRIMLIB_UnwrapFloat (JNIEnv * env, jobject obj);
-JNIEXPORT jdouble JNICALL PRIMLIB_UnwrapDouble (JNIEnv * env, jobject obj);
-
-/* Simple unwrapping functions. Objects *must* be of correct type. */
-JNIEXPORT jboolean JNICALL PRIMLIB_GetBooleanObjectValue (JNIEnv * env,
- jobject obj);
-JNIEXPORT jbyte JNICALL PRIMLIB_GetByteObjectValue (JNIEnv * env,
- jobject obj);
-JNIEXPORT jshort JNICALL PRIMLIB_GetShortObjectValue (JNIEnv * env,
- jobject obj);
-JNIEXPORT jchar JNICALL PRIMLIB_GetCharObjectValue (JNIEnv * env,
- jobject obj);
-JNIEXPORT jint JNICALL PRIMLIB_GetIntObjectValue (JNIEnv * env, jobject obj);
-JNIEXPORT jlong JNICALL PRIMLIB_GetLongObjectValue (JNIEnv * env,
- jobject obj);
-JNIEXPORT jfloat JNICALL PRIMLIB_GetFloatObjectValue (JNIEnv * env,
- jobject obj);
-JNIEXPORT jdouble JNICALL PRIMLIB_GetDoubleObjectValue (JNIEnv * env,
- jobject obj);
-
-/* jvalue conversion: Unwrap obj to the type of classType, with widening conversion. */
-JNIEXPORT jvalue JNICALL PRIMLIB_UnwrapJValue (JNIEnv * env, jobject obj,
- jclass classType);
-
-#endif
diff --git a/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am
index 6f21057c1..bb947424c 100644
--- a/native/jni/gtk-peer/Makefile.am
+++ b/native/jni/gtk-peer/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libgtkpeer.la
+nativelib_LTLIBRARIES = libgtkpeer.la
# Gtk/Cairo JNI sources.
if GTK_CAIRO
@@ -54,10 +54,12 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \
$(top_builddir)/native/jni/classpath/jcl.lo
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ \
+ @FREETYPE2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ -lX11 -lXtst
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
# Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
# headers contain broken prototypes (by design, see gtkitemfactory.h).
AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
- @GTK_CFLAGS@ @CAIRO_CFLAGS@ @PANGOFT2_CFLAGS@
+ @GTK_CFLAGS@ @CAIRO_CFLAGS@ @PANGOFT2_CFLAGS@ @FREETYPE2_CFLAGS@ \
+ @X_CFLAGS@
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
index b122eb015..4aca1cf57 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
@@ -116,11 +116,11 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState
gdk_gc_copy (g->gc, g_old->gc);
if (GDK_STABLE_IS_PIXMAP (g->drawable))
- gdk_pixmap_ref (g->drawable);
+ g_object_ref (g->drawable);
else /* GDK_IS_WINDOW (g->drawable) */
- gdk_window_ref (g->drawable);
+ g_object_ref (g->drawable);
- gdk_colormap_ref (g->cm);
+ g_object_ref (g->cm);
NSA_SET_G_PTR (env, obj, g);
@@ -140,8 +140,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II
g->drawable = (GdkDrawable *) gdk_pixmap_new (NULL, width, height,
gdk_rgb_get_visual ()->depth);
- g->cm = gdk_rgb_get_cmap ();
- gdk_colormap_ref (g->cm);
+ g->cm = gdk_rgb_get_colormap ();
+ g_object_ref (g->cm);
g->gc = gdk_gc_new (g->drawable);
NSA_SET_G_PTR (env, obj, g);
@@ -160,7 +160,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
pixmap = cp_gtk_image_get_pixmap (env, source);
g_assert(pixmap != NULL);
- gdk_pixmap_ref (pixmap);
+ g_object_ref (pixmap);
g = (struct graphics *) g_malloc (sizeof (struct graphics));
g->x_offset = g->y_offset = 0;
@@ -168,7 +168,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
g->drawable = (GdkDrawable *)pixmap;
g->cm = gdk_drawable_get_colormap (g->drawable);
- gdk_colormap_ref (g->cm);
+ g_object_ref (g->cm);
g->gc = gdk_gc_new (g->drawable);
NSA_SET_G_PTR (env, obj, g);
@@ -193,9 +193,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked
widget = GTK_WIDGET (ptr);
g->drawable = (GdkDrawable *) widget->window;
- gdk_window_ref (g->drawable);
+ g_object_ref (g->drawable);
g->cm = gtk_widget_get_colormap (widget);
- gdk_colormap_ref (g->cm);
+ g_object_ref (g->cm);
g->gc = gdk_gc_new (g->drawable);
gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]);
color = widget->style->fg[GTK_STATE_NORMAL];
@@ -254,14 +254,14 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose
XFlush (GDK_DISPLAY ());
- gdk_gc_destroy (g->gc);
+ g_object_unref (g->gc);
if (GDK_STABLE_IS_PIXMAP (g->drawable))
- gdk_pixmap_unref (g->drawable);
+ g_object_unref (g->drawable);
else /* GDK_IS_WINDOW (g->drawable) */
- gdk_window_unref (g->drawable);
+ g_object_unref (g->drawable);
- gdk_colormap_unref (g->cm);
+ g_object_unref (g->cm);
g_free (g);
@@ -388,12 +388,12 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea
g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- gdk_window_copy_area ((GdkWindow *)g->drawable,
- g->gc,
- x + g->x_offset + dx, y + g->y_offset + dy,
- (GdkWindow *)g->drawable,
- x + g->x_offset, y + g->y_offset,
- width, height);
+ gdk_draw_drawable ((GdkWindow *)g->drawable,
+ g->gc,
+ (GdkWindow *)g->drawable,
+ x + g->x_offset, y + g->y_offset,
+ x + g->x_offset + dx, y + g->y_offset + dy,
+ width, height);
gdk_flush ();
gdk_threads_leave ();
@@ -471,8 +471,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor
color.blue = blue << 8;
g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_color_alloc (g->cm, &color);
+
+ gdk_colormap_alloc_color (g->cm, &color, TRUE, TRUE);
gdk_gc_set_foreground (g->gc, &color);
gdk_threads_leave ();
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
index fe9980ffd..17effd88f 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
@@ -58,9 +58,12 @@ void
cp_gtk_graphics2d_init_jni (void)
{
jclass gdkgraphics2d;
+ JNIEnv *env = cp_gtk_gdk_env();
- gdkgraphics2d = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
- "gnu/java/awt/peer/gtk/GdkGraphics2D");
+ gdkgraphics2d = (*env)->FindClass (env,
+ "gnu/java/awt/peer/gtk/GdkGraphics2D");
+ if ((*env)->ExceptionOccurred(env))
+ return;
initComponentGraphics2DUnlockedID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics2d,
"initComponentGraphics2DUnlocked",
@@ -931,9 +934,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
CAIRO_FORMAT_ARGB32,
w, h, stride * 4);
g_assert (gr->pattern_surface != NULL);
- cairo_pattern_set_extend (gr->pattern, 1);
gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface);
g_assert (gr->pattern != NULL);
+ cairo_pattern_set_extend (gr->pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source (gr->cr, gr->pattern);
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
index 918ecfd0a..edce3917d 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
@@ -1,5 +1,5 @@
/* gnu_java_awt_GdkTextLayout.c
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,12 +38,28 @@
#include <jni.h>
#include <gtk/gtk.h>
+#include <string.h>
+#include <pango/pango.h>
+#include <pango/pangoft2.h>
+#include <pango/pangofc-font.h>
+#include <freetype/ftglyph.h>
+#include <freetype/ftoutln.h>
#include "native_state.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkTextLayout.h"
struct state_table *cp_gtk_native_text_layout_state_table;
+typedef struct gp
+{
+ JNIEnv *env;
+ jobject obj;
+ double px;
+ double py;
+ double sx;
+ double sy;
+} generalpath ;
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkTextLayout_initStaticState
(JNIEnv *env, jclass clazz)
@@ -190,3 +206,219 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_dispose
gdk_threads_leave ();
}
+
+/* GetOutline code follows ****************************/
+/********* Freetype callback functions *****************************/
+
+static int _moveTo( FT_Vector* to,
+ void *p)
+{
+ JNIEnv *env;
+ jobject obj;
+ jclass cls;
+ jmethodID method;
+ jvalue values[2];
+ generalpath *path = (generalpath *) p;
+
+ env = path->env;
+ obj = path->obj;
+
+ values[0].f = (jfloat)(to->x * path->sx + path->px);
+ values[1].f = (jfloat)(to->y * path->sy + path->py);
+
+ cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+ method = (*env)->GetMethodID (env, cls, "moveTo", "(FF)V");
+ (*env)->CallVoidMethodA(env, obj, method, values );
+
+ return 0;
+}
+
+static int _lineTo( FT_Vector* to,
+ void *p)
+{
+ JNIEnv *env;
+ jobject obj;
+ jclass cls;
+ jmethodID method;
+ jvalue values[2];
+ generalpath *path = (generalpath *) p;
+
+ env = path->env;
+ obj = path->obj;
+ values[0].f = (jfloat)(to->x * path->sx + path->px);
+ values[1].f = (jfloat)(to->y * path->sy + path->py);
+
+ cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+ method = (*env)->GetMethodID (env, cls, "lineTo", "(FF)V");
+ (*env)->CallVoidMethodA(env, obj, method, values );
+
+ return 0;
+}
+
+static int _quadTo( FT_Vector* cp,
+ FT_Vector* to,
+ void *p)
+{
+ JNIEnv *env;
+ jobject obj;
+ jclass cls;
+ jmethodID method;
+ jvalue values[4];
+ generalpath *path = (generalpath *) p;
+
+ env = path->env;
+ obj = path->obj;
+ values[0].f = (jfloat)(cp->x * path->sx + path->px);
+ values[1].f = (jfloat)(cp->y * path->sy + path->py);
+ values[2].f = (jfloat)(to->x * path->sx + path->px);
+ values[3].f = (jfloat)(to->y * path->sy + path->py);
+
+ cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+ method = (*env)->GetMethodID (env, cls, "quadTo", "(FFFF)V");
+ (*env)->CallVoidMethodA(env, obj, method, values );
+
+ return 0;
+}
+
+static int _curveTo( FT_Vector* cp1,
+ FT_Vector* cp2,
+ FT_Vector* to,
+ void *p)
+{
+ JNIEnv *env;
+ jobject obj;
+ jclass cls;
+ jmethodID method;
+ jvalue values[6];
+ generalpath *path = (generalpath *) p;
+
+ env = path->env;
+ obj = path->obj;
+ values[0].f = (jfloat)(cp1->x * path->sx + path->px);
+ values[1].f = (jfloat)(cp1->y * path->sy + path->py);
+ values[2].f = (jfloat)(cp2->x * path->sx + path->px);
+ values[3].f = (jfloat)(cp2->y * path->sy + path->py);
+ values[4].f = (jfloat)(to->x * path->sx + path->px);
+ values[5].f = (jfloat)(to->y * path->sy + path->py);
+
+ cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+ method = (*env)->GetMethodID (env, cls, "curveTo", "(FFFFFF)V");
+ (*env)->CallVoidMethodA(env, obj, method, values );
+
+ return 0;
+}
+
+
+JNIEXPORT jobject JNICALL
+Java_gnu_java_awt_peer_gtk_GdkTextLayout_getOutline
+ (JNIEnv *env, jobject obj, jobject transform)
+{
+ struct textlayout *tl;
+ generalpath *path;
+ jobject gp;
+ GSList *current_run;
+ PangoLayoutLine *current_line;
+ FT_Outline_Funcs ftCallbacks =
+ {
+ _moveTo,
+ _lineTo,
+ _quadTo,
+ _curveTo,
+ 0,
+ 0
+ };
+ PangoLayoutIter* layoutIterator;
+
+ gdk_threads_enter ();
+
+ tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, obj);
+ g_assert(tl != NULL);
+ g_assert(tl->pango_layout != NULL);
+
+ path = g_malloc0 (sizeof (generalpath));
+ g_assert(path != NULL);
+ path->env = env;
+
+ /* Scaling factors */
+ path->sx = PANGO_SCALE/65536.0;
+ path->sy = -PANGO_SCALE/65536.0;
+
+ { /* create a GeneralPath instance */
+ jclass cls;
+ jmethodID method;
+
+ cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+ method = (*env)->GetMethodID (env, cls, "<init>", "()V");
+ gp = path->obj = (*env)->NewObject (env, cls, method);
+ }
+
+ layoutIterator = pango_layout_get_iter (tl->pango_layout);
+ g_assert (layoutIterator != NULL);
+
+ if (pango_layout_iter_get_line (layoutIterator))
+ do
+ {
+ PangoRectangle line_logical_rect;
+ current_line = pango_layout_iter_get_line (layoutIterator);
+ pango_layout_iter_get_line_extents (layoutIterator,
+ NULL,
+ &line_logical_rect);
+
+ path->px = line_logical_rect.x/(double)PANGO_SCALE;
+ path->py = line_logical_rect.y/(double)PANGO_SCALE;
+
+ current_run = current_line->runs;
+ while (current_run)
+ {
+ FT_Face ft_face;
+ int index;
+ PangoGlyphItem *run = current_run->data;
+ PangoGlyphString *glyphs = run->glyphs;
+
+ PangoAnalysis *analysis = &run->item->analysis;
+ g_assert (analysis != NULL);
+ g_assert (analysis->font != NULL);
+
+ ft_face = pango_fc_font_lock_face ((PangoFcFont *)analysis->font);
+ g_assert (ft_face != NULL);
+
+ for (index = 0; index < glyphs->num_glyphs; index++)
+ {
+ FT_Glyph glyph;
+ FT_Error fterror;
+ PangoGlyphGeometry pgg = glyphs->glyphs[index].geometry;
+
+ fterror = FT_Load_Glyph(ft_face,
+ (FT_UInt)(glyphs->glyphs[index].glyph),
+ FT_LOAD_DEFAULT | FT_LOAD_NO_BITMAP);
+ g_assert(fterror == 0);
+
+ FT_Get_Glyph (ft_face->glyph, &glyph);
+ FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline),
+ &ftCallbacks, path);
+ FT_Done_Glyph (glyph);
+
+ path->px += pgg.width/(double)PANGO_SCALE;
+ }
+
+ pango_fc_font_unlock_face ((PangoFcFont *)analysis->font);
+ current_run = current_run->next;
+ }
+ } while (pango_layout_iter_next_line (layoutIterator));
+
+ g_free(path);
+ gdk_threads_leave ();
+
+ if (transform != NULL)
+ {
+ jclass cls;
+ jmethodID method;
+
+ cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+ method = (*env)->GetMethodID (env, cls, "transform",
+ "(Ljava/awt/geom/AffineTransform;)V");
+ (*env)->CallVoidMethod(env, gp, method, transform );
+ }
+
+ return gp;
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
index 52922ddb8..ef9ac1207 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
@@ -46,11 +46,11 @@ Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create
gpointer widget;
gdk_threads_enter ();
-
+
/* Create global reference and save it for future use */
NSA_SET_GLOBAL_REF (env, obj);
- widget = gtk_type_new (gtk_drawing_area_get_type ());
+ widget = gtk_drawing_area_new ();
NSA_SET_PTR (env, obj, widget);
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
index 4f2875092..5ba300b7e 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c
@@ -64,7 +64,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer_remove
/* Update the group to point to some other widget in the group. We
have to do this because Gtk doesn't have a separate object to
represent a radio button's group. */
- for (list = gtk_radio_button_group (button); list != NULL;
+ for (list = gtk_radio_button_get_group (button); list != NULL;
list = list->next)
{
if (list->data != button)
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
index 7012bd821..b74b0a265 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
@@ -130,7 +130,7 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup
gtk_radio_button_set_group (button, NULL);
else
gtk_radio_button_set_group (button,
- gtk_radio_button_group
+ gtk_radio_button_get_group
(GTK_RADIO_BUTTON (native_group)));
/* If the native group wasn't set on the new CheckboxGroup, then set
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
index 684deeb84..85ce2ae65 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
@@ -249,7 +249,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked
gdk_cursor = gdk_cursor_new (gdk_cursor_type);
gdk_window_set_cursor (widget->window, gdk_cursor);
- gdk_cursor_destroy (gdk_cursor);
+ gdk_cursor_unref (gdk_cursor);
}
JNIEXPORT void JNICALL
@@ -272,9 +272,9 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent
if (widget->parent == NULL)
{
if (GTK_IS_WINDOW (parent_widget))
- {
- GList *children = gtk_container_children
- (GTK_CONTAINER (parent_widget));
+ {
+ GList *children = gtk_container_get_children
+ (GTK_CONTAINER (parent_widget));
if (GTK_IS_MENU_BAR (children->data))
gtk_fixed_put (GTK_FIXED (children->next->data), widget, 0, 0);
@@ -465,7 +465,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen
ptr = NSA_GET_PTR (env, obj);
point = (*env)->GetIntArrayElements (env, jpoint, 0);
- gdk_window_get_origin (GTK_WIDGET (ptr)->window, point, point+1);
+ gdk_window_get_root_origin (GTK_WIDGET (ptr)->window, point, point+1);
if (!GTK_IS_CONTAINER (ptr))
{
@@ -843,7 +843,7 @@ find_fg_color_widget (GtkWidget *widget)
if (GTK_IS_EVENT_BOX (widget)
|| (GTK_IS_BUTTON (widget)
- && !GTK_IS_OPTION_MENU (widget)))
+ && !GTK_IS_COMBO_BOX (widget)))
fg_color_widget = gtk_bin_get_child (GTK_BIN(widget));
else
fg_color_widget = widget;
@@ -973,7 +973,7 @@ component_button_release_cb (GtkWidget *widget __attribute__((unused)),
/* Generate an AWT click event only if the release occured in the
window it was pressed in, and the mouse has not been dragged since
the last time it was pressed. */
- gdk_window_get_size (event->window, &width, &height);
+ gdk_drawable_get_size (event->window, &width, &height);
if (! hasBeenDragged
&& event->x >= 0
&& event->y >= 0
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
index fdc73ccdb..ae0657636 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
@@ -299,7 +299,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap(JNIEnv *env, jobject obj)
if (offScreen (env, obj) == JNI_FALSE)
gdk_pixbuf_unref ((GdkPixbuf *)getData (env, obj));
else
- gdk_pixmap_unref ((GdkPixmap *)getData (env, obj));
+ g_object_unref ((GdkPixmap *)getData (env, obj));
gdk_threads_leave ();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
index 3e21a0402..a5c0074c0 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
@@ -88,7 +88,7 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_nativeSetHelpMenu
if (helpmenu != NULL)
{
- list = gtk_container_children (GTK_CONTAINER (mbar));
+ list = gtk_container_get_children (GTK_CONTAINER (mbar));
while (list != NULL && list->data != helpmenu)
list = list->next;
if (list != NULL && list->data == helpmenu)
@@ -110,7 +110,7 @@ Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_delMenu
ptr = NSA_GET_PTR (env, obj);
- list = gtk_container_children (GTK_CONTAINER (ptr));
+ list = gtk_container_get_children (GTK_CONTAINER (ptr));
list = g_list_nth (list, index);
gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data));
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
index 16018f001..b61a55bee 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
@@ -165,7 +165,7 @@ Java_gnu_java_awt_peer_gtk_GtkMenuPeer_delItem
ptr = NSA_GET_PTR (env, obj);
- list = gtk_container_children (GTK_CONTAINER (ptr));
+ list = gtk_container_get_children (GTK_CONTAINER (ptr));
list = g_list_nth (list, index);
gtk_container_remove (GTK_CONTAINER (ptr), GTK_WIDGET (list->data));
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index 040cc92ff..59b56cf35 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -160,9 +160,7 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
XSynchronize (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), True);
#endif
- gdk_rgb_init ();
- gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
- gtk_widget_set_default_visual (gdk_rgb_get_visual ());
+ gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
/* Make sure queued calls don't get sent to GTK/GDK while
we're shutting down. */
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
index e5262957e..d79bbecba 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
@@ -1205,7 +1205,7 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetResizable
ptr = NSA_GET_PTR (env, obj);
- gtk_window_set_policy (GTK_WINDOW (ptr), resizable, resizable, FALSE);
+ gtk_window_set_resizable (GTK_WINDOW (ptr), resizable);
gdk_threads_leave ();
}
diff --git a/native/jni/java-io/Makefile.am b/native/jni/java-io/Makefile.am
index 5ed8a1baf..efa7d5688 100644
--- a/native/jni/java-io/Makefile.am
+++ b/native/jni/java-io/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libjavaio.la
+nativelib_LTLIBRARIES = libjavaio.la
libjavaio_la_SOURCES = javaio.h \
javaio.c \
diff --git a/native/jni/java-lang/Makefile.am b/native/jni/java-lang/Makefile.am
index 34ffe00fb..fb8390f08 100644
--- a/native/jni/java-lang/Makefile.am
+++ b/native/jni/java-lang/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libjavalang.la libjavalangreflect.la
+nativelib_LTLIBRARIES = libjavalang.la libjavalangreflect.la
libjavalang_la_SOURCES = java_lang_VMSystem.c \
java_lang_VMFloat.c \
diff --git a/native/jni/java-lang/java_lang_VMProcess.c b/native/jni/java-lang/java_lang_VMProcess.c
index 1c5a11ff9..a8eb75026 100644
--- a/native/jni/java-lang/java_lang_VMProcess.c
+++ b/native/jni/java-lang/java_lang_VMProcess.c
@@ -366,7 +366,6 @@ Java_java_lang_VMProcess_nativeSpawn (JNIEnv * env, jobject this,
streams[0], streams[1], streams[2], (jlong) pid);
if ((*env)->ExceptionOccurred (env))
goto done;
- (*env)->DeleteLocalRef (env, clazz);
done:
/*
diff --git a/native/jni/java-lang/java_lang_reflect_Array.c b/native/jni/java-lang/java_lang_reflect_Array.c
index 0bd23c16f..64ad202db 100644
--- a/native/jni/java-lang/java_lang_reflect_Array.c
+++ b/native/jni/java-lang/java_lang_reflect_Array.c
@@ -42,6 +42,7 @@ exception statement from your version. */
* Date: 2 Jun 1998
*/
+#include <config.h>
#include <stddef.h>
#include "java_lang_reflect_Array.h"
diff --git a/native/jni/java-net/Makefile.am b/native/jni/java-net/Makefile.am
index 3e8c863a9..bf7a92bbf 100644
--- a/native/jni/java-net/Makefile.am
+++ b/native/jni/java-net/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libjavanet.la
+nativelib_LTLIBRARIES = libjavanet.la
libjavanet_la_SOURCES = javanet.c \
javanet.h \
diff --git a/native/jni/java-net/javanet.c b/native/jni/java-net/javanet.c
index 51c58a921..31afbc869 100644
--- a/native/jni/java-net/javanet.c
+++ b/native/jni/java-net/javanet.c
@@ -856,8 +856,12 @@ _javanet_accept (JNIEnv * env, jobject this, jobject impl)
&& (TARGET_NATIVE_LAST_ERROR ()
!= TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL))
{
- JCL_ThrowException (env, IO_EXCEPTION,
- TARGET_NATIVE_LAST_ERROR_STRING ());
+ if (TARGET_NATIVE_LAST_ERROR () == EAGAIN)
+ JCL_ThrowException (env, "java/net/SocketTimeoutException",
+ "Timeout");
+ else
+ JCL_ThrowException (env, IO_EXCEPTION,
+ TARGET_NATIVE_LAST_ERROR_STRING ());
return;
}
}
diff --git a/native/jni/java-nio/Makefile.am b/native/jni/java-nio/Makefile.am
index 9785fee6d..8fd5ba3ae 100644
--- a/native/jni/java-nio/Makefile.am
+++ b/native/jni/java-nio/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libjavanio.la
+nativelib_LTLIBRARIES = libjavanio.la
libjavanio_la_SOURCES = gnu_java_nio_VMPipe.c \
gnu_java_nio_VMSelector.c \
diff --git a/native/jni/java-util/Makefile.am b/native/jni/java-util/Makefile.am
index da617f6a2..148e9ccbe 100644
--- a/native/jni/java-util/Makefile.am
+++ b/native/jni/java-util/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libjavautil.la
+nativelib_LTLIBRARIES = libjavautil.la
libjavautil_la_SOURCES = java_util_VMTimeZone.c
diff --git a/native/jni/midi-alsa/.cvsignore b/native/jni/midi-alsa/.cvsignore
new file mode 100644
index 000000000..a71781585
--- /dev/null
+++ b/native/jni/midi-alsa/.cvsignore
@@ -0,0 +1,7 @@
+*.o
+*.a
+*.lo
+*.la
+.libs
+.depsMakefile
+Makefile.in
diff --git a/native/jni/midi-alsa/Makefile.am b/native/jni/midi-alsa/Makefile.am
new file mode 100644
index 000000000..b6498df2b
--- /dev/null
+++ b/native/jni/midi-alsa/Makefile.am
@@ -0,0 +1,11 @@
+nativelib_LTLIBRARIES = libgjsmalsa.la
+
+libgjsmalsa_la_SOURCES = gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.c \
+gnu_javax_sound_midi_alsa_AlsaPortDevice.c \
+gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.c
+
+libgjsmalsa_la_LIBADD = -lasound
+
+AM_LDFLAGS = @CLASSPATH_MODULE@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@ `pkg-config --cflags-only-I alsa`
+AM_CFLAGS = @WARNING_CFLAGS@ @STRICT_WARNING_CFLAGS@ @ERROR_CFLAGS@ `pkg-config --cflags-only-other alsa`
diff --git a/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.c b/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.c
new file mode 100644
index 000000000..f740b276a
--- /dev/null
+++ b/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.c
@@ -0,0 +1,148 @@
+/* gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.c
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+#include <config.h>
+#include <gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider.h>
+
+#include <alsa/asoundlib.h>
+
+static snd_seq_t *seq;
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider_init_1
+(JNIEnv *env __attribute__((unused)), jobject this __attribute__((unused)))
+{
+ int rc = snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK);
+ if (rc < 0)
+ abort ();
+ snd_seq_set_client_name(seq, "gnu.javax.sound.midi.alsa");
+}
+
+/**
+ * Return a CLAZZ[] filled with ports matching TYPE.
+ */
+static jobjectArray
+getPortDeviceInfo (JNIEnv *env, unsigned type, const char *clazz)
+{
+ jobjectArray rarray;
+ snd_seq_client_info_t *cinfo;
+ snd_seq_port_info_t *pinfo;
+ int client;
+ int count = 0;
+ jclass icls;
+ jmethodID mid;
+
+ snd_seq_client_info_alloca(&cinfo);
+ snd_seq_port_info_alloca(&pinfo);
+
+ /* First, count the number of input devices. */
+ snd_seq_client_info_set_client (cinfo, -1);
+ while (snd_seq_query_next_client (seq, cinfo) >= 0)
+ {
+ client = snd_seq_client_info_get_client (cinfo);
+ if (client == 0)
+ continue;
+ snd_seq_port_info_set_client (pinfo, client);
+ snd_seq_port_info_set_port (pinfo, -1);
+ while (snd_seq_query_next_port (seq, pinfo) >= 0)
+ {
+ if ((snd_seq_port_info_get_capability (pinfo) & type) != type)
+ continue;
+ count++;
+ }
+ }
+
+ icls = (*env)->FindClass(env, clazz);
+ mid = (*env)->GetMethodID(env, icls, "<init>",
+ "(Ljava/lang/String;Ljava/lang/String;JJ)V");
+
+ rarray = (jobjectArray) (*env)->NewObjectArray(env, count, icls, NULL);
+
+ /* Now, populate our array. */
+ count = 0;
+ snd_seq_client_info_set_client (cinfo, -1);
+ while (snd_seq_query_next_client (seq, cinfo) >= 0)
+ {
+ const char *client_name;
+ client = snd_seq_client_info_get_client (cinfo);
+ if (client == 0)
+ continue;
+ snd_seq_port_info_set_client (pinfo, client);
+ snd_seq_port_info_set_port (pinfo, -1);
+
+ client_name = snd_seq_client_info_get_name (cinfo);
+
+ while (snd_seq_query_next_port (seq, pinfo) >= 0)
+ {
+ const char *port_name;
+
+ if ((snd_seq_port_info_get_capability (pinfo) & type) != type)
+ continue;
+
+ port_name = snd_seq_port_info_get_name (pinfo);
+
+ (*env)->SetObjectArrayElement(env, rarray, count,
+ (*env)->NewObject (env, icls, mid,
+ (*env)->NewStringUTF (env, client_name),
+ (*env)->NewStringUTF (env, port_name),
+ (jlong) snd_seq_port_info_get_client(pinfo),
+ (jlong) snd_seq_port_info_get_port(pinfo)));
+ count++;
+ }
+ }
+
+ return rarray;
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider_getInputDeviceInfo_1
+ (JNIEnv *env, jobject this __attribute__((unused)))
+{
+ return getPortDeviceInfo (env,
+ (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ),
+ "gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider$AlsaInputPortInfo");
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_gnu_javax_sound_midi_alsa_AlsaMidiDeviceProvider_getOutputDeviceInfo_1
+ (JNIEnv *env, jobject this __attribute__((unused)))
+{
+ return getPortDeviceInfo (env,
+ (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE),
+ "gnu/javax/sound/midi/alsa/AlsaMidiDeviceProvider$AlsaOutputPortInfo");
+}
+
diff --git a/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.c b/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.c
new file mode 100644
index 000000000..6e079d36c
--- /dev/null
+++ b/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.c
@@ -0,0 +1,59 @@
+/* gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.c
+ Copyright (C) 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#include <config.h>
+#include <gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice.h>
+
+JNIEXPORT jlong JNICALL
+Java_gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice_open_1
+ (JNIEnv *env __attribute__((unused)), jobject this __attribute__((unused)))
+{
+ /* Nothing yet. */
+ return 555;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_alsa_AlsaMidiSequencerDevice_close_1
+ (JNIEnv *env __attribute__((unused)),
+ jobject this __attribute__((unused)), jlong s __attribute__((unused)))
+{
+ /* Nothing. */
+}
+
+
diff --git a/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c b/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c
new file mode 100644
index 000000000..f4f8dd84a
--- /dev/null
+++ b/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c
@@ -0,0 +1,150 @@
+/* gnu_javax_sound_midi_alsa_AlsaPortDevice.c - Native support
+ Copyright (C) 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#include <config.h>
+#include <gnu_javax_sound_midi_alsa_AlsaPortDevice.h>
+#include <unistd.h>
+
+#include <alsa/asoundlib.h>
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_alsa_AlsaPortDevice_run_1receiver_1thread_1
+ (JNIEnv *env, jobject this __attribute__((unused)),
+ jlong client, jlong port, jobject receiver)
+{
+ int rc;
+ snd_seq_port_info_t *pinfo, *sinfo;
+ snd_seq_port_subscribe_t *subs;
+ snd_seq_addr_t sender, dest;
+ snd_seq_t *seq;
+
+ snd_seq_port_info_alloca (&pinfo);
+ snd_seq_port_info_alloca (&sinfo);
+ snd_seq_port_subscribe_alloca (&subs);
+
+ rc = snd_seq_open (&seq, "default", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK);
+
+ snd_seq_port_info_set_capability (pinfo, SND_SEQ_PORT_CAP_WRITE);
+ snd_seq_port_info_set_type (pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
+
+ rc = snd_seq_create_port (seq, pinfo);
+
+ sender.client = (int) client;
+ sender.port = (int) port;
+ dest.client = snd_seq_port_info_get_client(pinfo);
+ dest.port = snd_seq_port_info_get_port(pinfo);
+
+ snd_seq_port_subscribe_set_sender (subs, &sender);
+ snd_seq_port_subscribe_set_dest (subs, &dest);
+ rc = snd_seq_subscribe_port(seq, subs);
+
+ {
+ int npfd;
+ struct pollfd *pfd;
+ jclass smcls, rcls;
+ jmethodID sminit, rsend;
+ jbyteArray mba;
+ jbyte *ba;
+ jobject msg;
+ jlong jtimestamp;
+
+ npfd = snd_seq_poll_descriptors_count (seq, POLLIN);
+ pfd = (struct pollfd *) alloca (npfd * sizeof (struct pollfd));
+ snd_seq_poll_descriptors (seq, pfd, npfd, POLLIN);
+
+ smcls = (*env)->FindClass(env, "javax/sound/midi/ShortMessage");
+ sminit = (*env)->GetMethodID(env, smcls, "<init>", "([B)V");
+
+ rcls = (*env)->FindClass(env, "javax/sound/midi/Receiver");
+ rsend = (*env)->GetMethodID(env, rcls, "send", "(Ljavax/sound/midi/MidiMessage;J)V");
+
+ while (1)
+ {
+ if (poll (pfd, npfd, 100000) > 0)
+ {
+ snd_seq_event_t *ev;
+
+ do
+ {
+ snd_seq_event_input (seq, &ev);
+
+ if ((ev->flags & SND_SEQ_TIME_STAMP_MASK) == SND_SEQ_TIME_STAMP_TICK)
+ jtimestamp = (jlong) ev->time.tick;
+ else
+ jtimestamp = (jlong) ev->time.time.tv_sec * (jlong) 1000000000
+ + (jlong) ev->time.time.tv_nsec;
+
+ switch (ev->type)
+ {
+ case SND_SEQ_EVENT_NOTEON:
+ mba = (*env)->NewByteArray (env, 3);
+ ba = (*env)->GetByteArrayElements (env, mba, 0);
+ ba[0] = 0x90 + ev->data.control.channel;
+ ba[1] = ev->data.note.note;
+ ba[2] = ev->data.note.velocity;
+ (*env)->ReleaseByteArrayElements (env, mba, ba, 0);
+ msg = (*env)->NewObject(env, smcls, sminit, mba);
+ (*env)->CallObjectMethod(env, receiver,
+ rsend, msg, jtimestamp);
+ break;
+
+ case SND_SEQ_EVENT_CONTROLLER:
+ mba = (*env)->NewByteArray (env, 3);
+ ba = (*env)->GetByteArrayElements (env, mba, 0);
+ ba[0] = 0xB0 + ev->data.control.channel;
+ ba[1] = ev->data.control.param;
+ ba[2] = ev->data.control.value;
+ (*env)->ReleaseByteArrayElements (env, mba, ba, 0);
+ msg = (*env)->NewObject(env, smcls, sminit, mba);
+ (*env)->CallObjectMethod(env, receiver,
+ rsend, msg, jtimestamp);
+ break;
+
+ default:
+ printf ("UNKNOWN EVENT 0x%x\n", ev->type);
+ break;
+ }
+
+ snd_seq_free_event(ev);
+ }
+ while (snd_seq_event_input_pending (seq, 0) > 0);
+ }
+ }
+ }
+}
diff --git a/native/jni/midi-dssi/.cvsignore b/native/jni/midi-dssi/.cvsignore
new file mode 100644
index 000000000..a71781585
--- /dev/null
+++ b/native/jni/midi-dssi/.cvsignore
@@ -0,0 +1,7 @@
+*.o
+*.a
+*.lo
+*.la
+.libs
+.depsMakefile
+Makefile.in
diff --git a/native/jni/midi-dssi/Makefile.am b/native/jni/midi-dssi/Makefile.am
new file mode 100644
index 000000000..58ee5c925
--- /dev/null
+++ b/native/jni/midi-dssi/Makefile.am
@@ -0,0 +1,10 @@
+nativelib_LTLIBRARIES = libgjsmdssi.la
+
+libgjsmdssi_la_SOURCES = gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c \
+gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+
+libgjsmdssi_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo -ljack
+
+AM_LDFLAGS = @CLASSPATH_MODULE@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+AM_CFLAGS = @WARNING_CFLAGS@ @STRICT_WARNING_CFLAGS@ @ERROR_CFLAGS@
diff --git a/native/jni/midi-dssi/README b/native/jni/midi-dssi/README
new file mode 100644
index 000000000..6913414ff
--- /dev/null
+++ b/native/jni/midi-dssi/README
@@ -0,0 +1,134 @@
+The file native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
+contains two functions (get_port_default and set_control) derived from
+example code in the DSSI distribution (http://dssi.sourceforge.net).
+The original DSSI example code is distributed under the following
+terms:
+
+ Copyright 2004 Chris Cannam, Steve Harris and Sean Bolton.
+
+ Permission to use, copy, modify, distribute, and sell this software
+ for any purpose is hereby granted without fee, provided that the
+ above copyright notice and this permission notice are included in
+ all copies or substantial portions of the software.
+
+
+The rest of this file contain the original versions of these
+functions.
+
+
+LADSPA_Data get_port_default(const LADSPA_Descriptor *plugin, int port)
+{
+ LADSPA_PortRangeHint hint = plugin->PortRangeHints[port];
+ float lower = hint.LowerBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor) ? sample_rate : 1.0f);
+ float upper = hint.UpperBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor) ? sample_rate : 1.0f);
+
+ if (!LADSPA_IS_HINT_HAS_DEFAULT(hint.HintDescriptor)) {
+ if (!LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) ||
+ !LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) {
+ /* No hint, its not bounded, wild guess */
+ return 0.0f;
+ }
+
+ if (lower <= 0.0f && upper >= 0.0f) {
+ /* It spans 0.0, 0.0 is often a good guess */
+ return 0.0f;
+ }
+
+ /* No clues, return minimum */
+ return lower;
+ }
+
+ /* Try all the easy ones */
+
+ if (LADSPA_IS_HINT_DEFAULT_0(hint.HintDescriptor)) {
+ return 0.0f;
+ } else if (LADSPA_IS_HINT_DEFAULT_1(hint.HintDescriptor)) {
+ return 1.0f;
+ } else if (LADSPA_IS_HINT_DEFAULT_100(hint.HintDescriptor)) {
+ return 100.0f;
+ } else if (LADSPA_IS_HINT_DEFAULT_440(hint.HintDescriptor)) {
+ return 440.0f;
+ }
+
+ /* All the others require some bounds */
+
+ if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) {
+ if (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint.HintDescriptor)) {
+ return lower;
+ }
+ }
+ if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) {
+ if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint.HintDescriptor)) {
+ return upper;
+ }
+ if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) {
+ if (LADSPA_IS_HINT_DEFAULT_LOW(hint.HintDescriptor)) {
+ return lower * 0.75f + upper * 0.25f;
+ } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint.HintDescriptor)) {
+ return lower * 0.5f + upper * 0.5f;
+ } else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint.HintDescriptor)) {
+ return lower * 0.25f + upper * 0.75f;
+ }
+ }
+ }
+
+ /* fallback */
+ return 0.0f;
+}
+
+
+void
+setControl(d3h_instance_t *instance, long controlIn, snd_seq_event_t *event)
+{
+ long port = pluginControlInPortNumbers[controlIn];
+
+ const LADSPA_Descriptor *p = instance->plugin->descriptor->LADSPA_Plugin;
+
+ LADSPA_PortRangeHintDescriptor d = p->PortRangeHints[port].HintDescriptor;
+
+ LADSPA_Data lb = p->PortRangeHints[port].LowerBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(p->PortRangeHints[port].HintDescriptor) ?
+ sample_rate : 1.0f);
+
+ LADSPA_Data ub = p->PortRangeHints[port].UpperBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(p->PortRangeHints[port].HintDescriptor) ?
+ sample_rate : 1.0f);
+
+ float value = (float)event->data.control.value;
+
+ if (!LADSPA_IS_HINT_BOUNDED_BELOW(d)) {
+ if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) {
+ /* unbounded: might as well leave the value alone. */
+ } else {
+ /* bounded above only. just shift the range. */
+ value = ub - 127.0f + value;
+ }
+ } else {
+ if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) {
+ /* bounded below only. just shift the range. */
+ value = lb + value;
+ } else {
+ /* bounded both ends. more interesting. */
+ if (LADSPA_IS_HINT_LOGARITHMIC(d)) {
+ const float llb = logf(lb);
+ const float lub = logf(ub);
+
+ value = expf(llb + ((lub - llb) * value / 127.0f));
+ } else {
+ value = lb + ((ub - lb) * value / 127.0f);
+ }
+ }
+ }
+
+ if (verbose) {
+ printf("%s: %s MIDI controller %d=%d -> control in %ld=%f\n", myName,
+ instance->friendly_name, event->data.control.param,
+ event->data.control.value, controlIn, value);
+ }
+
+ pluginControlIns[controlIn] = value;
+ pluginPortUpdated[controlIn] = 1;
+}
+
diff --git a/native/jni/midi-dssi/dssi_data.h b/native/jni/midi-dssi/dssi_data.h
new file mode 100644
index 000000000..8278f7b9e
--- /dev/null
+++ b/native/jni/midi-dssi/dssi_data.h
@@ -0,0 +1,121 @@
+/* dssi_data.h - DSSI data
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <jni.h>
+#include <dssi.h>
+#include <jack/jack.h>
+#include <alsa/asoundlib.h>
+#include <alsa/seq.h>
+
+#include <stdio.h>
+
+#include "target_native.h"
+#include "target_native_misc.h"
+#include "../classpath/jcl.h"
+
+/* Specify the size of the circular buffer. It only needs to be big
+ enough to hold the events that happen between jack callbacks (~
+ 1/40th of a second). */
+#define EVENT_BUFFER_SIZE 1024
+
+/* Helper macros for going between pointers and jlongs. */
+#define JLONG_TO_PTR(T,P) ((T *)(long)P)
+#define PTR_TO_JLONG(P) ((jlong)(long)P)
+
+
+/* Every DSSI Synthesizer has one of these associated with it. The
+ Java class sees it as a "long" handle. */
+
+typedef struct
+{
+ /* This is a handle to the dlopen'ed .so file containing the DSSI
+ synthesizer. */
+ void *dlhandle;
+
+ /* The function to call to get the DSS_Descriptor. */
+ DSSI_Descriptor_Function fn;
+
+ /* The descriptor for this synthesizer. See the dssi.h system
+ header. */
+ const DSSI_Descriptor *desc;
+
+ /* We currently open a jack client connection for every
+ synthesizer. */
+ jack_client_t *jack_client;
+
+ /* We currently only handle stereo jack connections. Output from
+ mono synthesizers is sent to both left and right ports. */
+ jack_port_t *jack_left_output_port;
+ jack_port_t *jack_right_output_port;
+
+ /* We use a circular buffer to hold MIDI events before processing
+ them in the jack audio processing callback function. */
+ snd_seq_event_t midiEventBuffer[EVENT_BUFFER_SIZE];
+ int midiEventReadIndex;
+ int midiEventWriteIndex;
+
+ /* This is a handle the synthesizers underlying LADSPA structure.
+ See the ladspa.h system header for details. */
+ LADSPA_Handle plugin_handle;
+
+ /* These are buffers we pass to the DSSI Synthesizer for
+ filling. */
+ float *left_buffer;
+ float *right_buffer;
+
+ /* The number of input controls for this synth. */
+ unsigned control_count;
+
+ /* An array of control values, control_count in length. */
+ LADSPA_Data *control_values;
+
+ /* A mapping of MIDI controllers to control values. There are a
+ maximum of 128 MIDI controllers. */
+ unsigned control_value_map[128];
+
+ /* A mapping of MIDI controllers to LADSPA ports. There are a
+ maximum of 128 MIDI controllers. */
+ unsigned control_port_map[128];
+
+ /* The sample rate. */
+ jack_nframes_t sample_rate;
+
+} dssi_data;
+
diff --git a/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c b/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c
new file mode 100644
index 000000000..3cad45931
--- /dev/null
+++ b/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c
@@ -0,0 +1,139 @@
+/* gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c - DSSI Provider
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <config.h>
+#include <gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h>
+
+#include "dssi_data.h"
+
+void
+Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlclose_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)), jlong sohandle)
+{
+ dssi_data *data = (dssi_data *) (long) sohandle;
+ dlclose (data->dlhandle);
+ JCL_free (env, data);
+}
+
+jlong
+Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlopen_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)), jstring name)
+{
+ const char *filename;
+ void *handle;
+ DSSI_Descriptor_Function fn;
+ dssi_data *data = 0;
+
+ filename = JCL_jstring_to_cstring (env, name);
+ if (filename == NULL)
+ return (0);
+
+ handle = dlopen(filename, RTLD_NOW);
+
+ if (handle == 0)
+ goto done;
+
+ fn = (DSSI_Descriptor_Function) dlsym(handle, "dssi_descriptor");
+
+ if (fn == 0)
+ {
+ dlclose(handle);
+ goto done;
+ }
+
+ data = (dssi_data *) JCL_malloc(env, sizeof(dssi_data));
+ data->dlhandle = handle;
+ data->fn = fn;
+ data->midiEventReadIndex = 0;
+ data->midiEventWriteIndex = 0;
+
+ done:
+ JCL_free_cstring (env, name, filename);
+ return PTR_TO_JLONG(data);
+}
+
+jlong
+Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIHandle_1
+ (JNIEnv *env __attribute__((unused)),
+ jclass clazz __attribute__((unused)), jlong handle, jlong index)
+{
+ dssi_data *data = JLONG_TO_PTR(dssi_data,handle);
+ data->desc = (data->fn)(index);
+ return PTR_TO_JLONG(data->desc);
+}
+
+jstring
+Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIName_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
+{
+ DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
+ const char *str = desc->LADSPA_Plugin->Name;
+
+ return (*env)->NewStringUTF (env, str);
+}
+
+jstring
+Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSICopyright_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
+{
+ DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
+ const char *str = desc->LADSPA_Plugin->Copyright;
+
+ return (*env)->NewStringUTF (env, str);
+}
+
+jstring
+Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIVendor_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
+{
+ DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
+ const char *str = desc->LADSPA_Plugin->Maker;
+
+ return (*env)->NewStringUTF (env, str);
+}
+
+jstring
+Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSILabel_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
+{
+ DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
+ const char *str = desc->LADSPA_Plugin->Label;
+
+ return (*env)->NewStringUTF (env, str);
+}
+
+
diff --git a/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c b/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
new file mode 100644
index 000000000..ec1477ec8
--- /dev/null
+++ b/native/jni/midi-dssi/gnu_javax_sound_midi_dssi_DSSISynthesizer.c
@@ -0,0 +1,584 @@
+/* gnu_javax_sound_midi_dssi_DSSISynthesizer.c - DSSI Synth
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+/* The original get_port_default() and set_control() routines were
+ * copied from the DSSI source distribution and are covered by the
+ * following copyright and license...
+ *
+ * Copyright 2004 Chris Cannam, Steve Harris and Sean Bolton.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * for any purpose is hereby granted without fee, provided that the
+ * above copyright notice and this permission notice are included in
+ * all copies or substantial portions of the software.
+ */
+
+#include <config.h>
+#include <gnu_javax_sound_midi_dssi_DSSISynthesizer.h>
+#include <math.h>
+
+#include "dssi_data.h"
+
+/* Define this for debug output. */
+#undef DEBUG_DSSI_PROVIDER
+
+static void set_control (dssi_data *data, snd_seq_event_t *event);
+
+
+/**
+ * The jack callback routine.
+ *
+ * This function is called by the jack audio system in its own thread
+ * whenever it needs new audio data.
+ *
+ */
+static int
+process (jack_nframes_t nframes, void *arg)
+{
+ dssi_data *data = (dssi_data *) arg;
+ int index;
+ jack_default_audio_sample_t *buffer;
+
+ /* Look through the event buffer to see if any control values
+ need changing. */
+ for ( index = data->midiEventReadIndex;
+ index != data->midiEventWriteIndex;
+ index = (index + 1) % EVENT_BUFFER_SIZE)
+ {
+ if (data->midiEventBuffer[index].type == SND_SEQ_EVENT_CONTROLLER)
+ set_control (data, & data->midiEventBuffer[index]);
+ }
+
+ if (data->desc->run_synth)
+ {
+ /* Call the synth audio processing routine. */
+ data->desc->run_synth
+ (data->plugin_handle,
+ nframes,
+ &data->midiEventBuffer[data->midiEventReadIndex],
+ data->midiEventWriteIndex - data->midiEventReadIndex);
+ }
+ else
+ if (data->desc->run_multiple_synths)
+ {
+ snd_seq_event_t *events =
+ &data->midiEventBuffer[data->midiEventReadIndex];
+ unsigned long event_count =
+ data->midiEventWriteIndex - data->midiEventReadIndex;
+
+ /* Call the synth audio processing routine. */
+ data->desc->run_multiple_synths
+ (1,
+ & (data->plugin_handle),
+ nframes,
+ &events,
+ &event_count);
+ }
+
+ /* Update the read index on our circular buffer. */
+ data->midiEventReadIndex = data->midiEventWriteIndex;
+
+ /* Copy output from the synth to jack.
+
+ FIXME: This is hack that only gets one channel from the synth and
+ send that to both jack ports (until we handle stero synths
+ properly).
+
+ FIXME: Can we avoid this copying? */
+ buffer = jack_port_get_buffer(data->jack_left_output_port, nframes);
+ memcpy (buffer, data->left_buffer, nframes * sizeof(LADSPA_Data));
+ buffer = jack_port_get_buffer(data->jack_right_output_port, nframes);
+ memcpy (buffer, data->left_buffer, nframes * sizeof(LADSPA_Data));
+
+ return 0;
+}
+
+
+/**
+ * Calculate a reasonable default value for a specific control port.
+ * This is mostly copied from the DSSI example code. Copyright info
+ * is found at the top of this file.
+ *
+ */
+static LADSPA_Data
+get_port_default (const LADSPA_Descriptor *plugin,
+ int port, jack_nframes_t sample_rate)
+{
+ LADSPA_PortRangeHint hint = plugin->PortRangeHints[port];
+ float lower = hint.LowerBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor) ? sample_rate : 1.0f);
+ float upper = hint.UpperBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor) ? sample_rate : 1.0f);
+
+ if (!LADSPA_IS_HINT_HAS_DEFAULT(hint.HintDescriptor))
+ {
+ if (!LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) ||
+ !LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor))
+ {
+ /* No hint, its not bounded, wild guess */
+ return 0.0f;
+ }
+
+ if (lower <= 0.0f && upper >= 0.0f)
+ {
+ /* It spans 0.0, 0.0 is often a good guess */
+ return 0.0f;
+ }
+
+ /* No clues, return minimum */
+ return lower;
+ }
+
+ /* Try all the easy ones */
+
+ if (LADSPA_IS_HINT_DEFAULT_0(hint.HintDescriptor))
+ return 0.0f;
+ else if (LADSPA_IS_HINT_DEFAULT_1(hint.HintDescriptor))
+ return 1.0f;
+ else if (LADSPA_IS_HINT_DEFAULT_100(hint.HintDescriptor))
+ return 100.0f;
+ else if (LADSPA_IS_HINT_DEFAULT_440(hint.HintDescriptor))
+ return 440.0f;
+
+ /* All the others require some bounds */
+
+ if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)
+ && (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint.HintDescriptor)))
+ return lower;
+
+ if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor))
+ {
+ if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint.HintDescriptor))
+ return upper;
+
+ if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor))
+ {
+ if (LADSPA_IS_HINT_DEFAULT_LOW(hint.HintDescriptor))
+ return lower * 0.75f + upper * 0.25f;
+ else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint.HintDescriptor))
+ return lower * 0.5f + upper * 0.5f;
+ else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint.HintDescriptor))
+ return lower * 0.25f + upper * 0.75f;
+ }
+ }
+
+ /* fallback */
+ return 0.0f;
+}
+
+/**
+ * Set a control value by mapping the MIDI event to a suitable value
+ * for this control.
+ * This is mostly copied from the DSSI example code. Copyright info
+ * is found at the top of this file.
+ *
+ */
+static void
+set_control(dssi_data *data, snd_seq_event_t *event)
+{
+ unsigned control = event->data.control.param;
+ unsigned port = data->control_port_map[control];
+
+ const LADSPA_Descriptor *p = data->desc->LADSPA_Plugin;
+
+ LADSPA_PortRangeHintDescriptor d = p->PortRangeHints[port].HintDescriptor;
+
+ LADSPA_Data lb = p->PortRangeHints[port].LowerBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(p->PortRangeHints[port].HintDescriptor) ?
+ data->sample_rate : 1.0f);
+
+ LADSPA_Data ub = p->PortRangeHints[port].UpperBound *
+ (LADSPA_IS_HINT_SAMPLE_RATE(p->PortRangeHints[port].HintDescriptor) ?
+ data->sample_rate : 1.0f);
+
+ float value = (float)event->data.control.value;
+
+ if (!LADSPA_IS_HINT_BOUNDED_BELOW(d))
+ {
+ if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d))
+ {
+ /* unbounded: might as well leave the value alone. */
+ }
+ else
+ {
+ /* bounded above only. just shift the range. */
+ value = ub - 127.0f + value;
+ }
+ }
+ else
+ {
+ if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d))
+ {
+ /* bounded below only. just shift the range. */
+ value = lb + value;
+ }
+ else
+ {
+ /* bounded both ends. more interesting. */
+ if (LADSPA_IS_HINT_LOGARITHMIC(d))
+ {
+ const float llb = logf(lb);
+ const float lub = logf(ub);
+
+ value = expf(llb + ((lub - llb) * value / 127.0f));
+ }
+ else
+ {
+ value = lb + ((ub - lb) * value / 127.0f);
+ }
+ }
+ }
+
+#ifdef DEBUG_DSSI_PROVIDER
+ printf("MIDI controller %d=%d -> control in %u=%f\n",
+ event->data.control.param,
+ event->data.control.value,
+ data->control_value_map[control], value);
+#endif
+
+ data->control_values[data->control_value_map[control]] = value;
+}
+
+/**
+ * Open a new synthesizer. This currently involves instantiating a
+ * new synth, creating a new jack client connection, and activating
+ * both.
+ *
+ */
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_open_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
+{
+ unsigned int port_count, j, cindex;
+ const char **ports;
+ int controller = 0;
+ dssi_data *data = (dssi_data *) (long) handle;
+ if ((data->jack_client = jack_client_new (data->desc->LADSPA_Plugin->Label)) == 0)
+ {
+ /* JCL_ThrowException (env, "javax/sound/midi/MidiUnavailableException", */
+ JCL_ThrowException (env, "java/io/IOException",
+ "can't create jack client");
+ return;
+ }
+
+ /* Get the jack sample rate, which may be used in default control port
+ value calculations. */
+ data->sample_rate = jack_get_sample_rate (data->jack_client);
+
+ data->plugin_handle =
+ (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin,
+ data->sample_rate);
+
+ if (jack_set_process_callback (data->jack_client, process, data) != 0)
+ {
+ JCL_ThrowException (env, "java/io/IOException",
+ "can't set jack process callback");
+ return;
+ }
+
+ data->jack_left_output_port =
+ jack_port_register (data->jack_client, "output_left",
+ JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
+ data->jack_right_output_port =
+ jack_port_register (data->jack_client, "output_right",
+ JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
+
+ /* Count the number of controls and audio ouput ports. */
+ port_count = data->control_count = 0;
+ for (j = 0; j < data->desc->LADSPA_Plugin->PortCount; j++)
+ {
+ LADSPA_PortDescriptor pod =
+ data->desc->LADSPA_Plugin->PortDescriptors[j];
+
+ if (LADSPA_IS_PORT_AUDIO(pod) && LADSPA_IS_PORT_OUTPUT(pod))
+ port_count++;
+ else if (LADSPA_IS_PORT_CONTROL(pod) && LADSPA_IS_PORT_INPUT(pod))
+ data->control_count++;
+ }
+
+ /* Allocate the array of control values. */
+ data->control_values =
+ (LADSPA_Data *) JCL_malloc (env,
+ data->control_count * sizeof (LADSPA_Data));
+
+ /* Initialize the MIDI control map. */
+ memset (data->control_value_map, 0, data->control_count * sizeof(unsigned));
+
+ /* Create buffers for each port. */
+ for (cindex = 0, j = 0; j < data->desc->LADSPA_Plugin->PortCount; j++)
+ {
+ LADSPA_PortDescriptor pod =
+ data->desc->LADSPA_Plugin->PortDescriptors[j];
+ if (LADSPA_IS_PORT_AUDIO(pod) && LADSPA_IS_PORT_OUTPUT(pod))
+ {
+ data->left_buffer =
+ (float *) calloc(jack_get_buffer_size(data->jack_client),
+ sizeof(float));
+ (data->desc->LADSPA_Plugin->connect_port)(data->plugin_handle, j,
+ data->left_buffer);
+ }
+ else
+ if (LADSPA_IS_PORT_CONTROL(pod) && LADSPA_IS_PORT_INPUT(pod))
+ {
+ /* This is an input control port. Connect it to a properly
+ initialized value in our controller value array. */
+ (data->desc->LADSPA_Plugin->connect_port)
+ (data->plugin_handle, j, &(data->control_values[cindex]));
+ data->control_values[cindex] =
+ get_port_default (data->desc->LADSPA_Plugin,
+ j, data->sample_rate);
+
+ /* Set up the mapping between MIDI controllers and this
+ contoller value. */
+ if (data->desc->get_midi_controller_for_port)
+ {
+ controller = data->desc->
+ get_midi_controller_for_port(data->plugin_handle, j);
+
+ if ((controller != DSSI_NONE) && DSSI_IS_CC(controller))
+ {
+ data->control_value_map[DSSI_CC_NUMBER(controller)] = cindex;
+ data->control_port_map[DSSI_CC_NUMBER(controller)] = j;
+
+#ifdef DEBUG_DSSI_PROVIDER
+ printf ("MIDI Controller 0x%x [%s] = %g\n",
+ DSSI_CC_NUMBER(controller),
+ data->desc->LADSPA_Plugin->PortNames[j],
+ data->control_values[cindex]);
+#endif
+ }
+ }
+
+ cindex++;
+ }
+ }
+
+ (data->desc->LADSPA_Plugin->activate)(data->plugin_handle);
+
+ if (jack_activate (data->jack_client))
+ JCL_ThrowException (env, "java/io/IOException",
+ "can't activate jack client");
+
+ /* Try to connect the synth output to hardware audio ports. */
+ ports = jack_get_ports (data->jack_client, NULL, NULL,
+ JackPortIsPhysical | JackPortIsInput);
+ if (ports)
+ {
+ if (ports[0] && ports[1])
+ {
+ /* Don't bother checking return values. Failing is OK. */
+ jack_connect (data->jack_client,
+ jack_port_name (data->jack_left_output_port),
+ ports[0]);
+ jack_connect (data->jack_client,
+ jack_port_name (data->jack_right_output_port),
+ ports[1]);
+ }
+ free(ports);
+ }
+}
+
+/**
+ * This is called when we receive a new MIDI CONTROL CHANGE message.
+ * Simply stick an appropriate event in the event buffer. This will
+ * get processed in the jack callback function.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_controlChange_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle, jint channel, jint control, jint value)
+{
+ dssi_data *data = JLONG_TO_PTR(dssi_data,handle);
+
+ /* Insert this event in the event buffer. */
+ snd_seq_event_t *ev = & data->midiEventBuffer[data->midiEventWriteIndex];
+
+ /* Set the event value. */
+ snd_seq_ev_set_controller (ev, channel, control, value);
+
+ data->midiEventWriteIndex =
+ (data->midiEventWriteIndex + 1) % EVENT_BUFFER_SIZE;
+}
+
+/**
+ * This is called when we receive a new MIDI NOTE ON message. Simply
+ * stick an appropriate event in the event buffer. This will get
+ * processed in the jack callback function.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOn_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle, jint channel, jint note, jint velocity)
+{
+ dssi_data *data = JLONG_TO_PTR(dssi_data,handle);
+
+ /* Insert this event in the event buffer. */
+ snd_seq_event_t *ev = & data->midiEventBuffer[data->midiEventWriteIndex];
+
+ ev->type = SND_SEQ_EVENT_NOTEON;
+ ev->data.control.channel = channel;
+ ev->data.note.note = note;
+ ev->data.note.velocity = velocity;
+
+ data->midiEventWriteIndex =
+ (data->midiEventWriteIndex + 1) % EVENT_BUFFER_SIZE;
+}
+
+/**
+ * This is called when we receive a new MIDI NOTE OFF message. Simply
+ * stick an appropriate event in the event buffer. This will get
+ * processed in the jack callback function.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_noteOff_1
+ (JNIEnv *env __attribute__((unused)),
+ jclass clazz __attribute__((unused)),
+ jlong handle, jint channel, jint note, jint velocity)
+{
+ dssi_data *data = JLONG_TO_PTR(dssi_data,handle);
+
+ /* Insert this event in the event buffer. */
+ snd_seq_event_t *ev = & data->midiEventBuffer[data->midiEventWriteIndex];
+
+ ev->type = SND_SEQ_EVENT_NOTEOFF;
+ ev->data.control.channel = channel;
+ ev->data.note.note = note;
+ ev->data.note.velocity = velocity;
+
+ data->midiEventWriteIndex =
+ (data->midiEventWriteIndex + 1) % EVENT_BUFFER_SIZE;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_setPolyPressure_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle __attribute__((unused)), jint channel __attribute__((unused)),
+ jint note __attribute__((unused)), jint velocity __attribute__((unused)))
+{
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getPolyPressure_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle __attribute__((unused)), jint channel __attribute__((unused)),
+ jint note __attribute__((unused)))
+{
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_close_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle __attribute__((unused)))
+{
+}
+
+/* FIXME: These next three functions are really inefficient because
+ we're instantiating and cleaning up plugin instances just to query
+ values. */
+
+JNIEXPORT jstring JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramName_1
+ (JNIEnv *env, jclass clazz __attribute__((unused)),
+ jlong handle, jint index)
+{
+ LADSPA_Handle lhandle;
+ jstring name = (jstring) NULL;
+ dssi_data *data = JLONG_TO_PTR(dssi_data, handle);
+ if (data->desc->get_program == NULL)
+ return NULL;
+ lhandle =
+ (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin,
+ 48000);
+ const DSSI_Program_Descriptor *program =
+ (data->desc->get_program)(lhandle, (unsigned long) index);
+ if (program)
+ name = (*env)->NewStringUTF (env, program->Name);
+ (data->desc->LADSPA_Plugin->cleanup)(lhandle);
+
+ return name;
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramBank_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle, jint index)
+{
+ LADSPA_Handle lhandle;
+ jint result = -1;
+ dssi_data *data = JLONG_TO_PTR(dssi_data, handle);
+ lhandle =
+ (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin,
+ 48000);
+ const DSSI_Program_Descriptor *program =
+ (data->desc->get_program)(lhandle, (unsigned long) index);
+ if (program)
+ result = (jint) program->Bank;
+ (data->desc->LADSPA_Plugin->cleanup)(lhandle);
+ return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_getProgramProgram_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle, jint index)
+{
+ LADSPA_Handle lhandle;
+ jint result = -1;
+ dssi_data *data = JLONG_TO_PTR(dssi_data, handle);
+ lhandle =
+ (data->desc->LADSPA_Plugin->instantiate)(data->desc->LADSPA_Plugin,
+ 48000);
+ const DSSI_Program_Descriptor *program =
+ (data->desc->get_program)(lhandle, (unsigned long) index);
+ if (program)
+ result = (jint) program->Program;
+ (data->desc->LADSPA_Plugin->cleanup)(lhandle);
+ return result;
+}
+
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_midi_dssi_DSSISynthesizer_selectProgram_1
+ (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)),
+ jlong handle, jint bank, jint program)
+{
+ dssi_data *data = JLONG_TO_PTR(dssi_data, handle);
+
+ (data->desc->select_program)(data->plugin_handle,
+ (unsigned) bank, (unsigned) program);
+}
diff --git a/native/jni/qt-peer/Makefile.am b/native/jni/qt-peer/Makefile.am
index b2dc92979..031d58fee 100644
--- a/native/jni/qt-peer/Makefile.am
+++ b/native/jni/qt-peer/Makefile.am
@@ -1,7 +1,7 @@
# Qt AWT backend for Classpath
#
-pkglib_LTLIBRARIES = libqtpeer.la
+nativelib_LTLIBRARIES = libqtpeer.la
AM_LDFLAGS = @CLASSPATH_MODULE@ @QT_LIBS@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/native/jni/xmlj/Makefile.am b/native/jni/xmlj/Makefile.am
index b0f1f9104..2cb914586 100644
--- a/native/jni/xmlj/Makefile.am
+++ b/native/jni/xmlj/Makefile.am
@@ -1,4 +1,4 @@
-pkglib_LTLIBRARIES = libxmlj.la
+nativelib_LTLIBRARIES = libxmlj.la
libxmlj_la_SOURCES = \
xmlj_dom.c \
diff --git a/org/ietf/jgss/GSSCredential.java b/org/ietf/jgss/GSSCredential.java
index 724825d5e..bdf149710 100644
--- a/org/ietf/jgss/GSSCredential.java
+++ b/org/ietf/jgss/GSSCredential.java
@@ -331,4 +331,14 @@ public interface GSSCredential extends Cloneable
* @return True if this object equals the other.
*/
boolean equals(Object another);
+
+ /**
+ * Return the hash code of this credential. When overriding {@link #equals},
+ * it is necessary to override hashCode() as well.
+ *
+ * @return the hash code that must be the same for two credentials if
+ * {@link #equals} returns true.
+ */
+ int hashCode();
+
}
diff --git a/org/ietf/jgss/GSSName.java b/org/ietf/jgss/GSSName.java
index 5550697b5..ee3209dd0 100644
--- a/org/ietf/jgss/GSSName.java
+++ b/org/ietf/jgss/GSSName.java
@@ -201,6 +201,15 @@ public interface GSSName
boolean equals(Object another);
/**
+ * Return the hashcode of this GSSName. When overriding {@link #equals},
+ * it is normally necessary to override hashCode() as well.
+ *
+ * @return the hash code that must be the same for two names if {@link #equals}
+ * returns true.
+ */
+ int hashCode();
+
+ /**
* Creates a mechanism name (MN) from an arbitrary internal name. This
* is equivalent to using the factory methods {@link
* GSSManager#createName(java.lang.String,org.ietf.jgss.Oid,org.ietf.jgss.Oid)}
diff --git a/org/omg/CORBA/ACTIVITY_COMPLETED.java b/org/omg/CORBA/ACTIVITY_COMPLETED.java
new file mode 100644
index 000000000..ea234e620
--- /dev/null
+++ b/org/omg/CORBA/ACTIVITY_COMPLETED.java
@@ -0,0 +1,102 @@
+/* ACTIVITY_COMPLETED.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * The ACTIVITY_COMPLETED indicates that the Activity context in which the
+ * method call was made has been completed due to a timeout of either the
+ * Activity itself or a transaction that encompasses the Activity. It also
+ * may mean that the Activity is completed in a manner other than that
+ * originally requested.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ACTIVITY_COMPLETED
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = 463786710302308798L;
+
+ /**
+ * Creates ACTIVITY_COMPLETED with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public ACTIVITY_COMPLETED(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates ACTIVITY_COMPLETED with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public ACTIVITY_COMPLETED()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a ACTIVITY_COMPLETED exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public ACTIVITY_COMPLETED(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created ACTIVITY_COMPLETED exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public ACTIVITY_COMPLETED(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/ACTIVITY_REQUIRED.java b/org/omg/CORBA/ACTIVITY_REQUIRED.java
new file mode 100644
index 000000000..c0c72b524
--- /dev/null
+++ b/org/omg/CORBA/ACTIVITY_REQUIRED.java
@@ -0,0 +1,100 @@
+/* ACTIVITY_REQUIRED.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * The ACTIVITY_REQUIRED system exception indicates that an Activity context was
+ * necessary to perform the invoked operation, but one was not found
+ * associated with the calling thread.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ACTIVITY_REQUIRED
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = -5684213471781455027L;
+
+ /**
+ * Creates ACTIVITY_REQUIRED with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public ACTIVITY_REQUIRED(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates ACTIVITY_REQUIRED with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public ACTIVITY_REQUIRED()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a ACTIVITY_REQUIRED exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public ACTIVITY_REQUIRED(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created ACTIVITY_REQUIRED exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public ACTIVITY_REQUIRED(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/AnyHolder.java b/org/omg/CORBA/AnyHolder.java
index 0055fdd74..10f828aab 100644
--- a/org/omg/CORBA/AnyHolder.java
+++ b/org/omg/CORBA/AnyHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -55,7 +55,7 @@ public final class AnyHolder
/**
* The default type code for this holder.
*/
- private static final TypeCode t_any = new primitiveTypeCode(TCKind.tk_any);
+ private static final TypeCode t_any = new PrimitiveTypeCode(TCKind.tk_any);
/**
* The instance of {@link Any} (not the "any value"), held by this holder.
diff --git a/org/omg/CORBA/AnySeqHelper.java b/org/omg/CORBA/AnySeqHelper.java
index 5c45bb3d8..8ebae7a19 100644
--- a/org/omg/CORBA/AnySeqHelper.java
+++ b/org/omg/CORBA/AnySeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -130,7 +130,7 @@ public abstract class AnySeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_any);
+ return new ArrayTypeCode(TCKind.tk_any);
}
/**
diff --git a/org/omg/CORBA/AnySeqHolder.java b/org/omg/CORBA/AnySeqHolder.java
index 905e05c8b..b18a1457b 100644
--- a/org/omg/CORBA/AnySeqHolder.java
+++ b/org/omg/CORBA/AnySeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class AnySeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_any);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_any);
/**
* Constructs an instance of AnySeqHolder,
diff --git a/org/omg/CORBA/BAD_OPERATION.java b/org/omg/CORBA/BAD_OPERATION.java
index 26b340665..2649f2a6d 100755
--- a/org/omg/CORBA/BAD_OPERATION.java
+++ b/org/omg/CORBA/BAD_OPERATION.java
@@ -41,8 +41,76 @@ package org.omg.CORBA;
import java.io.Serializable;
/**
- * Means that the object exists but does not support the operation that
- * was invoked on it.
+ * Means that the object exists but does not support the operation that was
+ * invoked on it.
+ *
+ * In GNU Classpath, this exception may have the following Minor codes:
+ *
+ * <table border="1">
+ * <tr>
+ * <th>Hex</th>
+ * <th>Dec</th>
+ * <th>Minor</th>
+ * <th>Name</th>
+ * <th>Case</th>
+ * </tr>
+ * <tr>
+ * <td>47430000</td>
+ * <td>1195573248 </td>
+ * <td>0</td>
+ * <td>Method</td>
+ * <td> The remote side requested to invoke the method that is not available on
+ * that target (client and server probably disagree in the object definition).
+ * This code is set when the problem arises in the Classpath core; the idlj and
+ * rmic may generate the user code that sets 0x0 or other value.</td>
+ * </tr>
+ * <tr>
+ * <td>47430009</td>
+ * <td>1195573257</td>
+ * <td>9</td>
+ * <td>Any</td>
+ * <td> Attempt to extract from the Any value of the different type that was
+ * stored into that Any. </td>
+ * </tr>
+ * <tr>
+ * <td>4743000a</td>
+ * <td>1195573258</td>
+ * <td>10</td>
+ * <td>Activation</td>
+ * <td>Failed to activate the inactive object due any reason.</td>
+ * </tr>
+ * <tr>
+ * <td>4743000b</td>
+ * <td>1195573259</td>
+ * <td>11</td>
+ * <td>Policy</td>
+ * <td> The policies, applying to ORB or POA prevent the requested operation.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>4743000c</td>
+ * <td>1195573260</td>
+ * <td>12</td>
+ * <td>Socket</td>
+ * <td> Socket related errors like failure to open socket on the expected port.</td>
+ * </tr>
+ * <tr>
+ * <td>4743000e</td>
+ * <td>1195573262</td>
+ * <td>14</td>
+ * <td>Enumeration</td>
+ * <td> The passed value for enumeration is outside the valid range for that
+ * enumeration. </td>
+ * </tr>
+ * <tr>
+ * <td>4743000f</td>
+ * <td>1195573263</td>
+ * <td>15</td>
+ * <td>PolicyType</td>
+ * <td> The passed policy code is outside the valid range of the possible
+ * policies for the given policy type. </td>
+ * </tr>
+ * </table>
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
@@ -50,14 +118,15 @@ public class BAD_OPERATION
extends SystemException
implements Serializable
{
- /**
- * Use serialVersionUID for interoperability.
+ /**
+ * Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1654621651720499682L;
/**
- * Creates a BAD_OPERATION with the default minor code of 0,
- * completion state COMPLETED_NO and the given explaining message.
+ * Creates a BAD_OPERATION with the default minor code of 0, completion state
+ * COMPLETED_NO and the given explaining message.
+ *
* @param reasom the explaining message.
*/
public BAD_OPERATION(String message)
@@ -66,16 +135,18 @@ public class BAD_OPERATION
}
/**
- * Creates BAD_OPERATION with the default minor code of 0 and a
- * completion state COMPLETED_NO.
+ * Creates BAD_OPERATION with the default minor code of 0 and a completion
+ * state COMPLETED_NO.
*/
public BAD_OPERATION()
{
super("", 0, CompletionStatus.COMPLETED_NO);
}
- /** Creates a BAD_OPERATION exception with the specified minor
- * code and completion status.
+ /**
+ * Creates a BAD_OPERATION exception with the specified minor code and
+ * completion status.
+ *
* @param minor additional error code.
* @param completed the method completion status.
*/
@@ -86,6 +157,7 @@ public class BAD_OPERATION
/**
* Created BAD_OPERATION exception, providing full information.
+ *
* @param reason explaining message.
* @param minor additional error code (the "minor").
* @param completed the method completion status.
diff --git a/org/omg/CORBA/BAD_QOS.java b/org/omg/CORBA/BAD_QOS.java
new file mode 100644
index 000000000..ba8a0df32
--- /dev/null
+++ b/org/omg/CORBA/BAD_QOS.java
@@ -0,0 +1,99 @@
+/* BAD_QOS.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * The BAD_QOS is raised when the object cannot support the quality of
+ * service required by an invocation parameter.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class BAD_QOS
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = 4746597571263117454L;
+
+ /**
+ * Creates BAD_QOS with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public BAD_QOS(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates BAD_QOS with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public BAD_QOS()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a BAD_QOS exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public BAD_QOS(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created BAD_QOS exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public BAD_QOS(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/BooleanHolder.java b/org/omg/CORBA/BooleanHolder.java
index eddc62933..73cfeb296 100644
--- a/org/omg/CORBA/BooleanHolder.java
+++ b/org/omg/CORBA/BooleanHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,7 +62,7 @@ public final class BooleanHolder
* The default type code for this holder.
*/
private static final TypeCode t_boolean =
- new primitiveTypeCode(TCKind.tk_boolean);
+ new PrimitiveTypeCode(TCKind.tk_boolean);
/**
* The <code>boolean</code> (CORBA <code>boolean</code>) value,
diff --git a/org/omg/CORBA/BooleanSeqHelper.java b/org/omg/CORBA/BooleanSeqHelper.java
index d1fde8b77..41f93d10d 100644
--- a/org/omg/CORBA/BooleanSeqHelper.java
+++ b/org/omg/CORBA/BooleanSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class BooleanSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_boolean);
+ return new ArrayTypeCode(TCKind.tk_boolean);
}
/**
diff --git a/org/omg/CORBA/BooleanSeqHolder.java b/org/omg/CORBA/BooleanSeqHolder.java
index ac8224f92..bdec3b792 100644
--- a/org/omg/CORBA/BooleanSeqHolder.java
+++ b/org/omg/CORBA/BooleanSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class BooleanSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_boolean);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_boolean);
/**
* Constructs an instance of BooleanSeqHolder,
diff --git a/org/omg/CORBA/ByteHolder.java b/org/omg/CORBA/ByteHolder.java
index 0cfd8f03c..c440822e5 100644
--- a/org/omg/CORBA/ByteHolder.java
+++ b/org/omg/CORBA/ByteHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,7 +62,7 @@ public final class ByteHolder
* The default type code for this holder.
*/
private static final TypeCode t_octet =
- new primitiveTypeCode(TCKind.tk_octet);
+ new PrimitiveTypeCode(TCKind.tk_octet);
/**
* The <code>byte</code> (CORBA <code>octet</code>) value,
diff --git a/org/omg/CORBA/CODESET_INCOMPATIBLE.java b/org/omg/CORBA/CODESET_INCOMPATIBLE.java
new file mode 100644
index 000000000..41ccaf492
--- /dev/null
+++ b/org/omg/CORBA/CODESET_INCOMPATIBLE.java
@@ -0,0 +1,103 @@
+/* CODESET_INCOMPATIBLE.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * Raised when client and server are unable to reach any consensus on which
+ * code set should be used to represent the characters. This happens when
+ * neither server nor client cannot convert from the native code set of the
+ * corresponding side, there is no shared codeset from that both sides could
+ * convert and additionally the client and server* native sets are too
+ * different to communicate anyway without the massive data loss.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class CODESET_INCOMPATIBLE
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = -8784048396454171789L;
+
+ /**
+ * Creates CODESET_INCOMPATIBLE with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public CODESET_INCOMPATIBLE(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates CODESET_INCOMPATIBLE with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public CODESET_INCOMPATIBLE()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a CODESET_INCOMPATIBLE exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public CODESET_INCOMPATIBLE(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created CODESET_INCOMPATIBLE exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public CODESET_INCOMPATIBLE(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/CharHolder.java b/org/omg/CORBA/CharHolder.java
index 67eb2ee87..b8d0a3d6a 100644
--- a/org/omg/CORBA/CharHolder.java
+++ b/org/omg/CORBA/CharHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -61,7 +61,7 @@ public final class CharHolder
/**
* The default type code for this holder.
*/
- private static final TypeCode t_char = new primitiveTypeCode(TCKind.tk_char);
+ private static final TypeCode t_char = new PrimitiveTypeCode(TCKind.tk_char);
/**
* The <code>char</code> (CORBA <code>char</code>) value,
diff --git a/org/omg/CORBA/CharSeqHelper.java b/org/omg/CORBA/CharSeqHelper.java
index b91306c2c..08406058c 100644
--- a/org/omg/CORBA/CharSeqHelper.java
+++ b/org/omg/CORBA/CharSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class CharSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_char);
+ return new ArrayTypeCode(TCKind.tk_char);
}
/**
diff --git a/org/omg/CORBA/CharSeqHolder.java b/org/omg/CORBA/CharSeqHolder.java
index dc7d0a840..a60483b5f 100644
--- a/org/omg/CORBA/CharSeqHolder.java
+++ b/org/omg/CORBA/CharSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class CharSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_char);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_char);
/**
* Constructs an instance of CharSeqHolder,
diff --git a/org/omg/CORBA/CompletionStatus.java b/org/omg/CORBA/CompletionStatus.java
index f9f370443..1ddcca287 100644
--- a/org/omg/CORBA/CompletionStatus.java
+++ b/org/omg/CORBA/CompletionStatus.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.Minor;
+
import java.io.Serializable;
import org.omg.CORBA.portable.IDLEntity;
@@ -108,6 +110,7 @@ public class CompletionStatus
/**
* Returns the CompletionStatus, matching the given integer constant
+ *
* @param completion one of COMPLETED_YES, COMPLETED_NO or COMPLEED_MAYBE.
* @return one of COMPLETED_YES, COMPLETED_NO or COMPLEED_MAYBE.
* @throws BAD_PARAM if the parameter is not one of these three valid values.
@@ -116,11 +119,14 @@ public class CompletionStatus
{
try
{
- return states [ completion ];
+ return states[completion];
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid completion status " + completion);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid completion status "
+ + completion);
+ bad.minor = Minor.Enumeration;
+ throw bad;
}
}
diff --git a/org/omg/CORBA/CompletionStatusHelper.java b/org/omg/CORBA/CompletionStatusHelper.java
index f62857448..43b6b8c10 100644
--- a/org/omg/CORBA/CompletionStatusHelper.java
+++ b/org/omg/CORBA/CompletionStatusHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -131,7 +131,7 @@ public abstract class CompletionStatusHelper
new String[] { "COMPLETED_YES", "COMPLETED_NO", "COMPLETED_MAYBE" };
typeCode =
- Restricted_ORB.Singleton.create_enum_tc(id(), "CompletionStatus",
+ OrbRestricted.Singleton.create_enum_tc(id(), "CompletionStatus",
members
);
}
diff --git a/org/omg/CORBA/DefinitionKindHelper.java b/org/omg/CORBA/DefinitionKindHelper.java
index d9c7cc15a..fddbb585a 100644
--- a/org/omg/CORBA/DefinitionKindHelper.java
+++ b/org/omg/CORBA/DefinitionKindHelper.java
@@ -39,9 +39,9 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.DefinitionKindHolder;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.gnuAny;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -97,7 +97,7 @@ public abstract class DefinitionKindHelper
};
typeCode =
- Restricted_ORB.Singleton.create_enum_tc(id(), "DefinitionKind",
+ OrbRestricted.Singleton.create_enum_tc(id(), "DefinitionKind",
members
);
}
diff --git a/org/omg/CORBA/DoubleHolder.java b/org/omg/CORBA/DoubleHolder.java
index efee74b0f..65c8ebaf5 100644
--- a/org/omg/CORBA/DoubleHolder.java
+++ b/org/omg/CORBA/DoubleHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,7 +62,7 @@ public final class DoubleHolder
* The default type code for this holder.
*/
private static final TypeCode t_double =
- new primitiveTypeCode(TCKind.tk_double);
+ new PrimitiveTypeCode(TCKind.tk_double);
/**
* The <code>double</code> (CORBA <code>double</code>) value,
diff --git a/org/omg/CORBA/DoubleSeqHelper.java b/org/omg/CORBA/DoubleSeqHelper.java
index d8dffbf4c..2d9423fd0 100644
--- a/org/omg/CORBA/DoubleSeqHelper.java
+++ b/org/omg/CORBA/DoubleSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class DoubleSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_double);
+ return new ArrayTypeCode(TCKind.tk_double);
}
/**
diff --git a/org/omg/CORBA/DoubleSeqHolder.java b/org/omg/CORBA/DoubleSeqHolder.java
index a6828e1c1..619e9215b 100644
--- a/org/omg/CORBA/DoubleSeqHolder.java
+++ b/org/omg/CORBA/DoubleSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class DoubleSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_double);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_double);
/**
* Constructs an instance of DoubleSeqHolder,
diff --git a/org/omg/CORBA/DynamicImplementation.java b/org/omg/CORBA/DynamicImplementation.java
index 3bcf93d42..3b1b44319 100644
--- a/org/omg/CORBA/DynamicImplementation.java
+++ b/org/omg/CORBA/DynamicImplementation.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.Unexpected;
+import gnu.CORBA.gnuAny;
+import gnu.CORBA.gnuNVList;
+
import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.OutputStream;
/**
* This class was probably originally thinked as a base of all CORBA
@@ -51,18 +56,110 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class DynamicImplementation
+public class DynamicImplementation
extends ObjectImpl
{
/**
- * Invoke the method of the CORBA object.
- *
+ * Invoke the method of the CORBA object. After converting the parameters,
+ * this method delegates call to the {@link ObjectImpl#invoke}.
+ *
* @deprecated since 1.4.
- *
- * @param request the container for both passing and returing the
- * parameters, also contains the method name and thrown exceptions.
+ *
+ * @param request the container for both passing and returing the parameters,
+ * also contains the method name and thrown exceptions.
*/
- public abstract void invoke(ServerRequest request);
+ public void invoke(ServerRequest request)
+ {
+ Request r = _request(request.operation());
+
+ // Copy the parameters.
+ NVList args = new gnuNVList();
+ request.arguments(args);
+ NamedValue v;
+ int i = 0;
+
+ try
+ {
+ // Set the arguments.
+ for (i = 0; i < args.count(); i++)
+ {
+ v = args.item(i);
+ Any n;
+ OutputStream out;
+
+ switch (v.flags())
+ {
+ case ARG_IN.value:
+ out = v.value().create_output_stream();
+ v.value().write_value(out);
+ n = r.add_named_in_arg(v.name());
+ n.read_value(out.create_input_stream(), v.value().type());
+ break;
+ case ARG_INOUT.value:
+ out = v.value().create_output_stream();
+ v.value().write_value(out);
+ n = r.add_named_inout_arg(v.name());
+ n.read_value(out.create_input_stream(), v.value().type());
+ break;
+ case ARG_OUT.value:
+ r.add_named_out_arg(v.name());
+ break;
+
+ default:
+ throw new InternalError("Invalid flags " + v.flags());
+ }
+ }
+ }
+ catch (Bounds b)
+ {
+ throw new Unexpected(args.count() + "[" + i + "]", b);
+ }
+
+ // Set context.
+ r.ctx(request.ctx());
+
+ // Set the return type (expects that the ServerRequest will initialise
+ // the passed Any.
+
+ gnuAny g = new gnuAny();
+ request.result(g);
+ r.set_return_type(g.type());
+
+ // Invoke the method.
+ r.invoke();
+
+ // Transfer the returned values.
+ NVList r_args = r.arguments();
+
+ try
+ {
+ // API states that the ServerRequest.arguments must be called only
+ // once. Hence we assume we can just modify the previously returned
+ // value <code>args</code>, and the ServerRequest will preserve the
+ // reference.
+ for (i = 0; i < args.count(); i++)
+ {
+ v = args.item(i);
+
+ if (v.flags() == ARG_OUT.value || v.flags() == ARG_INOUT.value)
+ {
+ OutputStream out = r_args.item(i).value().create_output_stream();
+ r_args.item(i).value().write_value(out);
+ v.value().read_value(out.create_input_stream(),
+ v.value().type());
+ }
+ }
+ }
+ catch (Bounds b)
+ {
+ throw new Unexpected(args.count() + "[" + i + "]", b);
+ }
+
+ // Set the returned result (if any).
+ NamedValue returns = r.result();
+ if (returns != null)
+ request.set_result(returns.value());
+ }
/**
* Returns the array of the repository ids, supported by this object.
diff --git a/org/omg/CORBA/FieldNameHelper.java b/org/omg/CORBA/FieldNameHelper.java
index a35df4f35..6d6de43da 100644
--- a/org/omg/CORBA/FieldNameHelper.java
+++ b/org/omg/CORBA/FieldNameHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -80,7 +80,7 @@ public abstract class FieldNameHelper
*/
public static TypeCode type()
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "FieldName", orb.create_string_tc(0));
}
diff --git a/org/omg/CORBA/FixedHolder.java b/org/omg/CORBA/FixedHolder.java
index c3918a08d..8913acc17 100644
--- a/org/omg/CORBA/FixedHolder.java
+++ b/org/omg/CORBA/FixedHolder.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.fixedTypeCode;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.FixedTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import java.math.BigDecimal;
@@ -108,7 +108,7 @@ public final class FixedHolder
*/
public TypeCode _type()
{
- return new fixedTypeCode(value);
+ return new FixedTypeCode(value);
}
/**
diff --git a/org/omg/CORBA/FloatHolder.java b/org/omg/CORBA/FloatHolder.java
index 059953faf..1d6de16a1 100644
--- a/org/omg/CORBA/FloatHolder.java
+++ b/org/omg/CORBA/FloatHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,7 +62,7 @@ public final class FloatHolder
* The default type code for this holder.
*/
private static final TypeCode t_float =
- new primitiveTypeCode(TCKind.tk_float);
+ new PrimitiveTypeCode(TCKind.tk_float);
/**
* The <code>float</code> (CORBA <code>float</code>) value,
diff --git a/org/omg/CORBA/FloatSeqHelper.java b/org/omg/CORBA/FloatSeqHelper.java
index 9f7630c3f..1656dae44 100644
--- a/org/omg/CORBA/FloatSeqHelper.java
+++ b/org/omg/CORBA/FloatSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class FloatSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_float);
+ return new ArrayTypeCode(TCKind.tk_float);
}
/**
diff --git a/org/omg/CORBA/FloatSeqHolder.java b/org/omg/CORBA/FloatSeqHolder.java
index 24c760333..dbab1ec08 100644
--- a/org/omg/CORBA/FloatSeqHolder.java
+++ b/org/omg/CORBA/FloatSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class FloatSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_float);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_float);
/**
* Constructs an instance of FloatSeqHolder,
diff --git a/org/omg/CORBA/IDLTypeHelper.java b/org/omg/CORBA/IDLTypeHelper.java
index d9ca36496..635168eb8 100644
--- a/org/omg/CORBA/IDLTypeHelper.java
+++ b/org/omg/CORBA/IDLTypeHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
@@ -84,7 +84,7 @@ public abstract class IDLTypeHelper
if (typeCode == null)
{
typeCode =
- Restricted_ORB.Singleton.create_interface_tc(IDLTypeHelper.id(),
+ OrbRestricted.Singleton.create_interface_tc(IDLTypeHelper.id(),
"IDLType"
);
}
diff --git a/org/omg/CORBA/INVALID_ACTIVITY.java b/org/omg/CORBA/INVALID_ACTIVITY.java
new file mode 100644
index 000000000..a6e60d02a
--- /dev/null
+++ b/org/omg/CORBA/INVALID_ACTIVITY.java
@@ -0,0 +1,100 @@
+/* INVALID_ACTIVITY.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * Raised when the transaction or Activity is resumed in a different context
+ * than from which it was suspended. It is also raised when the invocation is
+ * not incompatible with the Activity’s current state.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class INVALID_ACTIVITY
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = 7907846629733712546L;
+
+ /**
+ * Creates INVALID_ACTIVITY with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public INVALID_ACTIVITY(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates INVALID_ACTIVITY with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public INVALID_ACTIVITY()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a INVALID_ACTIVITY exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public INVALID_ACTIVITY(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created INVALID_ACTIVITY exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public INVALID_ACTIVITY(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/IdentifierHelper.java b/org/omg/CORBA/IdentifierHelper.java
index fa2044841..5c055f812 100644
--- a/org/omg/CORBA/IdentifierHelper.java
+++ b/org/omg/CORBA/IdentifierHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -80,7 +80,7 @@ public abstract class IdentifierHelper
*/
public static TypeCode type()
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "Identifier", orb.create_string_tc(0));
}
diff --git a/org/omg/CORBA/IntHolder.java b/org/omg/CORBA/IntHolder.java
index 19822ef76..4729535a7 100644
--- a/org/omg/CORBA/IntHolder.java
+++ b/org/omg/CORBA/IntHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -61,7 +61,7 @@ public final class IntHolder
/**
* The default type code for this holder.
*/
- private static final TypeCode t_long = new primitiveTypeCode(TCKind.tk_long);
+ private static final TypeCode t_long = new PrimitiveTypeCode(TCKind.tk_long);
/**
* The <code>int</code> (CORBA <code>long</code>) value,
diff --git a/org/omg/CORBA/LocalObject.java b/org/omg/CORBA/LocalObject.java
index 4b6ae68af..7c06e1824 100644
--- a/org/omg/CORBA/LocalObject.java
+++ b/org/omg/CORBA/LocalObject.java
@@ -49,6 +49,13 @@ import org.omg.CORBA.NamedValue;
import org.omg.CORBA.Policy;
import org.omg.CORBA.Request;
import org.omg.CORBA.SetOverrideType;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.RemarshalException;
+import org.omg.CORBA.portable.ServantObject;
+
+import javax.rmi.CORBA.Util;
/**
* An object, formally implementing the CORBA {@link Object}, but actually
@@ -141,6 +148,17 @@ public class LocalObject
*
* @throws NO_IMPLEMENT, always.
*/
+ public org.omg.CORBA.Object _get_interface()
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
+
+ /**
+ * This method is not appropriate for the local objects and just
+ * throws an exception.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
public Policy _get_policy(int a_policy_type)
throws BAD_PARAM
{
@@ -232,4 +250,114 @@ public class LocalObject
{
throw new NO_IMPLEMENT(INAPPROPRIATE);
}
+
+ /**
+ * This method is called from <code>rmic</code> generated stubs if the
+ * {@link Util#isLocal()}, called passing <code>this</code> as parameter,
+ * returns true. If the method returns null, the requested method is then
+ * invoked on <code>this</code>. Else it is invoked on the returned object,
+ * casting it into the interface that the local object implements. In this
+ * case, the generated stub also later calls
+ * {@link _servant_postinvoke(ServantObject)}, passing that returned target
+ * as parameter.
+ *
+ * @param operation the name of the method being invoked.
+ * @param expectedType the interface that the returned servant
+ * object must implement.
+ *
+ * @throws NO_IMPLEMENT always. If used, the method must be overridden.
+ */
+ public ServantObject _servant_preinvoke(String operation, Class expectedType)
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
+
+
+ /**
+ * This method is called from <code>rmic</code> generated stubs if the
+ * {@link Util#isLocal()}, called passing <code>this</code> as parameter,
+ * returns true, and the {@link #_servant_preinvoke} return non-null object.
+ * The stub then invokes the requrested method on that returned object and
+ * later calls _servant_postinvoke, passing that returned target as parameter.
+ *
+ * @param servant the object that has served as the invocation target for the
+ * current operation.
+ */
+ public void _servant_postinvoke(ServantObject servant)
+ {
+ }
+
+ /**
+ * Invokes the operation. This method takes the OutputStream that was previously
+ * returned by a {@link _request()} and returns an InputStream which
+ * contains the reply. Up till jdk 1.5 inclusive this method is marked as
+ * unimplemented.
+ *
+ * @throws NO_IMPLEMENT always.
+ */
+ public InputStream _invoke(OutputStream output)
+ throws ApplicationException, RemarshalException
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
+
+ /**
+ * While it may look that this should return true, the jdk 1.5 API states
+ * that it must throw NO_IMPLEMENT instead. The rmi stubs do not call this
+ * method to check if the object is local; they call {@link Util#isLocal()}
+ * instead (passing <code>this</code> as parameter).
+ *
+ * @return never.
+ *
+ * @throws NO_IMPLEMENT always.
+ */
+ public boolean _is_local()
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
+
+
+ /**
+ * This method is not appropriate for the local objects and just
+ * throws an exception.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public ORB _orb()
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
+
+ /**
+ * This method is not appropriate for the local objects and just
+ * throws an exception.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public void _releaseReply(InputStream input)
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
+
+ /**
+ * This method is not appropriate for the local objects and just
+ * throws an exception.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public OutputStream _request(String operation, boolean responseExpected)
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
+
+ /**
+ * This method is not appropriate for the local objects and just
+ * throws an exception.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public boolean validate_connection()
+ {
+ throw new NO_IMPLEMENT(INAPPROPRIATE);
+ }
} \ No newline at end of file
diff --git a/org/omg/CORBA/LongHolder.java b/org/omg/CORBA/LongHolder.java
index c0b14d33b..ac249fed3 100644
--- a/org/omg/CORBA/LongHolder.java
+++ b/org/omg/CORBA/LongHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,7 +62,7 @@ public final class LongHolder
* The default type code for this holder.
*/
private static final TypeCode t_longlong =
- new primitiveTypeCode(TCKind.tk_longlong);
+ new PrimitiveTypeCode(TCKind.tk_longlong);
/**
* The <code>long</code> (CORBA <code>long long</code>) value,
diff --git a/org/omg/CORBA/LongLongSeqHelper.java b/org/omg/CORBA/LongLongSeqHelper.java
index 1d7cde01c..0e31c7136 100644
--- a/org/omg/CORBA/LongLongSeqHelper.java
+++ b/org/omg/CORBA/LongLongSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class LongLongSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_long);
+ return new ArrayTypeCode(TCKind.tk_long);
}
/**
diff --git a/org/omg/CORBA/LongLongSeqHolder.java b/org/omg/CORBA/LongLongSeqHolder.java
index 955790296..e56acd4ad 100644
--- a/org/omg/CORBA/LongLongSeqHolder.java
+++ b/org/omg/CORBA/LongLongSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class LongLongSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_longlong);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_longlong);
/**
* Constructs an instance of LongLongSeqHolder,
diff --git a/org/omg/CORBA/LongSeqHelper.java b/org/omg/CORBA/LongSeqHelper.java
index e98c77920..26b4e91c2 100644
--- a/org/omg/CORBA/LongSeqHelper.java
+++ b/org/omg/CORBA/LongSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class LongSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_long);
+ return new ArrayTypeCode(TCKind.tk_long);
}
/**
diff --git a/org/omg/CORBA/LongSeqHolder.java b/org/omg/CORBA/LongSeqHolder.java
index ac571decd..2359eb0b2 100644
--- a/org/omg/CORBA/LongSeqHolder.java
+++ b/org/omg/CORBA/LongSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -56,8 +56,8 @@ public final class LongSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_long);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_long);
/**
* The <code>int[]</code> (CORBA <code>LongSeq</code>) value,
diff --git a/org/omg/CORBA/MARSHAL.java b/org/omg/CORBA/MARSHAL.java
index 34cfa78f6..2cd92f5a6 100644
--- a/org/omg/CORBA/MARSHAL.java
+++ b/org/omg/CORBA/MARSHAL.java
@@ -41,8 +41,230 @@ package org.omg.CORBA;
import java.io.Serializable;
/**
- * Means that some request or reply from the network has a wrong
- * size or is structurally invalid.
+ * Means that some request or reply from the network has a wrong size or is
+ * structurally invalid. In GNU Classpath, this exception may have the following
+ * minor codes (the high 20 bits being Classpath VMCID):
+ *
+ * <table border="1">
+ * <tr>
+ * <th>Hex</th>
+ * <th>Dec</th>
+ * <th>Minor</th>
+ * <th>Name</th>
+ * <th>Case</th>
+ * </tr>
+ * <tr>
+ * <td>47430001</td>
+ * <td>1195573249</td>
+ * <td>1</td>
+ * <td>Giop</td>
+ * <td>The message being received is not a GIOP message. It does not start from
+ * the expected magic sequence byte[] { 'G', 'I', 'O', 'P' }.</td>
+ * </tr>
+ * <tr>
+ * <td>47430002</td>
+ * <td>1195573250</td>
+ * <td>2</td>
+ * <td>Header</td>
+ * <td>The unexpected IOException while reading or writing the GIOP message
+ * header or the subsequent request or response header</td>
+ * </tr>
+ * <tr>
+ * <td>47430003</td>
+ * <td>1195573251</td>
+ * <td>3</td>
+ * <td>EOF</td>
+ * <td>The data stream ended before reading all expected values from it. This
+ * usually means that the CORBA message is corrupted, but may also indicate that
+ * the server expects the remote method being invoked to have more or different
+ * parameters</td>
+ * </tr>
+ * <tr>
+ * <td>47430005</td>
+ * <td>1195573253</td>
+ * <td>5</td>
+ * <td>CDR</td>
+ * <td>The unexpected IOException while reading or writing the data via Commond
+ * Data Representation stream</td>
+ * </tr>
+ * <tr>
+ * <td>47430006</td>
+ * <td>1195573254 </td>
+ * <td>6</td>
+ * <td>Value</td>
+ * <td>The unexpected IOException while reading or writing the Value type.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>47430007 </td>
+ * <td>1195573255</td>
+ * <td>7</td>
+ * <td>Forwarding</td>
+ * <td>The unexpected IOException while handling request forwarding.</td>
+ * </tr>
+ * <tr>
+ * <td>47430008</td>
+ * <td>1195573256</td>
+ * <td>8</td>
+ * <td>Encapsulation </td>
+ * <td>The unexpected IOException while handling data encapsulation, tagged
+ * components, tagged profiles, etc.</td>
+ * </tr>
+ * <tr>
+ * <td>47430009</td>
+ * <td>1195573257</td>
+ * <td>9 </td>
+ * <td>Any</td>
+ * <td>The unexpected IOException while inserting or extracting data to/from
+ * the Any.</td>
+ * </tr>
+ * <tr>
+ * <td>4743000a</td>
+ * <td>1195573258 </td>
+ * <td>10</td>
+ * <td>UserException</td>
+ * <td>The unexpected UserException in the context where it cannot be handled
+ * as such and must be converted to the SystemException. </td>
+ * </tr>
+ * <tr>
+ * <td>4743000b</td>
+ * <td>1195573259</td>
+ * <td>11</td>
+ * <td>Inappropriate</td>
+ * <td>While the operation could formally be applied to the target, the OMG
+ * standard states that it is actually not applicable. For example, some CORBA
+ * objects like POA are always local and should not be passed to or returned
+ * from the remote side.</td>
+ * </tr>
+ * <tr>
+ * <td>4743000c</td>
+ * <td>1195573260</td>
+ * <td>12</td>
+ * <td>Negative</td>
+ * <td>When reading data, it was discovered that size of the data structure
+ * like string, sequence or character is written as the negative number.</td>
+ * </tr>
+ * <tr>
+ * <td>4743000e</td>
+ * <td>1195573262 </td>
+ * <td>14</td>
+ * <td>Graph</td>
+ * <td>Reference to non-existing node in the data grapth while reading the
+ * value types.</td>
+ * </tr>
+ * <tr>
+ * <td>4743000f</td>
+ * <td>1195573263</td>
+ * <td>15</td>
+ * <td>Boxed</td>
+ * <td>Unexpected exception was thrown from the IDL type helper while handling
+ * the object of this type as a boxed value.</td>
+ * </tr>
+ * <tr>
+ * <td>47430010</td>
+ * <td>1195573264</td>
+ * <td>16</td>
+ * <td>Instantiation</td>
+ * <td>Unable to instantiate an value type object while reading it from the
+ * stream.</td>
+ * </tr>
+ * <tr>
+ * <td>47430011</td>
+ * <td>1195573265</td>
+ * <td>17</td>
+ * <td>ValueHeaderTag</td>
+ * <td>The header tag of the value type being read from the CDR stream contains
+ * an unexpected value outside 0x7fffff00 .. 0x7fffffff and also not null and
+ * not an indirection.</td>
+ * </tr>
+ * <tr>
+ * <td>47430012</td>
+ * <td>1195573266</td>
+ * <td>18</td>
+ * <td>ValueHeaderFlags</td>
+ * <td>The header tag flags of the value type being read from the CDR stream
+ * make the invalid combination (for instance, 0x7fffff04).</td>
+ * </tr>
+ * <tr>
+ * <td>47430013</td>
+ * <td>1195573267</td>
+ * <td>19</td>
+ * <td>ClassCast</td>
+ * <td>The value type class, written on the wire, is not compatible with the
+ * expected class, passed as a parameter to the InputStream.read_value.</td>
+ * </tr>
+ * <tr>
+ * <td>47430014</td>
+ * <td>1195573268</td>
+ * <td>20</td>
+ * <td>Offset</td>
+ * <td>Positive or otherwise invalid indirection offset when reading the data
+ * graph of the value type.</td>
+ * </tr>
+ * <tr>
+ * <td>47430015</td>
+ * <td>1195573269</td>
+ * <td>21</td>
+ * <td>Chunks</td>
+ * <td>Errors while reading the chunked value type.</td>
+ * </tr>
+ * <tr>
+ * <td>47430016</td>
+ * <td>1195573270</td>
+ * <td>22</td>
+ * <td>UnsupportedValue</td>
+ * <td>No means are provided to read or write this value type (not Streamable,
+ * not CustomMarshal, not Serializable, no factory, no helper.</td>
+ * </tr>
+ * <tr>
+ * <td>47430017</td>
+ * <td>1195573271</td>
+ * <td>23</td>
+ * <td>Factory</td>
+ * <td>The value factory, required for the operation being invoked, is not
+ * registered with this ORB.</td>
+ * </tr>
+ * <tr>
+ * <td>47430018</td>
+ * <td>1195573272</td>
+ * <td>24</td>
+ *
+ * <td>UnsupportedAddressing</td>
+ * <td>Unsupported object addressing method in GIOP request header.</td>
+ * </tr>
+ * <tr>
+ * <td>47430019</td>
+ * <td>1195573273</td>
+ * <td>25</td>
+ * <td>IOR</td>
+ * <td>Invalid object reference (IOR).</td>
+ * </tr>
+ * <tr>
+ * <td>4743001a</td>
+ * <td>1195573274</td>
+ * <td>26</td>
+ * <td>TargetConversion</td>
+ * <td>Problems with converting between stubs, ties, interfaces and
+ * implementations.</td>
+ *
+ * </tr>
+ * <tr>
+ * <td>4743001b</td>
+ * <td>1195573275</td>
+ * <td>27</td>
+ * <td>ValueFields</td>
+ * <td>Problems with reading or writing the fields of the value type object
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>4743001c</td>
+ * <td>1195573276</td>
+ * <td>28</td>
+ * <td>NonSerializable</td>
+ * <td>The instance of the value type, passed using RMI over IIOP, is not
+ * serializable</td>
+ * </tr>
+ * </table>
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
@@ -50,14 +272,15 @@ public class MARSHAL
extends SystemException
implements Serializable
{
- /**
+ /**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 7416408250336395546L;
/**
- * Creates a MARSHAL with the default minor code of 0,
- * completion state COMPLETED_NO and the given explaining message.
+ * Creates a MARSHAL with the default minor code of 0, completion state
+ * COMPLETED_NO and the given explaining message.
+ *
* @param reasom the explaining message.
*/
public MARSHAL(String message)
@@ -66,32 +289,35 @@ public class MARSHAL
}
/**
- * Creates MARSHAL with the default minor code of 0 and a
- * completion state COMPLETED_NO.
+ * Creates MARSHAL with the default minor code of 0 and a completion state
+ * COMPLETED_NO.
*/
public MARSHAL()
{
super("", 0, CompletionStatus.COMPLETED_NO);
}
- /** Creates a MARSHAL exception with the specified minor
- * code and completion status.
- * @param minor additional error code.
- * @param completed the method completion status.
+ /**
+ * Creates a MARSHAL exception with the specified minor code and completion
+ * status.
+ *
+ * @param minor_code additional error code.
+ * @param is_completed the method completion status.
*/
- public MARSHAL(int minor, CompletionStatus completed)
+ public MARSHAL(int minor_code, CompletionStatus is_completed)
{
- super("", minor, completed);
+ super("", minor_code, is_completed);
}
/**
* Created MARSHAL exception, providing full information.
+ *
* @param reason explaining message.
- * @param minor additional error code (the "minor").
- * @param completed the method completion status.
+ * @param minor_code additional error code (the "minor").
+ * @param is_completed the method completion status.
*/
- public MARSHAL(String reason, int minor, CompletionStatus completed)
+ public MARSHAL(String reason, int minor_code, CompletionStatus is_completed)
{
- super(reason, minor, completed);
+ super(reason, minor_code, is_completed);
}
}
diff --git a/org/omg/CORBA/NO_RESOURCES.java b/org/omg/CORBA/NO_RESOURCES.java
index 262b8ce1a..013bdb674 100644
--- a/org/omg/CORBA/NO_RESOURCES.java
+++ b/org/omg/CORBA/NO_RESOURCES.java
@@ -41,9 +41,39 @@ package org.omg.CORBA;
import java.io.Serializable;
/**
- * Means that the ORB has reached some general resource limitation like
- * maximal number of the opened connections.
- *
+ * Means that the ORB has reached some general resource limitation like maximal
+ * number of the opened connections.
+ *
+ * In GNU Classpath, this exception may have the following minor codes:
+ *
+ * <table border="1">
+ * <tr>
+ * <td>Hex</td>
+ * <td>Dec</td>
+ * <td>Minor</td>
+ * <td>Name</td>
+ * <td>Case</td>
+ * </tr>
+ * <tr>
+ * <td>47430014</td>
+ * <td>1195573268</td>
+ * <td>20</td>
+ * <td>Ports</td>
+ * <td>No more free ports available for the new objects. The port control, if
+ * turned on, prevents malicios client from knocking the server out by suddenly
+ * requiring to allocate a very large number of objects.</td>
+ * </tr>
+ * <tr>
+ * <td>47430015</td>
+ * <td>1195573269</td>
+ * <td>21</td>
+ * <td>Threads</td>
+ * <td> Too many parallel calls (too many parallel threads). The thread control,
+ * if turned on, prevents malicios client from knocking the server out by
+ * suddenly submitting a very large number of requests. </td>
+ * </tr>
+ * </table>
+ *
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class NO_RESOURCES
@@ -56,8 +86,9 @@ public class NO_RESOURCES
private static final long serialVersionUID = 8129246118235803597L;
/**
- * Creates a NO_RESOURCES with the default minor code of 0,
- * completion state COMPLETED_NO and the given explaining message.
+ * Creates a NO_RESOURCES with the default minor code of 0, completion state
+ * COMPLETED_NO and the given explaining message.
+ *
* @param reasom the explaining message.
*/
public NO_RESOURCES(String message)
@@ -66,32 +97,35 @@ public class NO_RESOURCES
}
/**
- * Creates NO_RESOURCES with the default minor code of 0 and a
- * completion state COMPLETED_NO.
+ * Creates NO_RESOURCES with the default minor code of 0 and a completion
+ * state COMPLETED_NO.
*/
public NO_RESOURCES()
{
super("", 0, CompletionStatus.COMPLETED_NO);
}
- /** Creates a NO_RESOURCES exception with the specified minor
- * code and completion status.
- * @param minor additional error code.
- * @param completed the method completion status.
+ /**
+ * Creates a NO_RESOURCES exception with the specified minor code and
+ * completion status.
+ *
+ * @param a_minor additional error code.
+ * @param a_completed the method completion status.
*/
- public NO_RESOURCES(int minor, CompletionStatus completed)
+ public NO_RESOURCES(int a_minor, CompletionStatus a_completed)
{
- super("", minor, completed);
+ super("", a_minor, a_completed);
}
/**
* Created NO_RESOURCES exception, providing full information.
- * @param reason explaining message.
- * @param minor additional error code (the "minor").
- * @param completed the method completion status.
+ *
+ * @param a_reason explaining message.
+ * @param a_minor additional error code (the "minor").
+ * @param a_completed the method completion status.
*/
- public NO_RESOURCES(String reason, int minor, CompletionStatus completed)
+ public NO_RESOURCES(String a_reason, int a_minor, CompletionStatus a_completed)
{
- super(reason, minor, completed);
+ super(a_reason, a_minor, a_completed);
}
}
diff --git a/org/omg/CORBA/NameValuePairHelper.java b/org/omg/CORBA/NameValuePairHelper.java
index f40e570a7..5d2430b23 100644
--- a/org/omg/CORBA/NameValuePairHelper.java
+++ b/org/omg/CORBA/NameValuePairHelper.java
@@ -39,9 +39,10 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.DynAn.NameValuePairHolder;
-import gnu.CORBA.aliasTypeCode;
-import gnu.CORBA.primitiveTypeCode;
-import gnu.CORBA.stringTypeCode;
+import gnu.CORBA.typecodes.AliasTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
+import gnu.CORBA.Minor;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -75,7 +76,9 @@ public abstract class NameValuePairHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("NameValuePair expected");
+ BAD_OPERATION bad = new BAD_OPERATION("NameValuePair expected");
+ bad.minor = Minor.Any;
+ throw bad;
}
}
@@ -117,12 +120,12 @@ public abstract class NameValuePairHelper
StructMember[] members = new StructMember[ 2 ];
TypeCode t_id =
- new aliasTypeCode(new stringTypeCode(TCKind.tk_string), "", "id");
+ new AliasTypeCode(new StringTypeCode(TCKind.tk_string), "", "id");
members [ 0 ] = new StructMember("id", t_id, null);
members [ 1 ] =
- new StructMember("value", new primitiveTypeCode(TCKind.tk_any), null);
+ new StructMember("value", new PrimitiveTypeCode(TCKind.tk_any), null);
typeCode = ORB.init().create_struct_tc(id(), "NameValuePair", members);
}
diff --git a/org/omg/CORBA/OMGVMCID.java b/org/omg/CORBA/OMGVMCID.java
index 6c7b30810..2b2bd4bc3 100644
--- a/org/omg/CORBA/OMGVMCID.java
+++ b/org/omg/CORBA/OMGVMCID.java
@@ -1,54 +1,72 @@
/* OMGVMCID.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
package org.omg.CORBA;
/**
- * Holds a single constant, specifying, that
- * The vendor minor code ID reserved for the Object Management Group
- * (http://www.omg.org).
+ * </p>
+ * The higher 20 bits of any CORBA exception hold "Vendor Minor Codeset ID"
+ * (VMCID), for instance 0x4F4D0000 (OMG standard), 0x54410000 (TAO), 0x4A430000
+ * (JacORB), 0x49540000 (IONA), 0x53550000 (Sun).
+ * </p>
+ * <p>
+ * GNU Classpath official vendor minor code set id is 0x47430000 ("GC\x00\x00"),
+ * and the reserved space spans till 0x47430FFF, allowing to use up to 4096
+ * Classpath specific exceptions. It was assigned 30/09/2005 by OMG Vice President
+ * Andrew Watson.
+ * </p>
+ * <p>
+ * The standard minor codes for the standard system exceptions are prefaced by
+ * the VMCID assigned to OMG, defined as 0x4F4D0000 (the code of the minor field
+ * for the standard exception with minor code 1 is 0x4F4D0001). Within a vendor
+ * assigned space, the assignment of values to minor codes is left to the
+ * vendor.
+ * </p>
+ *
+ * <p>
+ * The VMCID 0 and 0xFFFFF0000 are reserved for experimental use.
+ * </p>
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public interface OMGVMCID
{
/**
- * The vendor minor code ID (1330446336) reserved for the Object
- * Management Group (http://www.omg.org).
+ * The OMG vendor minor code ID.
*/
- int value = 1330446336;
+ int value = 0x4F4D0000;
}
diff --git a/org/omg/CORBA/ORB.java b/org/omg/CORBA/ORB.java
index ba39b1610..667da2da8 100644
--- a/org/omg/CORBA/ORB.java
+++ b/org/omg/CORBA/ORB.java
@@ -38,13 +38,15 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
-import gnu.CORBA.fixedTypeCode;
-import gnu.CORBA.generalTypeCode;
+import gnu.CORBA.OrbFocused;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.gnuContext;
-import gnu.CORBA.primitiveTypeCode;
-import gnu.CORBA.recordTypeCode;
-import gnu.CORBA.recursiveTypeCode;
+import gnu.CORBA.typecodes.FixedTypeCode;
+import gnu.CORBA.typecodes.GeneralTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.CORBA.typecodes.RecursiveTypeCode;
import org.omg.CORBA.ORBPackage.InconsistentTypeCode;
@@ -58,17 +60,17 @@ import java.io.IOException;
import java.util.Properties;
/**
- * A central class in CORBA implementation, responsible for sending and
- * handling remote invocations. ORB also works as a factory for
- * creating instances of certain CORBA classes.
- *
- * Despite the core library contains the fully working CORBA implementation,
- * it also provides a simple way to plug-in the alternative CORBA support.
- * This is done by replacing the ORB. The alternative ORB can be specified
- * via properties, passed to ORB.Init(...).
- *
- * When creating an ORB instance, the class name
- * is searched in the following locations:
+ * A central class in CORBA implementation, responsible for sending and handling
+ * remote invocations. ORB also works as a factory for creating instances of
+ * certain CORBA classes.
+ *
+ * Despite the core library contains the fully working CORBA implementation, it
+ * also provides a simple way to plug-in the alternative CORBA support. This is
+ * done by replacing the ORB. The alternative ORB can be specified via
+ * properties, passed to ORB.Init(...).
+ *
+ * When creating an ORB instance, the class name is searched in the following
+ * locations:
* <p>
* 1. Applet parameter or application string array, if any.<br>
* 2. The properties parameter, if any.<br>
@@ -76,25 +78,50 @@ import java.util.Properties;
* 4. The orb.properties file located in the user.home directory (if any).<br>
* 5. The orb.properties file located in the java.home/lib directory (if any).
* </p>
- *
- * The supported properties are:
- * <table border="1">
- * <tr><td> org.omg.CORBA.ORBClass</td><td>The class,
- * implementing the functional ORB, returned by
- * {@link #init(Applet, Properties)} or
- * {@link #init(String[], Properties)} </td></tr>
- * <tr><td>org.omg.CORBA.ORBSingletonClass</td><td>The class,
- * implementing the restricted ORB, returned by
- * {@link #init()}.
- * </td></tr>
- * <tr><td>org.omg.CORBA.ORBInitRef</td><td>Specifies the
- * initial reference, accessible by name with the method
- * {@link #resolve_initial_references(String)}.
- * </table>
- * The command line accepts the same properties as a keys. When specifying
- * in the command line, the prefix org.omg.CORBA can be omitted,
- * for instance<code> -ORBInitRef NameService=IOR:aabbccdd....</code>
- *
+ *
+ * The supported properties are: <table border="1">
+ * <tr>
+ * <td> org.omg.CORBA.ORBClass</td>
+ * <td>The class, implementing the functional ORB, returned by
+ * {@link #init(Applet, Properties)} or {@link #init(String[], Properties)}
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>org.omg.CORBA.ORBSingletonClass</td>
+ * <td>The class, implementing the restricted ORB, returned by {@link #init()}.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>org.omg.CORBA.ORBInitRef</td>
+ * <td>Specifies the initial reference, accessible by name with the method
+ * {@link #resolve_initial_references(String)}.</td>
+ * </tr>
+ * <tr>
+ * <td>gnu.CORBA.ListenerPort</td>
+ * <td>Specifies that this ORB should serve all its objects on a single port
+ * (for example, "1234") or on a specified port range (for example,
+ * "1100-1108"). The property is used when working with firewals and serves as a
+ * replacement for the proprietary properties like com.ibm.CORBA.ListenerPort
+ * or com.sun.CORBA.POA.ORBPersistentServerPort. The specified port or range
+ * should not overlap with the values, specified for other ORB's.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>gnu.Corba.SocketFactory</td>
+ * <td>Sets the user-defined server and client socket factory for the ORB being
+ * currently instantiated. Serves as a replacement of the proprietary
+ * property com.sun.CORBA.connection.ORBSocketFactoryClass. To have multiple
+ * types of sockets, instantiate several ORB's with this property each time
+ * set to the different value.
+ * The factory must implement gnu.CORBA.interfaces.SocketFactory.
+ * </td>
+ * </tr>
+ * </table>
+ * <p>The command line accepts the same properties as a keys. When
+ * specifying in the command line, the prefix org.omg.CORBA can be omitted, for
+ * instance<code> -ORBInitRef NameService=IOR:aabbccdd....</code>
+ * </p>
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class ORB
@@ -114,18 +141,21 @@ public abstract class ORB
*/
private static final String RESTRICTED_ORB =
"org.omg.CORBA.ORBSingletonClass";
-
+
+ private static final String LISTENER_PORT =
+ OrbFocused.LISTENER_PORT;
+
/**
* The class, implementing the default fully functional ORB.
*/
private static final String DEFAULT_FUNCTIONAL_ORB =
gnu.CORBA.Poa.ORB_1_4.class.getName();
-
- /**
- * The class, implementing the default restricted ORB.
- */
- private static final String DEFAULT_RESTRICTED_ORB =
- gnu.CORBA.Restricted_ORB.class.getName();
+
+ private static final String DEFAULT_FOCUSED_ORB =
+ gnu.CORBA.OrbFocused.class.getName();
+
+ // There is no need for name of the default restricted ORB as it is
+ // singleton and it is more effectively referred directly.
/**
* Connect the given CORBA object to this ORB. After the object is
@@ -191,11 +221,11 @@ public abstract class ORB
*/
public TypeCode create_recursive_sequence_tc(int bound, int offset)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_struct);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_struct);
for (int i = 0; i < offset; i++)
r.add(new StructMember());
- TypeCode recurs = new primitiveTypeCode(TCKind.tk_sequence);
+ TypeCode recurs = new PrimitiveTypeCode(TCKind.tk_sequence);
r.add(new StructMember("", recurs, null));
return r;
@@ -397,7 +427,7 @@ public abstract class ORB
*/
public TypeCode create_fixed_tc(short digits, short scale)
{
- fixedTypeCode r = new fixedTypeCode();
+ FixedTypeCode r = new FixedTypeCode();
r.setDigits(digits);
r.setScale(scale);
return r;
@@ -617,7 +647,7 @@ public abstract class ORB
*/
public TypeCode create_abstract_interface_tc(String id, String name)
{
- generalTypeCode t = new generalTypeCode(TCKind.tk_abstract_interface);
+ GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_abstract_interface);
t.setName(name);
t.setId(id);
return t;
@@ -633,7 +663,7 @@ public abstract class ORB
*/
public TypeCode create_native_tc(String id, String name)
{
- generalTypeCode t = new generalTypeCode(TCKind.tk_native);
+ GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_native);
t.setName(name);
t.setId(id);
return t;
@@ -649,7 +679,7 @@ public abstract class ORB
*/
public TypeCode create_recursive_tc(String id)
{
- return new recursiveTypeCode(id);
+ return new RecursiveTypeCode(id);
}
/**
@@ -659,7 +689,7 @@ public abstract class ORB
TypeCode boxed_type
)
{
- generalTypeCode t = new generalTypeCode(TCKind.tk_value_box);
+ GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_value_box);
t.setName(name);
t.setId(id);
t.setContentType(boxed_type);
@@ -673,7 +703,7 @@ public abstract class ORB
TypeCode concrete_base, ValueMember[] members
)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_value);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_value);
r.setId(id);
r.setName(name);
r.setTypeModifier(type_modifier);
@@ -780,9 +810,9 @@ public abstract class ORB
*/
public static ORB init()
{
- String orb_cn = getORBName(null, RESTRICTED_ORB);
+ String orb_cn = getCumulatedProperty(null, RESTRICTED_ORB);
if (orb_cn == null)
- return Restricted_ORB.Singleton;
+ return OrbRestricted.Singleton;
else
return createORB(null, orb_cn);
}
@@ -805,6 +835,11 @@ public abstract class ORB
public static ORB init(Applet applet, Properties props)
{
String ocn = applet.getParameter(FUNCTIONAL_ORB);
+ String lp = applet.getParameter(LISTENER_PORT);
+
+ if (ocn==null && lp!=null)
+ ocn = DEFAULT_FOCUSED_ORB;
+
ORB orb = createORB(props, ocn);
orb.set_parameters(applet, props);
@@ -812,40 +847,44 @@ public abstract class ORB
}
/**
- * Creates the working instance of ORB for a
- * standalone application.
- *
- * By default the built-in fully functional ORB is returned. The ORB class
- * is found as described in the header of this class.
- *
+ * Creates the working instance of ORB for a standalone application.
+ *
+ * By default the built-in fully functional ORB is returned. The ORB class is
+ * found as described in the header of this class.
+ *
* @param args the parameters, passed to the applications
- * <code>main(String[] args)</code> method, may be <code>null</code>.
- * The parameter -org.omg.CORBA.ORBClass <class name>
- * if present, defines the used ORB implementation class. If this
- * property is not present, the ORB class is found as described in the
- * class header.
-
- *
+ * <code>main(String[] args)</code> method, may be <code>null</code>. The
+ * parameter -org.omg.CORBA.ORBClass <class name> if present, defines the used
+ * ORB implementation class. If this property is not present, the ORB class is
+ * found as described in the class header.
+ *
* @param props application specific properties, may be <code>null</code>.
- *
+ *
* @return a newly created functional derivative of this abstract class.
*/
public static ORB init(String[] args, Properties props)
{
String ocn = null;
+ String lp = null;
String orbKey = "-" + FUNCTIONAL_ORB;
+ String lpKey = "-" + LISTENER_PORT;
if (args != null)
if (args.length >= 2)
{
for (int i = 0; i < args.length - 1; i++)
{
- if (args [ i ].equals(orbKey))
- ocn = args [ i + 1 ];
+ if (args[i].equals(orbKey))
+ ocn = args[i + 1];
+ if (args[i].equals(lpKey))
+ lp = args[i + 1];
}
}
+ if (lp != null && ocn == null)
+ ocn = DEFAULT_FOCUSED_ORB;
+
ORB orb = createORB(props, ocn);
orb.set_parameters(args, props);
@@ -854,9 +893,9 @@ public abstract class ORB
/**
* List the initially available CORBA objects (services).
- *
+ *
* @return a list of services.
- *
+ *
* @see #resolve_initial_references(String)
*/
public abstract String[] list_initial_services();
@@ -1075,23 +1114,10 @@ public abstract class ORB
protected abstract void set_parameters(Applet app, Properties props);
/**
- * Checks if the communication over network is allowed.
- * @throws java.lang.SecurityException
+ * Get the property with the given name, searching in the standard
+ * places for the ORB properties.
*/
- private static final void checkNetworkingPermission(String host, int port)
- throws SecurityException
- {
- SecurityManager security = System.getSecurityManager();
- if (security != null)
- {
- security.checkConnect(host, port);
- }
- }
-
- /**
- * Get the ORB class name.
- */
- private static String getORBName(Properties props, String property)
+ private static String getCumulatedProperty(Properties props, String property)
{
String orb_cn = null;
@@ -1106,7 +1132,7 @@ public abstract class ORB
if (orb_cn == null)
orb_cn = checkFile(property, "java.home", "lib");
-
+
return orb_cn;
}
@@ -1149,10 +1175,10 @@ public abstract class ORB
/**
* Create ORB when its name is possibly known.
- *
+ *
* @param props properties, possibly containing the ORB name.
- * @param orbClassName the direct ORB class name, overriding
- * other possible locations, or null if not specified.
+ * @param orbClassName the direct ORB class name, overriding other possible
+ * locations, or null if not specified.
*/
private static ORB createORB(Properties props, String orbClassName)
{
@@ -1160,15 +1186,21 @@ public abstract class ORB
if (orbClassName == null)
{
- orbClassName = getORBName(props, FUNCTIONAL_ORB);
+ orbClassName = getCumulatedProperty(props, FUNCTIONAL_ORB);
if (orbClassName == null)
- orbClassName = DEFAULT_FUNCTIONAL_ORB;
+ {
+ String lp = getCumulatedProperty(props, LISTENER_PORT);
+ if (lp != null)
+ orbClassName = DEFAULT_FOCUSED_ORB;
+ else
+ orbClassName = DEFAULT_FUNCTIONAL_ORB;
+ }
}
try
{
- orb = (ORB) Class.forName(orbClassName).newInstance();
+ orb = (ORB) ObjectCreator.forName(orbClassName).newInstance();
}
catch (ClassNotFoundException ex)
{
diff --git a/org/omg/CORBA/ObjectHelper.java b/org/omg/CORBA/ObjectHelper.java
index 1324c621f..220f2dace 100644
--- a/org/omg/CORBA/ObjectHelper.java
+++ b/org/omg/CORBA/ObjectHelper.java
@@ -38,7 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.Minor;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -63,7 +64,9 @@ public abstract class ObjectHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("CORBA object expected");
+ BAD_OPERATION bad = new BAD_OPERATION("CORBA object expected");
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CORBA/ObjectHolder.java b/org/omg/CORBA/ObjectHolder.java
index 27ae67416..f79a89bef 100644
--- a/org/omg/CORBA/ObjectHolder.java
+++ b/org/omg/CORBA/ObjectHolder.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
-import gnu.CORBA.recordTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -63,11 +63,11 @@ public final class ObjectHolder
* The default type code for this holder if the object type code with
* the zero length string as id.
*/
- private static final recordTypeCode t_object;
+ private static final RecordTypeCode t_object;
static
{
- t_object = new recordTypeCode(TCKind.tk_objref);
+ t_object = new RecordTypeCode(TCKind.tk_objref);
t_object.setId("");
}
diff --git a/org/omg/CORBA/OctetSeqHelper.java b/org/omg/CORBA/OctetSeqHelper.java
index 0612ae4e2..df7b22ff5 100644
--- a/org/omg/CORBA/OctetSeqHelper.java
+++ b/org/omg/CORBA/OctetSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class OctetSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_octet);
+ return new ArrayTypeCode(TCKind.tk_octet);
}
/**
diff --git a/org/omg/CORBA/OctetSeqHolder.java b/org/omg/CORBA/OctetSeqHolder.java
index 5092d707e..62ea73819 100644
--- a/org/omg/CORBA/OctetSeqHolder.java
+++ b/org/omg/CORBA/OctetSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class OctetSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_octet);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_octet);
/**
* Constructs an instance of OctetSeqHolder,
diff --git a/org/omg/CORBA/ParameterModeHelper.java b/org/omg/CORBA/ParameterModeHelper.java
index ec75b2bcf..ac17a9235 100644
--- a/org/omg/CORBA/ParameterModeHelper.java
+++ b/org/omg/CORBA/ParameterModeHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -87,7 +87,7 @@ public abstract class ParameterModeHelper
new String[] { "PARAM_IN", "PARAM_OUT", "PARAM_INOUT" };
typeCode =
- Restricted_ORB.Singleton.create_enum_tc(id(), "ParameterMode", members);
+ OrbRestricted.Singleton.create_enum_tc(id(), "ParameterMode", members);
}
return typeCode;
}
diff --git a/org/omg/CORBA/PolicyError.java b/org/omg/CORBA/PolicyError.java
index bd60fbe69..749868a99 100644
--- a/org/omg/CORBA/PolicyError.java
+++ b/org/omg/CORBA/PolicyError.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import org.omg.CORBA.portable.IDLEntity;
+
import java.io.Serializable;
/**
diff --git a/org/omg/CORBA/PolicyErrorCodeHelper.java b/org/omg/CORBA/PolicyErrorCodeHelper.java
new file mode 100644
index 000000000..ab7ac9547
--- /dev/null
+++ b/org/omg/CORBA/PolicyErrorCodeHelper.java
@@ -0,0 +1,115 @@
+/* PolicyErrorCodeHelper.java --
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package org.omg.CORBA;
+
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the policy error code as an alias of
+ * <code>short</code>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class PolicyErrorCodeHelper
+
+{
+
+ /**
+ * Delegates call to {@link Any.extract_short()}.
+ */
+ public static short extract(Any a)
+ {
+ return a.extract_short();
+ }
+
+ /**
+ * Returns policy error code repository id.
+ *
+ * @return "IDL:omg.org/CORBA/PolicyErrorCode:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/PolicyErrorCode:1.0";
+ }
+
+ /**
+ * Delegates call to {@link Any.insert_short(short)}.
+ */
+ public static void insert(Any a, short that)
+ {
+ a.insert_short(that);
+ }
+
+ /**
+ * Delegates call to {@link InputStream.read_short()}.
+ */
+ public static short read(InputStream istream)
+ {
+ return istream.read_short();
+ }
+
+ /**
+ * Returns a typecode of the policy error code, stating it is an alias of
+ * <code>short</code>, named "PolicyErrorCode".
+ *
+ * @return a typecode of synchronization scope.
+ */
+ public static TypeCode type()
+ {
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_alias);
+ r.setName("PolicyErrorCode");
+ r.setId(id());
+ r.setContentType(new PrimitiveTypeCode(TCKind.tk_short));
+ return r;
+ }
+
+ /**
+ * Delegates call to {@link OutputStream.write_short()}.
+ */
+ public static void write(OutputStream ostream, short value)
+ {
+ ostream.write_short(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/PolicyErrorHelper.java b/org/omg/CORBA/PolicyErrorHelper.java
new file mode 100644
index 000000000..49db768cd
--- /dev/null
+++ b/org/omg/CORBA/PolicyErrorHelper.java
@@ -0,0 +1,158 @@
+/* PolicyErrorHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+* The helper operations for the exception {@link PolicyError}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public abstract class PolicyErrorHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Create the PolicyError typecode. The typecode defines a structure, named
+ * "PolicyError", containing the {@link PolicyErrorCode} (alias int) field,
+ * named "reason".
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 1 ];
+
+ TypeCode field;
+
+ field =
+ orb.create_alias_tc("IDL:omg.org/CORBA/PolicyErrorCode:1.0",
+ "PolicyErrorCode", orb.get_primitive_tc(TCKind.tk_short)
+ );
+ members [ 0 ] = new StructMember("reason", field, null);
+ typeCode = orb.create_exception_tc(id(), "PolicyError", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the PolicyError into the given Any.
+ * This method uses the PolicyErrorHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the PolicyError to insert.
+ */
+ public static void insert(Any any, PolicyError that)
+ {
+ any.insert_Streamable(new PolicyErrorHolder(that));
+ }
+
+ /**
+ * Extract the PolicyError from given Any.
+ * This method uses the PolicyErrorHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain PolicyError.
+ */
+ public static PolicyError extract(Any any)
+ {
+ try
+ {
+ return ((PolicyErrorHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("PolicyError expected");
+ bad.minor = Minor.Any;
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the PolicyError repository id.
+ *
+ * @return "IDL:omg.org/CORBA/PolicyError:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/PolicyError:1.0";
+ }
+
+ /**
+ * Read the exception from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static PolicyError read(InputStream input)
+ {
+ // Read the exception repository id.
+ String id = input.read_string();
+ PolicyError value = new PolicyError();
+
+ value.reason = input.read_short();
+ return value;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, PolicyError value)
+ {
+ // Write the exception repository id.
+ output.write_string(id());
+ output.write_short(value.reason);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/PolicyErrorHolder.java b/org/omg/CORBA/PolicyErrorHolder.java
new file mode 100644
index 000000000..8e2c9a8d3
--- /dev/null
+++ b/org/omg/CORBA/PolicyErrorHolder.java
@@ -0,0 +1,103 @@
+/* PolicyErrorHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+* A holder for the exception {@link PolicyError}.
+
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public class PolicyErrorHolder implements Streamable
+{
+ /**
+ * The stored PolicyError value.
+ */
+ public PolicyError value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public PolicyErrorHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public PolicyErrorHolder(PolicyError initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = PolicyErrorHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ PolicyErrorHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the PolicyError.
+ */
+ public TypeCode _type()
+ {
+ return PolicyErrorHelper.type();
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/PolicyHelper.java b/org/omg/CORBA/PolicyHelper.java
index 16b9d94c7..66fb0aa08 100644
--- a/org/omg/CORBA/PolicyHelper.java
+++ b/org/omg/CORBA/PolicyHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -99,7 +101,9 @@ public abstract class PolicyHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Policy expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Policy expected");
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CORBA/PolicyListHelper.java b/org/omg/CORBA/PolicyListHelper.java
index f03836a4f..6e4d329b8 100644
--- a/org/omg/CORBA/PolicyListHelper.java
+++ b/org/omg/CORBA/PolicyListHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -97,7 +99,9 @@ public abstract class PolicyListHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Policy[] expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Policy[] expected");
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CORBA/PrincipalHolder.java b/org/omg/CORBA/PrincipalHolder.java
index 22501a0f7..270427f3f 100644
--- a/org/omg/CORBA/PrincipalHolder.java
+++ b/org/omg/CORBA/PrincipalHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -58,7 +58,7 @@ public final class PrincipalHolder
* The default type code for this holder.
*/
private static final TypeCode t_any =
- new primitiveTypeCode(TCKind.tk_Principal);
+ new PrimitiveTypeCode(TCKind.tk_Principal);
/**
* The instance of {@link Principal}, held by this holder.
diff --git a/org/omg/CORBA/REBIND.java b/org/omg/CORBA/REBIND.java
new file mode 100644
index 000000000..9480906cc
--- /dev/null
+++ b/org/omg/CORBA/REBIND.java
@@ -0,0 +1,99 @@
+/* REBIND.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * Raised on the failure of the requested or implied attempt to
+ * rebind an object reference.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class REBIND
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = 823920851143467547L;
+
+ /**
+ * Creates REBIND with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public REBIND(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates REBIND with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public REBIND()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a REBIND exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public REBIND(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created REBIND exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public REBIND(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/RepositoryIdHelper.java b/org/omg/CORBA/RepositoryIdHelper.java
index 42fb00852..a392002fd 100644
--- a/org/omg/CORBA/RepositoryIdHelper.java
+++ b/org/omg/CORBA/RepositoryIdHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -80,7 +80,7 @@ public abstract class RepositoryIdHelper
*/
public static TypeCode type()
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "RepositoryId", orb.create_string_tc(0));
}
diff --git a/org/omg/CORBA/ServiceDetailHelper.java b/org/omg/CORBA/ServiceDetailHelper.java
index fe0135d97..58000f2c5 100644
--- a/org/omg/CORBA/ServiceDetailHelper.java
+++ b/org/omg/CORBA/ServiceDetailHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.Minor;
import gnu.CORBA.ServiceDetailHolder;
import org.omg.CORBA.portable.InputStream;
@@ -78,7 +79,10 @@ public abstract class ServiceDetailHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CORBA/SetOverrideTypeHelper.java b/org/omg/CORBA/SetOverrideTypeHelper.java
index bfdad683e..1fa1ef868 100644
--- a/org/omg/CORBA/SetOverrideTypeHelper.java
+++ b/org/omg/CORBA/SetOverrideTypeHelper.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.SetOverrideTypeHolder;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -88,7 +88,7 @@ public abstract class SetOverrideTypeHelper
};
typeCode =
- Restricted_ORB.Singleton.create_enum_tc(id(), "SetOverrideType",
+ OrbRestricted.Singleton.create_enum_tc(id(), "SetOverrideType",
members
);
}
diff --git a/org/omg/CORBA/ShortHolder.java b/org/omg/CORBA/ShortHolder.java
index c2e18cb2a..dfc4721f3 100644
--- a/org/omg/CORBA/ShortHolder.java
+++ b/org/omg/CORBA/ShortHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,7 +62,7 @@ public final class ShortHolder
* The default type code for this holder.
*/
private static final TypeCode t_short =
- new primitiveTypeCode(TCKind.tk_short);
+ new PrimitiveTypeCode(TCKind.tk_short);
/**
* The <code>short</code> (CORBA <code>short</code>) value,
diff --git a/org/omg/CORBA/ShortSeqHelper.java b/org/omg/CORBA/ShortSeqHelper.java
index 21eda87d1..40124f216 100644
--- a/org/omg/CORBA/ShortSeqHelper.java
+++ b/org/omg/CORBA/ShortSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class ShortSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_short);
+ return new ArrayTypeCode(TCKind.tk_short);
}
/**
diff --git a/org/omg/CORBA/ShortSeqHolder.java b/org/omg/CORBA/ShortSeqHolder.java
index 183db3a57..246d1ecf4 100644
--- a/org/omg/CORBA/ShortSeqHolder.java
+++ b/org/omg/CORBA/ShortSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class ShortSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_short);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_short);
/**
* Constructs an instance of ShortSeqHolder,
diff --git a/org/omg/CORBA/StringHolder.java b/org/omg/CORBA/StringHolder.java
index 8a637c8e5..ac45c562c 100644
--- a/org/omg/CORBA/StringHolder.java
+++ b/org/omg/CORBA/StringHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.stringTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -61,8 +61,8 @@ public final class StringHolder
/**
* The default type code for this holder.
*/
- private static final stringTypeCode t_string =
- new stringTypeCode(TCKind.tk_string);
+ private static final StringTypeCode t_string =
+ new StringTypeCode(TCKind.tk_string);
/**
* The <code>String</code> (CORBA <code>string</code>) value,
diff --git a/org/omg/CORBA/StringSeqHelper.java b/org/omg/CORBA/StringSeqHelper.java
index 0ae264679..4225c0bd1 100644
--- a/org/omg/CORBA/StringSeqHelper.java
+++ b/org/omg/CORBA/StringSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class StringSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_string);
+ return new ArrayTypeCode(TCKind.tk_string);
}
/**
diff --git a/org/omg/CORBA/StringSeqHolder.java b/org/omg/CORBA/StringSeqHolder.java
index 8e419d233..71ac887e2 100755
--- a/org/omg/CORBA/StringSeqHolder.java
+++ b/org/omg/CORBA/StringSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class StringSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_char);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_char);
/**
* Constructs an instance of StringSeqHolder,
diff --git a/org/omg/CORBA/StringValueHelper.java b/org/omg/CORBA/StringValueHelper.java
index 97d0e7a5d..24e79ce57 100644
--- a/org/omg/CORBA/StringValueHelper.java
+++ b/org/omg/CORBA/StringValueHelper.java
@@ -38,10 +38,9 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
-import gnu.CORBA.gnuAny;
+import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -75,7 +74,7 @@ public class StringValueHelper
* The String typecode.
*/
private static final TypeCode tString =
- Restricted_ORB.Singleton.create_string_tc(0);
+ OrbRestricted.Singleton.create_string_tc(0);
/**
* Returns the String Value repository Id.
@@ -121,7 +120,9 @@ public class StringValueHelper
}
catch (ClassCastException ex)
{
- throw new MARSHAL("String expected");
+ MARSHAL m = new MARSHAL("String expected");
+ m.minor = Minor.ClassCast;
+ throw m;
}
}
@@ -141,7 +142,11 @@ public class StringValueHelper
return an_any.extract_string();
}
else
- throw new BAD_OPERATION("Contains not a string value type");
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("String value type expected");
+ bad.minor = Minor.Any;
+ throw bad;
+ }
}
/**
@@ -177,7 +182,7 @@ public class StringValueHelper
{
if (typecode == null)
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
typecode =
orb.create_value_box_tc(id(), "StringValue", tString);
}
diff --git a/org/omg/CORBA/StructMemberHelper.java b/org/omg/CORBA/StructMemberHelper.java
index 72d66fa91..01445129b 100644
--- a/org/omg/CORBA/StructMemberHelper.java
+++ b/org/omg/CORBA/StructMemberHelper.java
@@ -38,7 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.TypeCodeHelper;
import org.omg.CORBA.portable.InputStream;
@@ -87,7 +88,7 @@ public abstract class StructMemberHelper
{
if (typeCode == null)
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
synchronized (TypeCode.class)
{
@@ -151,6 +152,7 @@ public abstract class StructMemberHelper
catch (UserException ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.UserException;
m.initCause(ex);
throw m;
}
@@ -170,6 +172,7 @@ public abstract class StructMemberHelper
catch (UserException ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.UserException;
m.initCause(ex);
throw m;
}
diff --git a/org/omg/CORBA/SystemException.java b/org/omg/CORBA/SystemException.java
index 85396ee53..dd1936279 100644
--- a/org/omg/CORBA/SystemException.java
+++ b/org/omg/CORBA/SystemException.java
@@ -1,39 +1,39 @@
/* SystemException.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005 Free Software Foundation, Inc.
-This file is part of GNU Classpath.
+ 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 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.
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
+ 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. */
+ 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 org.omg.CORBA;
@@ -42,6 +42,7 @@ import java.io.Serializable;
/**
* The root class for all CORBA standard exceptions.
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class SystemException
@@ -49,8 +50,7 @@ public class SystemException
implements Serializable
{
/**
- * Use serialVersionUID for interoperability.
- * Using the version 1.4 UID.
+ * Use serialVersionUID for interoperability. Using the version 1.4 UID.
*/
private static final long serialVersionUID = -8486391734674855519L;
@@ -60,22 +60,35 @@ public class SystemException
public CompletionStatus completed;
/**
- * The additional exception error code ("minor").
+ * <p>
+ * Contains more details about the exception. The lower 12 bits contain a
+ * code, defining the reason why exception has been thrown. The higher 20 bits
+ * hold "Vendor Minor Codeset ID" (VMCID).
+ * </p>
+ * <p>
+ * The Classpath specifice minor exception codes are documented in the headers
+ * of the corresponding exceptions (for instance, {@link MARSHAL}).
+ * </p>
+ *
+ * The VMCID 0 and 0xfffff are reserved for experimental use.
+ *
+ * @see OMGVMCID
*/
public int minor;
/**
* Constructs an instance of the CORBA standard exception.
- * @param a_reason a string, explaining the reason why the
- * exceptions has been thrown.
+ *
+ * @param a_reason a string, explaining the reason why the exceptions has been
+ * thrown.
* @param a_minor an additional error code (known as the "minor")
* @param a_completed the task completion status.
*/
protected SystemException(String a_reason, int a_minor,
- CompletionStatus a_completed
- )
+ CompletionStatus a_completed)
{
- super(a_reason);
+ super(a_reason + " Minor: " + Integer.toHexString(a_minor) + " ("
+ + (a_minor & 0xFFF) + "). Completed: "+a_completed);
minor = a_minor;
completed = a_completed;
}
diff --git a/org/omg/CORBA/TIMEOUT.java b/org/omg/CORBA/TIMEOUT.java
new file mode 100644
index 000000000..44ae8b31c
--- /dev/null
+++ b/org/omg/CORBA/TIMEOUT.java
@@ -0,0 +1,98 @@
+/* TIMEOUT.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * Raised when no delivery has been made during the specified timeout duration.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class TIMEOUT
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = 4674850648191359518L;
+
+ /**
+ * Creates TIMEOUT with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public TIMEOUT(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates TIMEOUT with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public TIMEOUT()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a TIMEOUT exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public TIMEOUT(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created TIMEOUT exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public TIMEOUT(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/TRANSACTION_MODE.java b/org/omg/CORBA/TRANSACTION_MODE.java
new file mode 100644
index 000000000..5f1981ba4
--- /dev/null
+++ b/org/omg/CORBA/TRANSACTION_MODE.java
@@ -0,0 +1,99 @@
+/* TRANSACTION_MODE.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * Raised when the TransactionPolicy in the IOR is not the same as the current
+ * transaction mode.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class TRANSACTION_MODE
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = 681236728492128745L;
+
+ /**
+ * Creates TRANSACTION_MODE with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public TRANSACTION_MODE(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates TRANSACTION_MODE with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public TRANSACTION_MODE()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a TRANSACTION_MODE exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public TRANSACTION_MODE(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created TRANSACTION_MODE exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public TRANSACTION_MODE(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/TRANSACTION_UNAVAILABLE.java b/org/omg/CORBA/TRANSACTION_UNAVAILABLE.java
new file mode 100644
index 000000000..dc808a23c
--- /dev/null
+++ b/org/omg/CORBA/TRANSACTION_UNAVAILABLE.java
@@ -0,0 +1,99 @@
+/* TRANSACTION_UNAVAILABLE.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import java.io.Serializable;
+
+/**
+ * Raised in response to the abnormal termination of the transaction
+ * service.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class TRANSACTION_UNAVAILABLE
+ extends SystemException
+ implements Serializable
+{
+ /**
+ * Use serialVersionUID (v1.5) for interoperability.
+ */
+ private static final long serialVersionUID = 6340246200933309385L;
+
+ /**
+ * Creates TRANSACTION_UNAVAILABLE with the default minor code of 0,
+ * completion state COMPLETED_NO and the given explaining message.
+ * @param reason the explaining message.
+ */
+ public TRANSACTION_UNAVAILABLE(String message)
+ {
+ super(message, 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Creates TRANSACTION_UNAVAILABLE with the default minor code of 0 and a
+ * completion state COMPLETED_NO.
+ */
+ public TRANSACTION_UNAVAILABLE()
+ {
+ super("", 0, CompletionStatus.COMPLETED_NO);
+ }
+
+ /** Creates a TRANSACTION_UNAVAILABLE exception with the specified minor
+ * code and completion status.
+ * @param minor additional error code.
+ * @param completed the method completion status.
+ */
+ public TRANSACTION_UNAVAILABLE(int minor, CompletionStatus completed)
+ {
+ super("", minor, completed);
+ }
+
+ /**
+ * Created TRANSACTION_UNAVAILABLE exception, providing full information.
+ * @param reason explaining message.
+ * @param minor additional error code (the "minor").
+ * @param completed the method completion status.
+ */
+ public TRANSACTION_UNAVAILABLE(String reason, int minor, CompletionStatus completed)
+ {
+ super(reason, minor, completed);
+ }
+}
diff --git a/org/omg/CORBA/TypeCodeHolder.java b/org/omg/CORBA/TypeCodeHolder.java
index 276e8bf16..bb293376d 100644
--- a/org/omg/CORBA/TypeCodeHolder.java
+++ b/org/omg/CORBA/TypeCodeHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -58,7 +58,7 @@ public class TypeCodeHolder
* The default type code for this holder.
*/
private static final TypeCode t_TypeCode =
- new primitiveTypeCode(TCKind.tk_TypeCode);
+ new PrimitiveTypeCode(TCKind.tk_TypeCode);
/**
* The <code>TypeCode</code> (CORBA <code>TypeCode</code>) value,
diff --git a/org/omg/CORBA/TypeCodePackage/BadKind.java b/org/omg/CORBA/TypeCodePackage/BadKind.java
index 88192f6ad..8ca659d7f 100644
--- a/org/omg/CORBA/TypeCodePackage/BadKind.java
+++ b/org/omg/CORBA/TypeCodePackage/BadKind.java
@@ -40,8 +40,8 @@ package org.omg.CORBA.TypeCodePackage;
import java.io.Serializable;
-import org.omg.CORBA.IDLEntity;
import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
/**
* This exception is thrown when an inappropriate operation is invoked on
diff --git a/org/omg/CORBA/TypeCodePackage/Bounds.java b/org/omg/CORBA/TypeCodePackage/Bounds.java
index cd48706bc..16954e034 100644
--- a/org/omg/CORBA/TypeCodePackage/Bounds.java
+++ b/org/omg/CORBA/TypeCodePackage/Bounds.java
@@ -40,8 +40,8 @@ package org.omg.CORBA.TypeCodePackage;
import java.io.Serializable;
-import org.omg.CORBA.IDLEntity;
import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
/**
* The {@link org.omg.CORBA.TypeCode#member_name(int) },
diff --git a/org/omg/CORBA/ULongLongSeqHelper.java b/org/omg/CORBA/ULongLongSeqHelper.java
index e92409bb0..1148cb408 100644
--- a/org/omg/CORBA/ULongLongSeqHelper.java
+++ b/org/omg/CORBA/ULongLongSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class ULongLongSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_ulong);
+ return new ArrayTypeCode(TCKind.tk_ulong);
}
/**
diff --git a/org/omg/CORBA/ULongLongSeqHolder.java b/org/omg/CORBA/ULongLongSeqHolder.java
index 2d0fcf0b3..70b43bf7f 100644
--- a/org/omg/CORBA/ULongLongSeqHolder.java
+++ b/org/omg/CORBA/ULongLongSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class ULongLongSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_ulonglong);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_ulonglong);
/**
* Constructs an instance of ULongLongSeqHolder,
diff --git a/org/omg/CORBA/ULongSeqHelper.java b/org/omg/CORBA/ULongSeqHelper.java
index 846833c2a..dddc1323d 100644
--- a/org/omg/CORBA/ULongSeqHelper.java
+++ b/org/omg/CORBA/ULongSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class ULongSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_long);
+ return new ArrayTypeCode(TCKind.tk_long);
}
/**
diff --git a/org/omg/CORBA/ULongSeqHolder.java b/org/omg/CORBA/ULongSeqHolder.java
index 8810e2159..64d9db6ce 100644
--- a/org/omg/CORBA/ULongSeqHolder.java
+++ b/org/omg/CORBA/ULongSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class ULongSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_ulong);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_ulong);
/**
* Constructs an instance of ULongSeqHolder,
diff --git a/org/omg/CORBA/UShortSeqHelper.java b/org/omg/CORBA/UShortSeqHelper.java
index 76371bc30..d1fc440a9 100644
--- a/org/omg/CORBA/UShortSeqHelper.java
+++ b/org/omg/CORBA/UShortSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class UShortSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_short);
+ return new ArrayTypeCode(TCKind.tk_short);
}
/**
diff --git a/org/omg/CORBA/UShortSeqHolder.java b/org/omg/CORBA/UShortSeqHolder.java
index 8c6f7d190..47e33b9be 100644
--- a/org/omg/CORBA/UShortSeqHolder.java
+++ b/org/omg/CORBA/UShortSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class UShortSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_ushort);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_ushort);
/**
* Constructs an instance of UShortSeqHolder,
diff --git a/org/omg/CORBA/UnionMemberHelper.java b/org/omg/CORBA/UnionMemberHelper.java
index a49435644..c599542fb 100644
--- a/org/omg/CORBA/UnionMemberHelper.java
+++ b/org/omg/CORBA/UnionMemberHelper.java
@@ -38,7 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.TypeCodeHelper;
import org.omg.CORBA.portable.InputStream;
@@ -97,7 +98,7 @@ public abstract class UnionMemberHelper
}
active = true;
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
StructMember[] members = new StructMember[ 4 ];
TypeCode member;
@@ -152,6 +153,7 @@ public abstract class UnionMemberHelper
catch (UserException ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.UserException;
m.initCause(ex);
throw m;
}
@@ -172,6 +174,7 @@ public abstract class UnionMemberHelper
catch (UserException ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.UserException;
m.initCause(ex);
throw m;
}
diff --git a/org/omg/CORBA/UnknownUserExceptionHelper.java b/org/omg/CORBA/UnknownUserExceptionHelper.java
new file mode 100644
index 000000000..e93dc7403
--- /dev/null
+++ b/org/omg/CORBA/UnknownUserExceptionHelper.java
@@ -0,0 +1,157 @@
+/* UnknownUserExceptionHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+* The helper operations for the exception {@link UnknownUserException}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public abstract class UnknownUserExceptionHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Create the UnknownUserException typecode (structure,
+ * named "UnknownUserException", containing a single field of
+ * type {@link Any}, named "except".
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 1 ];
+
+ TypeCode field;
+
+ field = orb.get_primitive_tc(TCKind.tk_any);
+ members [ 0 ] = new StructMember("except", field, null);
+ typeCode =
+ orb.create_exception_tc(id(), "UnknownUserException", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Insert the UnknownUserException into the given Any.
+ * This method uses the UnknownUserExceptionHolder.
+ *
+ * @param any the Any to insert into.
+ * @param that the UnknownUserException to insert.
+ */
+ public static void insert(Any any, UnknownUserException that)
+ {
+ any.insert_Streamable(new UnknownUserExceptionHolder(that));
+ }
+
+ /**
+ * Extract the UnknownUserException from given Any.
+ * This method uses the UnknownUserExceptionHolder.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain
+ * UnknownUserException.
+ */
+ public static UnknownUserException extract(Any any)
+ {
+ try
+ {
+ return ((UnknownUserExceptionHolder) any.extract_Streamable()).value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("UnknownUserException expected");
+ bad.minor = Minor.Any;
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the UnknownUserException repository id.
+ *
+ * @return "IDL:omg.org/CORBA/UnknownUserException:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/UnknownUserException:1.0";
+ }
+
+ /**
+ * Read the exception from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static UnknownUserException read(InputStream input)
+ {
+ // Read the exception repository id.
+ String id = input.read_string();
+ UnknownUserException value = new UnknownUserException();
+
+ value.except = input.read_any();
+ return value;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, UnknownUserException value)
+ {
+ // Write the exception repository id.
+ output.write_string(id());
+ output.write_any(value.except);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/UnknownUserExceptionHolder.java b/org/omg/CORBA/UnknownUserExceptionHolder.java
new file mode 100644
index 000000000..d7b1ca006
--- /dev/null
+++ b/org/omg/CORBA/UnknownUserExceptionHolder.java
@@ -0,0 +1,103 @@
+/* UnknownUserExceptionHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+* A holder for the exception {@link UnknownUserException}.
+
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public class UnknownUserExceptionHolder implements Streamable
+{
+ /**
+ * The stored UnknownUserException value.
+ */
+ public UnknownUserException value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public UnknownUserExceptionHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public UnknownUserExceptionHolder(UnknownUserException initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = UnknownUserExceptionHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ UnknownUserExceptionHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the UnknownUserException.
+ */
+ public TypeCode _type()
+ {
+ return UnknownUserExceptionHelper.type();
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/ValueBaseHelper.java b/org/omg/CORBA/ValueBaseHelper.java
index 941e9d740..1699d912d 100644
--- a/org/omg/CORBA/ValueBaseHelper.java
+++ b/org/omg/CORBA/ValueBaseHelper.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.CDR.Vio;
-import gnu.CORBA.recordTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -109,7 +109,7 @@ public abstract class ValueBaseHelper
*/
public static TypeCode type()
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_value);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_value);
return r;
}
diff --git a/org/omg/CORBA/ValueMemberHelper.java b/org/omg/CORBA/ValueMemberHelper.java
index 208623c2e..3150af2aa 100644
--- a/org/omg/CORBA/ValueMemberHelper.java
+++ b/org/omg/CORBA/ValueMemberHelper.java
@@ -38,7 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
import gnu.CORBA.TypeCodeHelper;
import org.omg.CORBA.portable.InputStream;
@@ -91,7 +92,7 @@ public abstract class ValueMemberHelper
{
if (typeCode == null)
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
if (active)
{
@@ -177,6 +178,7 @@ public abstract class ValueMemberHelper
catch (UserException ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.UserException;
m.initCause(ex);
throw m;
}
@@ -200,6 +202,7 @@ public abstract class ValueMemberHelper
catch (UserException ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.UserException;
m.initCause(ex);
throw m;
}
diff --git a/org/omg/CORBA/VersionSpecHelper.java b/org/omg/CORBA/VersionSpecHelper.java
index dcdad34e4..984570298 100644
--- a/org/omg/CORBA/VersionSpecHelper.java
+++ b/org/omg/CORBA/VersionSpecHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -80,7 +80,7 @@ public abstract class VersionSpecHelper
*/
public static TypeCode type()
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "VersionSpec", orb.create_string_tc(0));
}
diff --git a/org/omg/CORBA/VisibilityHelper.java b/org/omg/CORBA/VisibilityHelper.java
index 71b572d99..a09e5b686 100644
--- a/org/omg/CORBA/VisibilityHelper.java
+++ b/org/omg/CORBA/VisibilityHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -83,9 +83,9 @@ public abstract class VisibilityHelper
if (typeCode == null)
{
TypeCode tshort =
- Restricted_ORB.Singleton.get_primitive_tc(TCKind.tk_short);
+ OrbRestricted.Singleton.get_primitive_tc(TCKind.tk_short);
typeCode =
- Restricted_ORB.Singleton.create_alias_tc(id(), "Visibility", tshort);
+ OrbRestricted.Singleton.create_alias_tc(id(), "Visibility", tshort);
}
return typeCode;
}
diff --git a/org/omg/CORBA/WCharSeqHelper.java b/org/omg/CORBA/WCharSeqHelper.java
index c12c3de1c..4bb92989d 100644
--- a/org/omg/CORBA/WCharSeqHelper.java
+++ b/org/omg/CORBA/WCharSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -125,7 +125,7 @@ public abstract class WCharSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_char);
+ return new ArrayTypeCode(TCKind.tk_char);
}
/**
diff --git a/org/omg/CORBA/WCharSeqHolder.java b/org/omg/CORBA/WCharSeqHolder.java
index 1b11506a2..72a9cc8c1 100644
--- a/org/omg/CORBA/WCharSeqHolder.java
+++ b/org/omg/CORBA/WCharSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class WCharSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_wchar);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_wchar);
/**
* Constructs an instance of WCharSeqHolder,
diff --git a/org/omg/CORBA/WStringSeqHelper.java b/org/omg/CORBA/WStringSeqHelper.java
index 916c6a250..356cf0dd2 100644
--- a/org/omg/CORBA/WStringSeqHelper.java
+++ b/org/omg/CORBA/WStringSeqHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
@@ -127,7 +127,7 @@ public abstract class WStringSeqHelper
*/
public static TypeCode type()
{
- return new primitiveArrayTypeCode(TCKind.tk_string);
+ return new ArrayTypeCode(TCKind.tk_string);
}
/**
diff --git a/org/omg/CORBA/WStringSeqHolder.java b/org/omg/CORBA/WStringSeqHolder.java
index 474d69a47..68b77ff6a 100755
--- a/org/omg/CORBA/WStringSeqHolder.java
+++ b/org/omg/CORBA/WStringSeqHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.primitiveArrayTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -62,8 +62,8 @@ public final class WStringSeqHolder
/**
* The type code for this holder. Each holder has a different instance.
*/
- private final primitiveArrayTypeCode typecode =
- new primitiveArrayTypeCode(TCKind.tk_wchar);
+ private final ArrayTypeCode typecode =
+ new ArrayTypeCode(TCKind.tk_wchar);
/**
* Constructs an instance of WStringSeqHolder,
diff --git a/org/omg/CORBA/WStringValueHelper.java b/org/omg/CORBA/WStringValueHelper.java
index 7748a6c78..1c63a408e 100644
--- a/org/omg/CORBA/WStringValueHelper.java
+++ b/org/omg/CORBA/WStringValueHelper.java
@@ -38,10 +38,9 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.Restricted_ORB;
-import gnu.CORBA.gnuAny;
+import gnu.CORBA.Minor;
+import gnu.CORBA.OrbRestricted;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -75,7 +74,7 @@ public class WStringValueHelper
* The Wide String typecode.
*/
private static final TypeCode twString =
- Restricted_ORB.Singleton.create_wstring_tc(0);
+ OrbRestricted.Singleton.create_wstring_tc(0);
/**
* Returns the String Value repository Id.
@@ -121,7 +120,9 @@ public class WStringValueHelper
}
catch (ClassCastException ex)
{
- throw new MARSHAL("String expected");
+ MARSHAL m = new MARSHAL("String expected");
+ m.minor = Minor.ClassCast;
+ throw m;
}
}
@@ -141,7 +142,11 @@ public class WStringValueHelper
return an_any.extract_wstring();
}
else
- throw new BAD_OPERATION("Contains not a wide string value type");
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("WString value type expected");
+ bad.minor = Minor.Any;
+ throw bad;
+ }
}
/**
@@ -177,7 +182,7 @@ public class WStringValueHelper
{
if (typecode == null)
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
typecode =
orb.create_value_box_tc(id(), "WStringValue", twString);
}
diff --git a/org/omg/CORBA/WrongTransactionHelper.java b/org/omg/CORBA/WrongTransactionHelper.java
new file mode 100644
index 000000000..5bb5baff2
--- /dev/null
+++ b/org/omg/CORBA/WrongTransactionHelper.java
@@ -0,0 +1,151 @@
+/* WrongTransactionHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+* The helper operations for the exception {@link WrongTransaction}.
+*
+* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+*/
+public abstract class WrongTransactionHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Create the WrongTransaction typecode (structure,
+ * named "WrongTransaction"), no fields.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ ORB orb = ORB.init();
+ StructMember[] members = new StructMember[ 0 ];
+ typeCode = orb.create_exception_tc(id(), "WrongTransaction", members);
+ }
+ return typeCode;
+ }
+
+ /* Every user exception with no user defined
+ fields can use EmptyExceptionHolder */
+
+ /**
+ * Insert the WrongTransaction into the given Any.
+ *
+ * @param any the Any to insert into.
+ * @param that the WrongTransaction to insert.
+ */
+ public static void insert(Any any, WrongTransaction that)
+ {
+ any.insert_Streamable(new EmptyExceptionHolder(that, type()));
+ }
+
+ /**
+ * Extract the WrongTransaction from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain WrongTransaction.
+ */
+ public static WrongTransaction extract(Any any)
+ {
+ try
+ {
+ EmptyExceptionHolder h =
+ (EmptyExceptionHolder) any.extract_Streamable();
+ return (WrongTransaction) h.value;
+ }
+ catch (ClassCastException cex)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("WrongTransaction expected");
+ bad.minor = Minor.Any;
+ bad.initCause(cex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the WrongTransaction repository id.
+ *
+ * @return "IDL:omg.org/CORBA/WrongTransaction:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/WrongTransaction:1.0";
+ }
+
+ /**
+ * Read the exception from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static WrongTransaction read(InputStream input)
+ {
+ // Read the exception repository id.
+ String id = input.read_string();
+ WrongTransaction value = new WrongTransaction(id);
+
+ return value;
+ }
+
+ /**
+ * Write the exception to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, WrongTransaction value)
+ {
+ // Write the exception repository id.
+ output.write_string(id());
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/WrongTransactionHolder.java b/org/omg/CORBA/WrongTransactionHolder.java
new file mode 100644
index 000000000..103724f81
--- /dev/null
+++ b/org/omg/CORBA/WrongTransactionHolder.java
@@ -0,0 +1,103 @@
+/* WrongTransactionHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.CORBA;
+
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for the exception {@link WrongTransaction}.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class WrongTransactionHolder implements Streamable
+{
+ /**
+ * The stored WrongTransaction value.
+ */
+ public WrongTransaction value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public WrongTransactionHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public WrongTransactionHolder(WrongTransaction initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = WrongTransactionHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ WrongTransactionHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the WrongTransaction.
+ */
+ public TypeCode _type()
+ {
+ return WrongTransactionHelper.type();
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/_IDLTypeStub.java b/org/omg/CORBA/_IDLTypeStub.java
index db36fa780..6661b0c47 100644
--- a/org/omg/CORBA/_IDLTypeStub.java
+++ b/org/omg/CORBA/_IDLTypeStub.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.Minor;
import gnu.CORBA.TypeCodeHelper;
import org.omg.CORBA.portable.ApplicationException;
@@ -52,7 +53,7 @@ import java.io.Serializable;
/**
* The stub for the IDL type. This stub can be used to access the
* remote IDL type object, if its IOR is known. To create the
- * working instance with the known IOR, pass {@link gnu.CORBA.IOR_Delegate}
+ * working instance with the known IOR, pass {@link gnu.CORBA.IorDelegate}
* to the constructor.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
@@ -78,7 +79,7 @@ public class _IDLTypeStub
/**
* Create an instance with the given delegate.
*
- * @see gnu.CORBA.IOR_Delegate
+ * @see gnu.CORBA.IorDelegate
*/
public _IDLTypeStub(Delegate delegate)
{
@@ -114,6 +115,7 @@ public class _IDLTypeStub
catch (UserException ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.UserException;
m.initCause(ex);
throw m;
}
diff --git a/org/omg/CORBA/portable/ObjectImpl.java b/org/omg/CORBA/portable/ObjectImpl.java
index 3cf1f4977..f2f21a79e 100644
--- a/org/omg/CORBA/portable/ObjectImpl.java
+++ b/org/omg/CORBA/portable/ObjectImpl.java
@@ -60,9 +60,9 @@ public abstract class ObjectImpl
implements org.omg.CORBA.Object
{
/**
- * The vendor - dependent delegate, responsible for the method implementations.
+ * The delegate, responsible for the method implementations.
*/
- private Delegate delegate;
+ transient Delegate delegate;
/**
* Create a request to invoke the method of this object, specifying
diff --git a/org/omg/CORBA_2_3/ORB.java b/org/omg/CORBA_2_3/ORB.java
index 7a9dc6a1a..82660fea7 100644
--- a/org/omg/CORBA_2_3/ORB.java
+++ b/org/omg/CORBA_2_3/ORB.java
@@ -117,11 +117,9 @@ public abstract class ORB
}
/**
- * Up till OMG 3.0.3 inclusive and also in Suns API till 1.4
- * inclusive this is totally undocumented. No problem, though,
- * because is in addition not implemented.
- *
- * @throws NO_IMPLEMENT, always.
+ * This method is called by RMI-IIOP {@link javax.rmi.Tie#orb(ORB)},
+ * passing <code>this</code> as parameter. The ORB will try to connect
+ * that tie as one of its objects.
*/
public void set_delegate(java.lang.Object wrapper)
{
diff --git a/org/omg/CORBA_2_3/portable/InputStream.java b/org/omg/CORBA_2_3/portable/InputStream.java
index 06ee33e66..23055ef2d 100644
--- a/org/omg/CORBA_2_3/portable/InputStream.java
+++ b/org/omg/CORBA_2_3/portable/InputStream.java
@@ -40,9 +40,9 @@ package org.omg.CORBA_2_3.portable;
import gnu.CORBA.CDR.Vio;
-import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.CustomMarshal;
import org.omg.CORBA.portable.BoxedValueHelper;
-import org.omg.CORBA.portable.ValueFactory;
+import org.omg.CORBA.portable.StreamableValue;
import java.io.Serializable;
@@ -78,12 +78,12 @@ public abstract class InputStream
*/
public Object read_abstract_interface()
{
- boolean isValue = read_boolean();
+ boolean isObject = read_boolean();
- if (isValue)
- return read_value();
- else
+ if (isObject)
return read_Object();
+ else
+ return read_value();
}
/**
@@ -192,11 +192,7 @@ public abstract class InputStream
*/
public Serializable read_value(String repository_id)
{
- ValueFactory factory =
- ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);
- if (factory == null)
- throw new MARSHAL("No factory");
- return (Serializable) Vio.read(this, null, factory);
+ return Vio.read(this, repository_id);
}
/**
diff --git a/org/omg/CORBA_2_3/portable/OutputStream.java b/org/omg/CORBA_2_3/portable/OutputStream.java
index 2ff8c226a..70f9a4913 100644
--- a/org/omg/CORBA_2_3/portable/OutputStream.java
+++ b/org/omg/CORBA_2_3/portable/OutputStream.java
@@ -64,40 +64,40 @@ public abstract class OutputStream
extends org.omg.CORBA.portable.OutputStream
{
/**
- * Writes an abstract interface to the stream. An abstract interface can
- * be eithe CORBA object or value type and is written as a union with
- * the boolean discriminator (false for objects, true for value types).
- *
- * The object from value is separated by fact that all values implement
- * the {@link ValueBase} interface. Also, the passed parameter is treated
- * as value it it does not implement CORBA Object.
- *
+ * Writes an abstract interface to the stream. An abstract interface can be
+ * eithe CORBA object or value type and is written as a union with the boolean
+ * discriminator (false for objects, true for value types).
+ *
+ * The object from value is separated by fact that all values implement the
+ * {@link ValueBase} interface. Also, the passed parameter is treated as value
+ * it it does not implement CORBA Object.
+ *
* @param an_interface an abstract interface to write.
*/
public void write_abstract_interface(java.lang.Object an_interface)
{
- boolean isValue =
- an_interface instanceof ValueBase ||
- (!(an_interface instanceof org.omg.CORBA.Object));
+ boolean isObject = !(an_interface instanceof ValueBase)
+ && an_interface instanceof org.omg.CORBA.Object;
- write_boolean(isValue);
+ write_boolean(isObject);
- if (isValue)
- write_value((ValueBase) an_interface);
- else
+ if (isObject)
write_Object((org.omg.CORBA.Object) an_interface);
+ else
+ write_value((Serializable) an_interface);
+
}
/**
* Writes a value type into the output stream.
- *
- * The value type must implement either {@link CustomValue}
- * (for user-defined writing method) or {@link StramableValue}
- * (for standard writing using code, generated by IDL compiler).
- *
- * The written record will have a repository id, matching the
- * class of the passed object. The codebase will not be written.
- *
+ *
+ * The value type must implement either {@link CustomValue} (for user-defined
+ * writing method) or {@link StramableValue} (for standard writing using code,
+ * generated by IDL compiler).
+ *
+ * The written record will have a repository id, matching the class of the
+ * passed object. The codebase will not be written.
+ *
* @param value a value type object to write.
*/
public void write_value(Serializable value)
@@ -124,7 +124,9 @@ public abstract class OutputStream
* Writes a value type into the output stream, stating it is an
* instance of the given class. The written record
* will have a repository id, matching the passed class.
- * The codebase will not be written.
+ * The codebase will not be written. It the object
+ * being written is an instance of the different class, this results
+ * writing two Id inheritance hierarchy.
*
* The value type must implement either {@link CustomValue}
* (for user-defined writing method) or {@link StramableValue}
@@ -138,15 +140,15 @@ public abstract class OutputStream
}
/**
- * Writes a value type into the output stream,
- * stating it has the given repository id.
- *
- * The value type must implement either {@link CustomValue}
- * (for user-defined writing method) or {@link StramableValue}
- * (for standard writing using code, generated by IDL compiler).
- *
+ * Writes a value type into the output stream, stating it has the given
+ * repository id.
+ *
+ * The value type must implement either {@link CustomValue} (for user-defined
+ * writing method) or {@link StramableValue} (for standard writing using code,
+ * generated by IDL compiler).
+ *
* @param repository_id a repository id of the value type.
- *
+ *
* @param value a value type object to write.
*/
public void write_value(Serializable value, String repository_id)
diff --git a/org/omg/CosNaming/BindingHelper.java b/org/omg/CosNaming/BindingHelper.java
index 1665464ec..b5b420772 100644
--- a/org/omg/CosNaming/BindingHelper.java
+++ b/org/omg/CosNaming/BindingHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -74,7 +76,10 @@ public abstract class BindingHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Binding expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Binding expected");
+ bad.minor = Minor.Any;
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/BindingIteratorHelper.java b/org/omg/CosNaming/BindingIteratorHelper.java
index 204d9f058..64f7b4dfa 100644
--- a/org/omg/CosNaming/BindingIteratorHelper.java
+++ b/org/omg/CosNaming/BindingIteratorHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
@@ -78,6 +80,7 @@ public abstract class BindingIteratorHelper
{
BAD_OPERATION bad = new BAD_OPERATION("Binding iterator expected");
bad.initCause(ex);
+ bad.minor = Minor.Any;
throw bad;
}
}
@@ -121,6 +124,35 @@ public abstract class BindingIteratorHelper
return new _BindingIteratorStub(delegate);
}
}
+
+ /**
+ * Narrow the given object to the BindingIterator. No type-checking is
+ * performed to verify that the object actually supports the requested type.
+ * The {@link BAD_OPERATION} will be thrown if unsupported operations are
+ * invoked on the new returned reference, but no failure is expected at the
+ * time of the unchecked_narrow.
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted binding iterator.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static BindingIterator unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof BindingIterator)
+ return (BindingIterator) obj;
+ else
+ {
+ // Do not call the _is_a(..).
+ Delegate delegate = ((ObjectImpl) obj)._get_delegate();
+ return new _BindingIteratorStub(delegate);
+ }
+ }
/**
* Read the exception from the given CDR stream.
diff --git a/org/omg/CosNaming/BindingIteratorPOA.java b/org/omg/CosNaming/BindingIteratorPOA.java
index 1aa7521fb..988c4ee91 100644
--- a/org/omg/CosNaming/BindingIteratorPOA.java
+++ b/org/omg/CosNaming/BindingIteratorPOA.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.portable.InputStream;
@@ -103,7 +105,8 @@ public abstract class BindingIteratorPOA
out = rh.createReply();
}
else
- throw new BAD_OPERATION(method, 0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(method, Minor.Method,
+ CompletionStatus.COMPLETED_MAYBE);
return out;
}
diff --git a/org/omg/CosNaming/BindingTypeHelper.java b/org/omg/CosNaming/BindingTypeHelper.java
index ede00008e..2f0dc71c4 100644
--- a/org/omg/CosNaming/BindingTypeHelper.java
+++ b/org/omg/CosNaming/BindingTypeHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -71,6 +73,7 @@ public abstract class BindingTypeHelper
{
BAD_OPERATION bad = new BAD_OPERATION("Binding type expected");
bad.initCause(ex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/CosNaming/IstringHelper.java b/org/omg/CosNaming/IstringHelper.java
index 83bbecee5..b90b452e6 100644
--- a/org/omg/CosNaming/IstringHelper.java
+++ b/org/omg/CosNaming/IstringHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CosNaming;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -84,7 +84,7 @@ public abstract class IstringHelper
*/
public static TypeCode type()
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "Istring", orb.create_string_tc(0));
}
diff --git a/org/omg/CosNaming/NameComponentHelper.java b/org/omg/CosNaming/NameComponentHelper.java
index 9f0e1287e..8499edfe6 100644
--- a/org/omg/CosNaming/NameComponentHelper.java
+++ b/org/omg/CosNaming/NameComponentHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -76,6 +78,7 @@ public abstract class NameComponentHelper
{
BAD_OPERATION bad = new BAD_OPERATION("Name component expected");
bad.initCause(ex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/CosNaming/NameHelper.java b/org/omg/CosNaming/NameHelper.java
index 047ad918f..18faf3182 100644
--- a/org/omg/CosNaming/NameHelper.java
+++ b/org/omg/CosNaming/NameHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -77,6 +79,7 @@ public abstract class NameHelper
{
BAD_OPERATION bad = new BAD_OPERATION("Name expected");
bad.initCause(ex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextExtHelper.java b/org/omg/CosNaming/NamingContextExtHelper.java
index 6e2ef060b..86bf8c55d 100644
--- a/org/omg/CosNaming/NamingContextExtHelper.java
+++ b/org/omg/CosNaming/NamingContextExtHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
@@ -78,6 +80,7 @@ public abstract class NamingContextExtHelper
{
BAD_OPERATION bad = new BAD_OPERATION("NamingContextExt expected");
bad.initCause(ex);
+ bad.minor = Minor.Any;
throw bad;
}
}
@@ -122,6 +125,35 @@ public abstract class NamingContextExtHelper
return new _NamingContextExtStub(delegate);
}
}
+
+ /**
+ * Narrow the given object to the NamingContextExt. No type-checking is
+ * performed to verify that the object actually supports the requested type.
+ * The {@link BAD_OPERATION} will be thrown if unsupported operations are
+ * invoked on the new returned reference, but no failure is expected at the
+ * time of the unchecked_narrow.
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted NamingContextExt
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static NamingContextExt unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof NamingContextExt)
+ return (NamingContextExt) obj;
+ else
+ {
+ // Do not call the _is_a(..).
+ Delegate delegate = ((ObjectImpl) obj)._get_delegate();
+ return new _NamingContextExtStub(delegate);
+ }
+ }
/**
* Read the extended naming context from the given CDR input stream.
diff --git a/org/omg/CosNaming/NamingContextExtPOA.java b/org/omg/CosNaming/NamingContextExtPOA.java
index a6d3346f8..cf5d7b3d8 100644
--- a/org/omg/CosNaming/NamingContextExtPOA.java
+++ b/org/omg/CosNaming/NamingContextExtPOA.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.ObjectHelper;
@@ -189,7 +191,7 @@ public abstract class NamingContextExtPOA
OutputStream out = null;
Integer call_method = (Integer) _NamingContextImplBase.methods.get(method);
if (call_method == null)
- throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(Minor.Method, CompletionStatus.COMPLETED_MAYBE);
switch (call_method.intValue())
{
diff --git a/org/omg/CosNaming/NamingContextHelper.java b/org/omg/CosNaming/NamingContextHelper.java
index 3a60d9cb4..fb9b091a6 100644
--- a/org/omg/CosNaming/NamingContextHelper.java
+++ b/org/omg/CosNaming/NamingContextHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
@@ -78,6 +80,7 @@ public abstract class NamingContextHelper
{
BAD_OPERATION bad = new BAD_OPERATION("Naming context expected");
bad.initCause(ex);
+ bad.minor = Minor.Any;
throw bad;
}
}
@@ -130,6 +133,35 @@ public abstract class NamingContextHelper
else
throw new BAD_PARAM();
}
+
+ /**
+ * Narrow the given object to the NamingContext. No type-checking is performed
+ * to verify that the object actually supports the requested type. The
+ * {@link BAD_OPERATION} will be thrown if unsupported operations are invoked
+ * on the new returned reference, but no failure is expected at the time of
+ * the unchecked_narrow.
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted NamingContext.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static NamingContext unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ if (obj == null)
+ return null;
+ else if (obj instanceof NamingContext)
+ return (NamingContext) obj;
+ else
+ {
+ // Do not call the _is_a(..).
+ Delegate delegate = ((ObjectImpl) obj)._get_delegate();
+ return new _NamingContextStub(delegate);
+ }
+ }
/**
* Read the naming context from the given CDR input stream.
diff --git a/org/omg/CosNaming/NamingContextPOA.java b/org/omg/CosNaming/NamingContextPOA.java
index a2db0ad35..a97888276 100644
--- a/org/omg/CosNaming/NamingContextPOA.java
+++ b/org/omg/CosNaming/NamingContextPOA.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.ObjectHelper;
@@ -92,7 +94,7 @@ public abstract class NamingContextPOA
OutputStream out = null;
Integer call_method = (Integer) _NamingContextImplBase.methods.get(method);
if (call_method == null)
- throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(Minor.Method, CompletionStatus.COMPLETED_MAYBE);
switch (call_method.intValue())
{
diff --git a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
index 948789521..6bf7bd7a6 100644
--- a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -75,7 +77,10 @@ public abstract class AlreadyBoundHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java b/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
index d1a1da51e..1d0b6049b 100644
--- a/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/CannotProceedHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -78,7 +80,10 @@ public abstract class CannotProceedHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
index 434713b2d..8f1133602 100644
--- a/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -75,7 +77,10 @@ public abstract class InvalidNameHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
index e1f82994f..6333dfcbc 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -75,7 +77,10 @@ public abstract class NotEmptyHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java b/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
index 544ab6377..442b7db9e 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -77,7 +79,10 @@ public abstract class NotFoundHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
index b6eacf85f..45a42a0ba 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming.NamingContextPackage;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -74,7 +76,10 @@ public abstract class NotFoundReasonHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/_BindingIteratorImplBase.java b/org/omg/CosNaming/_BindingIteratorImplBase.java
index 53c0dd3a6..9c7e1b347 100644
--- a/org/omg/CosNaming/_BindingIteratorImplBase.java
+++ b/org/omg/CosNaming/_BindingIteratorImplBase.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BooleanHolder;
import org.omg.CORBA.CompletionStatus;
@@ -114,7 +116,8 @@ public abstract class _BindingIteratorImplBase
out = rh.createReply();
}
else
- throw new BAD_OPERATION(method, 0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(method, Minor.Method,
+ CompletionStatus.COMPLETED_MAYBE);
return out;
}
diff --git a/org/omg/CosNaming/_NamingContextExtStub.java b/org/omg/CosNaming/_NamingContextExtStub.java
index 3ad772030..a0bc80ac0 100644
--- a/org/omg/CosNaming/_NamingContextExtStub.java
+++ b/org/omg/CosNaming/_NamingContextExtStub.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.CosNaming;
-import gnu.CORBA.NamingService.snConverter;
+import gnu.CORBA.NamingService.NameTransformer;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.ObjectHelper;
@@ -86,7 +86,7 @@ public class _NamingContextExtStub
/**
* The local name form converter.
*/
- private snConverter converter = new snConverter();
+ private NameTransformer converter = new NameTransformer();
/**
* Create the naming context stub.
diff --git a/org/omg/CosNaming/_NamingContextImplBase.java b/org/omg/CosNaming/_NamingContextImplBase.java
index 0c8b46f16..1c2a56be6 100644
--- a/org/omg/CosNaming/_NamingContextImplBase.java
+++ b/org/omg/CosNaming/_NamingContextImplBase.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CosNaming;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.DynamicImplementation;
@@ -123,7 +125,7 @@ public abstract class _NamingContextImplBase
OutputStream out = null;
Integer call_method = (Integer) methods.get(method);
if (call_method == null)
- throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(Minor.Method, CompletionStatus.COMPLETED_MAYBE);
switch (call_method.intValue())
{
@@ -389,7 +391,7 @@ public abstract class _NamingContextImplBase
// The server request contains no required result type.
Integer call_method = (Integer) methods.get(request.operation());
if (call_method == null)
- throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(Minor.Method, CompletionStatus.COMPLETED_MAYBE);
switch (call_method.intValue())
{
diff --git a/org/omg/DynamicAny/DynAnyFactoryHelper.java b/org/omg/DynamicAny/DynAnyFactoryHelper.java
index 0c02916e5..b8e3aafef 100644
--- a/org/omg/DynamicAny/DynAnyFactoryHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryHelper.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -80,6 +82,25 @@ public abstract class DynAnyFactoryHelper
+ " is not a DynAnyFactory");
}
}
+
+ /**
+ * Narrow the given object to the DynAnyFactory. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynAnyFactory.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynAnyFactory unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the final_type code of the {@link DynAnyFactory}.
@@ -161,13 +182,8 @@ public abstract class DynAnyFactoryHelper
*/
static String not_applicable(String Id)
{
- try
- {
- throw new MARSHAL("The read/write are not applicable for " + Id);
- }
- catch (Exception e)
- {
- throw new MARSHAL();
- }
+ MARSHAL m = new MARSHAL("The read/write are not applicable for " + Id);
+ m.minor = Minor.Inappropriate;
+ throw m;
}
} \ No newline at end of file
diff --git a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
index c7b54bef8..a9f45c4b7 100644
--- a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.DynamicAny.DynAnyFactoryPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class InconsistentTypeCodeHelper
{
BAD_OPERATION bad = new BAD_OPERATION("InconsistentTypeCode expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/DynAnyHelper.java b/org/omg/DynamicAny/DynAnyHelper.java
index ca48cd4c5..73e2d9856 100644
--- a/org/omg/DynamicAny/DynAnyHelper.java
+++ b/org/omg/DynamicAny/DynAnyHelper.java
@@ -79,6 +79,25 @@ public abstract class DynAnyHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynAny");
}
}
+
+ /**
+ * Narrow the given object to the DynAny. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynAny.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynAny unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynAny}.
diff --git a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
index 55e35eedc..1b5004f07 100644
--- a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.DynamicAny.DynAnyPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -107,6 +108,7 @@ public abstract class InvalidValueHelper
{
BAD_OPERATION bad = new BAD_OPERATION("InvalidValue expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
index e15fb72c6..b09ab4db8 100644
--- a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.DynamicAny.DynAnyPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -107,6 +108,7 @@ public abstract class TypeMismatchHelper
{
BAD_OPERATION bad = new BAD_OPERATION("TypeMismatch expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/DynAnySeqHelper.java b/org/omg/DynamicAny/DynAnySeqHelper.java
index 87e344523..ec3f0c481 100644
--- a/org/omg/DynamicAny/DynAnySeqHelper.java
+++ b/org/omg/DynamicAny/DynAnySeqHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
import gnu.CORBA.DynAnySeqHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class DynAnySeqHelper
{
BAD_OPERATION bad = new BAD_OPERATION("DynAnySeq expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/DynArrayHelper.java b/org/omg/DynamicAny/DynArrayHelper.java
index 0372b5851..f2892c856 100644
--- a/org/omg/DynamicAny/DynArrayHelper.java
+++ b/org/omg/DynamicAny/DynArrayHelper.java
@@ -78,6 +78,25 @@ public abstract class DynArrayHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynArray");
}
}
+
+ /**
+ * Narrow the given object to the DynArray. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynArray.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynArray unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynArray}.
diff --git a/org/omg/DynamicAny/DynEnumHelper.java b/org/omg/DynamicAny/DynEnumHelper.java
index 944d43757..8db1a2006 100644
--- a/org/omg/DynamicAny/DynEnumHelper.java
+++ b/org/omg/DynamicAny/DynEnumHelper.java
@@ -79,6 +79,25 @@ public abstract class DynEnumHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynEnum");
}
}
+
+ /**
+ * Narrow the given object to the DynEnum. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynEnum.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynEnum unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynEnum}.
diff --git a/org/omg/DynamicAny/DynFixedHelper.java b/org/omg/DynamicAny/DynFixedHelper.java
index 1d818d7b1..84bb59d9f 100644
--- a/org/omg/DynamicAny/DynFixedHelper.java
+++ b/org/omg/DynamicAny/DynFixedHelper.java
@@ -79,6 +79,25 @@ public abstract class DynFixedHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynFixed");
}
}
+
+ /**
+ * Narrow the given object to the DynFixed. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynFixed.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynFixed unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynFixed}.
diff --git a/org/omg/DynamicAny/DynSequenceHelper.java b/org/omg/DynamicAny/DynSequenceHelper.java
index c38a51f09..ad3013371 100644
--- a/org/omg/DynamicAny/DynSequenceHelper.java
+++ b/org/omg/DynamicAny/DynSequenceHelper.java
@@ -78,6 +78,25 @@ public abstract class DynSequenceHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynSequence");
}
}
+
+ /**
+ * Narrow the given object to the DynSequence. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynSequence.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynSequence unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynSequence}.
diff --git a/org/omg/DynamicAny/DynStructHelper.java b/org/omg/DynamicAny/DynStructHelper.java
index e4790b443..021c5d031 100644
--- a/org/omg/DynamicAny/DynStructHelper.java
+++ b/org/omg/DynamicAny/DynStructHelper.java
@@ -78,6 +78,25 @@ public abstract class DynStructHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynStruct");
}
}
+
+ /**
+ * Narrow the given object to the DynStruct. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynStruct.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynStruct unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynStruct}.
diff --git a/org/omg/DynamicAny/DynUnionHelper.java b/org/omg/DynamicAny/DynUnionHelper.java
index 794098333..8f924c086 100644
--- a/org/omg/DynamicAny/DynUnionHelper.java
+++ b/org/omg/DynamicAny/DynUnionHelper.java
@@ -78,6 +78,25 @@ public abstract class DynUnionHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynUnion");
}
}
+
+ /**
+ * Narrow the given object to the DynUnion. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynUnion.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynUnion unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynUnion}.
diff --git a/org/omg/DynamicAny/DynValueHelper.java b/org/omg/DynamicAny/DynValueHelper.java
index a6d7afaa9..026ca4990 100644
--- a/org/omg/DynamicAny/DynValueHelper.java
+++ b/org/omg/DynamicAny/DynValueHelper.java
@@ -78,6 +78,25 @@ public abstract class DynValueHelper
throw new BAD_PARAM(obj.getClass().getName() + " is not a DynValue");
}
}
+
+ /**
+ * Narrow the given object to the DynValue. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted DynValue.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static DynValue unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Get the type code of the {@link DynValue}.
diff --git a/org/omg/DynamicAny/FieldNameHelper.java b/org/omg/DynamicAny/FieldNameHelper.java
index 7c4cdbf49..f15b8adfa 100644
--- a/org/omg/DynamicAny/FieldNameHelper.java
+++ b/org/omg/DynamicAny/FieldNameHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -84,7 +84,7 @@ public abstract class FieldNameHelper
*/
public static TypeCode type()
{
- ORB orb = Restricted_ORB.Singleton;
+ ORB orb = OrbRestricted.Singleton;
return orb.create_alias_tc(id(), "FieldName", orb.create_string_tc(0));
}
diff --git a/org/omg/DynamicAny/NameDynAnyPairHelper.java b/org/omg/DynamicAny/NameDynAnyPairHelper.java
index d649800b8..a0e5c6b85 100644
--- a/org/omg/DynamicAny/NameDynAnyPairHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.Minor;
import gnu.CORBA.NameDynAnyPairHolder;
import org.omg.CORBA.Any;
@@ -83,6 +84,7 @@ public abstract class NameDynAnyPairHelper
{
BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPair expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
index f110926b8..ec4f72822 100644
--- a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.Minor;
import gnu.CORBA.NameDynAnyPairSeqHolder;
import org.omg.CORBA.Any;
@@ -105,6 +106,7 @@ public abstract class NameDynAnyPairSeqHelper
{
BAD_OPERATION bad = new BAD_OPERATION("NameDynAnyPairSeq expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/NameValuePairHelper.java b/org/omg/DynamicAny/NameValuePairHelper.java
index a3d5bff45..1e0f52b59 100644
--- a/org/omg/DynamicAny/NameValuePairHelper.java
+++ b/org/omg/DynamicAny/NameValuePairHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.Minor;
import gnu.CORBA.NameValuePairHolder;
import org.omg.CORBA.Any;
@@ -118,6 +119,7 @@ public abstract class NameValuePairHelper
{
BAD_OPERATION bad = new BAD_OPERATION("NameValuePair expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/NameValuePairSeqHelper.java b/org/omg/DynamicAny/NameValuePairSeqHelper.java
index 400708e18..62481534e 100644
--- a/org/omg/DynamicAny/NameValuePairSeqHelper.java
+++ b/org/omg/DynamicAny/NameValuePairSeqHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.Minor;
import gnu.CORBA.NameValuePairSeqHolder;
import org.omg.CORBA.Any;
@@ -98,6 +99,7 @@ public abstract class NameValuePairSeqHelper
{
BAD_OPERATION bad = new BAD_OPERATION("NameValuePairSeq expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/DynamicAny/_DynAnyFactoryStub.java b/org/omg/DynamicAny/_DynAnyFactoryStub.java
index b0f6d6052..15f7c816b 100644
--- a/org/omg/DynamicAny/_DynAnyFactoryStub.java
+++ b/org/omg/DynamicAny/_DynAnyFactoryStub.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.DynamicAny;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.TypeCode;
@@ -101,7 +103,9 @@ public class _DynAnyFactoryStub
public DynAny create_dyn_any(Any _0)
throws InconsistentTypeCode
{
- throw new MARSHAL(NOT_APPLICABLE);
+ MARSHAL m = new MARSHAL(NOT_APPLICABLE);
+ m.minor = Minor.Inappropriate;
+ throw m;
}
/**
@@ -113,7 +117,9 @@ public class _DynAnyFactoryStub
public DynAny create_dyn_any_from_type_code(TypeCode _0)
throws InconsistentTypeCode
{
- throw new MARSHAL(NOT_APPLICABLE);
+ MARSHAL m = new MARSHAL(NOT_APPLICABLE);
+ m.minor = Minor.Inappropriate;
+ throw m;
}
static String NOT_APPLICABLE =
diff --git a/org/omg/IOP/CodecFactoryHelper.java b/org/omg/IOP/CodecFactoryHelper.java
index d5c55a264..fea0b887b 100644
--- a/org/omg/IOP/CodecFactoryHelper.java
+++ b/org/omg/IOP/CodecFactoryHelper.java
@@ -120,6 +120,25 @@ public abstract class CodecFactoryHelper
throw bad;
}
}
+
+ /**
+ * Narrow the given object to the CodecFactory. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted CodecFactory.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static CodecFactory unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* This should read the CodecFactory from the CDR intput stream,
diff --git a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
index a1082178c..e036dbf1f 100644
--- a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
+++ b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP.CodecFactoryPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
@@ -108,6 +109,7 @@ public abstract class UnknownEncodingHelper
{
BAD_OPERATION bad = new BAD_OPERATION("UnknownEncoding expected");
bad.initCause(cex);
+ bad.minor = Minor.Any;
throw bad;
}
}
diff --git a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
index e5910ac57..e353be8f9 100644
--- a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP.CodecPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -103,6 +104,7 @@ public abstract class FormatMismatchHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("FormatMismatch expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
index 6c4ce52f0..8a93c5895 100644
--- a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
+++ b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP.CodecPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class InvalidTypeForEncodingHelper
{
BAD_OPERATION bad =
new BAD_OPERATION("InvalidTypeForEncoding expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
index 9f4228637..33951de70 100644
--- a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.IOP.CodecPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -103,6 +104,7 @@ public abstract class TypeMismatchHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("TypeMismatch expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/IOP/ExceptionDetailMessage.java b/org/omg/IOP/ExceptionDetailMessage.java
new file mode 100644
index 000000000..167ab1ac7
--- /dev/null
+++ b/org/omg/IOP/ExceptionDetailMessage.java
@@ -0,0 +1,60 @@
+/* ExceptionDetailMessage.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.IOP;
+
+/**
+ * <p>Defines the ExceptionDetailMessage (= 14) service context. This context
+ * may be included into reply message, having the SYSTEM_EXCEPTION or
+ * USER_EXCEPTION reply status, as the alternative to the stack trace
+ * that might contain sensitive or unwanted information. The service
+ * context contains the CDR-encapsulated wide string, usually
+ * returned by {@link Exception#getMessage}.
+ * </p><p>
+ * The applications may also send the more comprehensive UnknownExceptionInfo
+ * ( = 9 ) service context that contains the thrown exception, written
+ * as the Value type.
+ * </p>
+ */
+public interface ExceptionDetailMessage
+{
+ /**
+ * Specifies the ExceptionDetailMessage value, 14.
+ */
+ int value = 14;
+}
diff --git a/org/omg/IOP/IORHelper.java b/org/omg/IOP/IORHelper.java
index 5945bb75a..77f18d9b9 100644
--- a/org/omg/IOP/IORHelper.java
+++ b/org/omg/IOP/IORHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -111,6 +113,7 @@ public abstract class IORHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("IOR expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/IOP/MultipleComponentProfileHelper.java b/org/omg/IOP/MultipleComponentProfileHelper.java
index bc26068c9..6f5156fe2 100644
--- a/org/omg/IOP/MultipleComponentProfileHelper.java
+++ b/org/omg/IOP/MultipleComponentProfileHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.TypeCode;
@@ -96,6 +98,7 @@ public abstract class MultipleComponentProfileHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("MultipleComponentProfile expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/IOP/RMICustomMaxStreamFormat.java b/org/omg/IOP/RMICustomMaxStreamFormat.java
new file mode 100644
index 000000000..a071c8488
--- /dev/null
+++ b/org/omg/IOP/RMICustomMaxStreamFormat.java
@@ -0,0 +1,56 @@
+/* RMICustomMaxStreamFormat.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.IOP;
+
+ /**
+ * A single constant interface, defining the RMICustomMaxStreamFormat (= 17)
+ * service context. This constant is used in the service contexts
+ * inside the message when the {@link TAG_RMI_CUSTOM_MAX_STREAM_FORMAT}
+ * are used in IOR references. Please note that these two constants have
+ * different values.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RMICustomMaxStreamFormat
+{
+ /**
+ * Specifies the RMICustomMaxStreamFormat value, 17.
+ */
+ int value = 17;
+}
diff --git a/org/omg/IOP/ServiceContextHelper.java b/org/omg/IOP/ServiceContextHelper.java
index a8224a64c..5693a3235 100644
--- a/org/omg/IOP/ServiceContextHelper.java
+++ b/org/omg/IOP/ServiceContextHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -115,6 +117,7 @@ public abstract class ServiceContextHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ServiceContext expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/IOP/ServiceContextListHelper.java b/org/omg/IOP/ServiceContextListHelper.java
index 11bbe253f..fa436cbb8 100644
--- a/org/omg/IOP/ServiceContextListHelper.java
+++ b/org/omg/IOP/ServiceContextListHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
@@ -94,7 +96,10 @@ public abstract class ServiceContextListHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("ServiceContext[] expected.");
+ BAD_OPERATION bad = new BAD_OPERATION("ServiceContext[] expected");
+ bad.minor = Minor.Any;
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/IOP/TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.java b/org/omg/IOP/TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.java
new file mode 100644
index 000000000..e13c759c9
--- /dev/null
+++ b/org/omg/IOP/TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.java
@@ -0,0 +1,61 @@
+/* TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.IOP;
+
+/**
+ * A single constant interface, defining the
+ * TAG_RMI_CUSTOM_MAX_STREAM_FORMAT (= 38) tagged component.
+ *
+ * This component defines the format that has been used to write the RMI-IIOP
+ * value type objects in the message. It consists of the single byte,
+ * having the value of the used version. If this component is missing,
+ * the default value is assumed to be 1 for GIOP 1.2 and 2 for GIOP 1.3.
+ * The component can occur only once in the same IOR profile.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface TAG_RMI_CUSTOM_MAX_STREAM_FORMAT
+{
+ /**
+ * Specifies the TAG_RMI_CUSTOM_MAX_STREAM_FORMAT value, 38.
+ */
+ int value = 38;
+}
diff --git a/org/omg/IOP/TaggedComponentHelper.java b/org/omg/IOP/TaggedComponentHelper.java
index 906d6390a..eaee120f0 100644
--- a/org/omg/IOP/TaggedComponentHelper.java
+++ b/org/omg/IOP/TaggedComponentHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.IOP;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.MARSHAL;
@@ -115,6 +117,7 @@ public abstract class TaggedComponentHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("TaggedComponent expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
@@ -149,6 +152,7 @@ public abstract class TaggedComponentHelper
catch (IOException e)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Encapsulation;
m.initCause(e);
throw m;
}
@@ -175,6 +179,7 @@ public abstract class TaggedComponentHelper
catch (IOException e)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Encapsulation;
m.initCause(e);
throw m;
}
diff --git a/org/omg/IOP/TaggedProfileHelper.java b/org/omg/IOP/TaggedProfileHelper.java
index a23122eb9..2943657c0 100644
--- a/org/omg/IOP/TaggedProfileHelper.java
+++ b/org/omg/IOP/TaggedProfileHelper.java
@@ -38,8 +38,9 @@ exception statement from your version. */
package org.omg.IOP;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.Minor;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -118,6 +119,7 @@ public abstract class TaggedProfileHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("TaggedProfile expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
@@ -143,10 +145,10 @@ public abstract class TaggedProfileHelper
TaggedProfile value = new TaggedProfile();
value.tag = input.read_long();
- if (input instanceof cdrBufInput)
+ if (input instanceof BufferredCdrInput)
{
// Highly probable.
- value.profile_data = ((cdrBufInput) input).read_sequence();
+ value.profile_data = ((BufferredCdrInput) input).read_sequence();
}
else
{
@@ -167,7 +169,7 @@ public abstract class TaggedProfileHelper
{
output.write_long(value.tag);
- if (output instanceof cdrBufOutput)
+ if (output instanceof BufferedCdrOutput)
{
// Highly probable.
output.write_long(value.profile_data.length);
@@ -178,6 +180,7 @@ public abstract class TaggedProfileHelper
catch (IOException e)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Encapsulation;
m.initCause(e);
throw m;
}
diff --git a/org/omg/Messaging/SyncScopeHelper.java b/org/omg/Messaging/SyncScopeHelper.java
index 7d8b412fe..1d482c579 100644
--- a/org/omg/Messaging/SyncScopeHelper.java
+++ b/org/omg/Messaging/SyncScopeHelper.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package org.omg.Messaging;
-import gnu.CORBA.primitiveTypeCode;
-import gnu.CORBA.recordTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.TCKind;
@@ -104,10 +104,10 @@ public class SyncScopeHelper
*/
public static TypeCode type()
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_alias);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_alias);
r.setName("SyncScope");
r.setId(id());
- r.setContentType(new primitiveTypeCode(TCKind.tk_short));
+ r.setContentType(new PrimitiveTypeCode(TCKind.tk_short));
return r;
}
diff --git a/org/omg/PortableInterceptor/ACTIVE.java b/org/omg/PortableInterceptor/ACTIVE.java
new file mode 100644
index 000000000..d7e7e1487
--- /dev/null
+++ b/org/omg/PortableInterceptor/ACTIVE.java
@@ -0,0 +1,55 @@
+/* ACTIVE.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+/**
+ * A single constant interface, defining the adapter state (ACTIVE) = 1.
+ * Used with IOR interceptors.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ACTIVE
+{
+ /**
+ * Specifies the ACTIVE value, 1.
+ */
+ short value = 1;
+}
diff --git a/org/omg/PortableInterceptor/AdapterManagerIdHelper.java b/org/omg/PortableInterceptor/AdapterManagerIdHelper.java
new file mode 100644
index 000000000..f3f7e6441
--- /dev/null
+++ b/org/omg/PortableInterceptor/AdapterManagerIdHelper.java
@@ -0,0 +1,119 @@
+/* AdapterManagerIdHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the adapter manager id. An adapter manager id is an
+ * integer constant and needs no helper, but the one is included anyway.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class AdapterManagerIdHelper
+{
+ /**
+ * Create the AdapterManagerId typecode (alias of CORBA long (java int),
+ * named "AdapterManagerId").
+ */
+ public static TypeCode type()
+ {
+ ORB orb = ORB.init();
+ return orb.create_alias_tc(id(), "AdapterManagerId",
+ orb.get_primitive_tc(TCKind.tk_long)
+ );
+ }
+
+ /**
+ * Insert the int into the given Any.
+ */
+ public static void insert(Any any, int that)
+ {
+ any.insert_long(that);
+ }
+
+ /**
+ * Extract the int from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain int.
+ */
+ public static int extract(Any any)
+ {
+ return any.extract_long();
+ }
+
+ /**
+ * Get the adapter manager id repository id.
+ *
+ * @return "IDL:omg.org/PortableInterceptor/AdapterManagerId:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/AdapterManagerId:1.0";
+ }
+
+ /**
+ * Read the int (adapter manager id) from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static int read(InputStream input)
+ {
+ return input.read_long();
+ }
+
+ /**
+ * Write the int (adapter manager id) to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, int value)
+ {
+ output.write_long(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/AdapterNameHelper.java b/org/omg/PortableInterceptor/AdapterNameHelper.java
new file mode 100644
index 000000000..1cda311b2
--- /dev/null
+++ b/org/omg/PortableInterceptor/AdapterNameHelper.java
@@ -0,0 +1,144 @@
+/* AdapterNameHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import gnu.CORBA.OrbRestricted;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.StringSeqHelper;
+import org.omg.CORBA.StringSeqHolder;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * Provides static helper methods for working with the adapter name helper.
+ * The adapter name helper is an array of strings, so {@link StringSeqHelper}
+ * could be used for io operations. The separate helper is provided anyway.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class AdapterNameHelper
+{
+
+ /**
+ * The cached typecode, computed once.
+ */
+ static TypeCode typecode;
+
+ /**
+ * Extract the adapter name (<code>String[]</code>) from the given {@link Any}.
+ *
+ * @param a an Any to extract the array from.
+ *
+ * @return the extracted array.
+ */
+ public static String[] extract(Any a)
+ {
+ StringSeqHolder h = (StringSeqHolder) a.extract_Streamable();
+ return h.value;
+ }
+
+ /**
+ * Returns the agreed Id.
+ *
+ * @return "IDL:omg.org/PortableInterceptor/AdapterName:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/AdapterName:1.0";
+ }
+
+ /**
+ * Insert into the given adapter name (<code>String[]</code>) into the
+ * given {@link Any}.
+ *
+ * @param into the target Any.
+ * @param that the array to insert.
+ */
+ public static void insert(Any into, String[] that)
+ {
+ StringSeqHolder holder = new StringSeqHolder(that);
+ into.insert_Streamable(holder);
+ into.type(type());
+ }
+
+ /**
+ * Reads the <code>String[]</code> from the CORBA input stream.
+ *
+ * @param input the CORBA stream to read from.
+ * @return the value from the stream.
+ */
+ public static String[] read(InputStream input)
+ {
+ return StringSeqHelper.read(input);
+ }
+
+ /**
+ * Creates and returns a new instance of the TypeCode,
+ * corresponding the adapter name.
+ *
+ * @return the alias of the string sequence, named "AdapterName".
+ */
+ public static TypeCode type()
+ {
+ if (typecode == null)
+ {
+ ORB orb = OrbRestricted.Singleton;
+
+ TypeCode component = orb.create_string_tc(0);
+ typecode = orb.create_alias_tc(id(), "AdapterName", component);
+ }
+ return typecode;
+ }
+
+ /**
+ * Writes the <code>String[]</code> into the given stream.
+ *
+ * @param output the CORBA output stream to write.
+ * @param value the value that must be written.
+ */
+ public static void write(OutputStream output, String[] value)
+ {
+ StringSeqHelper.write(output, value);
+ }
+}
diff --git a/org/omg/PortableInterceptor/AdapterStateHelper.java b/org/omg/PortableInterceptor/AdapterStateHelper.java
new file mode 100644
index 000000000..ceb7ac8d5
--- /dev/null
+++ b/org/omg/PortableInterceptor/AdapterStateHelper.java
@@ -0,0 +1,119 @@
+/* AdapterStateHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the adapter state. An adapter state is an
+ * short integer constant and needs no helper, but the one is included anyway.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class AdapterStateHelper
+{
+ /**
+ * Create the AdapterState typecode (alias of <code>short</code>,
+ * named "AdapterState").
+ */
+ public static TypeCode type()
+ {
+ ORB orb = ORB.init();
+ return orb.create_alias_tc(id(), "AdapterState",
+ orb.get_primitive_tc(TCKind.tk_short)
+ );
+ }
+
+ /**
+ * Insert the <code>short</code> into the given Any.
+ */
+ public static void insert(Any any, short that)
+ {
+ any.insert_short(that);
+ }
+
+ /**
+ * Extract the <code>short</code> from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain int.
+ */
+ public static short extract(Any any)
+ {
+ return any.extract_short();
+ }
+
+ /**
+ * Get the adapter state repository id.
+ *
+ * @return "IDL:omg.org/PortableInterceptor/AdapterState:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/AdapterState:1.0";
+ }
+
+ /**
+ * Read the <code>short</code> (adapter state) from the CDR intput stream.
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static short read(InputStream input)
+ {
+ return input.read_short();
+ }
+
+ /**
+ * Write the <code>short</code> (adapter state) to the CDR output stream.
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, short value)
+ {
+ output.write_short(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/CurrentHelper.java b/org/omg/PortableInterceptor/CurrentHelper.java
index b7a5a541e..df3bcaef7 100644
--- a/org/omg/PortableInterceptor/CurrentHelper.java
+++ b/org/omg/PortableInterceptor/CurrentHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
@@ -45,6 +47,7 @@ import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.PortableServer.ServantActivator;
/**
* The helper operations for the CORBA object {@link Current}.
@@ -123,6 +126,25 @@ public abstract class CurrentHelper
throw new BAD_PARAM("Not a Current");
}
}
+
+ /**
+ * Narrow the given object to the Current. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted Current.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static Current unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* Not supported for compatibility reasons.
@@ -133,7 +155,9 @@ public abstract class CurrentHelper
*/
public static Current read(InputStream input)
{
- throw new MARSHAL();
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
/**
@@ -145,6 +169,8 @@ public abstract class CurrentHelper
*/
public static void write(OutputStream output, Current value)
{
- throw new MARSHAL();
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/DISCARDING.java b/org/omg/PortableInterceptor/DISCARDING.java
new file mode 100644
index 000000000..bec0c25e0
--- /dev/null
+++ b/org/omg/PortableInterceptor/DISCARDING.java
@@ -0,0 +1,55 @@
+/* DISCARDING.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+/**
+ * A single constant interface, defining the adapter state (DISCARDING) = 2.
+ * Used with IOR interceptors.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DISCARDING
+{
+ /**
+ * Specifies the DISCARDING value, 2.
+ */
+ short value = 2;
+}
diff --git a/org/omg/PortableInterceptor/ForwardRequestHelper.java b/org/omg/PortableInterceptor/ForwardRequestHelper.java
index 11d6b7f0f..5db56d745 100644
--- a/org/omg/PortableInterceptor/ForwardRequestHelper.java
+++ b/org/omg/PortableInterceptor/ForwardRequestHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import gnu.CORBA.Minor;
import gnu.CORBA.Interceptor.ForwardRequestHolder;
import org.omg.CORBA.Any;
@@ -106,6 +107,7 @@ public abstract class ForwardRequestHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION(id() + " expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableInterceptor/HOLDING.java b/org/omg/PortableInterceptor/HOLDING.java
new file mode 100644
index 000000000..ce22a1f68
--- /dev/null
+++ b/org/omg/PortableInterceptor/HOLDING.java
@@ -0,0 +1,55 @@
+/* HOLDING.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+/**
+ * A single constant interface, defining the adapter state (HOLDING) = 0.
+ * Used with IOR interceptors.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface HOLDING
+{
+ /**
+ * Specifies the HOLDING value, 0.
+ */
+ short value = 0;
+}
diff --git a/org/omg/PortableInterceptor/INACTIVE.java b/org/omg/PortableInterceptor/INACTIVE.java
new file mode 100644
index 000000000..8a5cad1e1
--- /dev/null
+++ b/org/omg/PortableInterceptor/INACTIVE.java
@@ -0,0 +1,57 @@
+/* INACTIVE.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+/**
+ * A single constant interface, defining the adapter state (INACTIVE) = 3.
+ * The adapter is shutting down, and will eventually end up in the
+ * NON_EXISTENT state.
+ * Used with IOR interceptors.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface INACTIVE
+{
+ /**
+ * Specifies the INACTIVE value, 3.
+ */
+ short value = 3;
+}
diff --git a/org/omg/PortableInterceptor/InvalidSlotHelper.java b/org/omg/PortableInterceptor/InvalidSlotHelper.java
index c0aa0ee1b..98b259677 100644
--- a/org/omg/PortableInterceptor/InvalidSlotHelper.java
+++ b/org/omg/PortableInterceptor/InvalidSlotHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class InvalidSlotHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("InvalidSlot expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableInterceptor/NON_EXISTENT.java b/org/omg/PortableInterceptor/NON_EXISTENT.java
new file mode 100644
index 000000000..136b64fb0
--- /dev/null
+++ b/org/omg/PortableInterceptor/NON_EXISTENT.java
@@ -0,0 +1,57 @@
+/* NON_EXISTENT.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+/**
+ * A single constant interface, defining the adapter state (NON_EXISTENT) = 4.
+ * NON_EXISTENT does not map directly to a particular POAManager state, but
+ * indicates that a POA has been destroyed. Used with IOR interceptors.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+
+public interface NON_EXISTENT
+{
+ /**
+ * Specifies the NON_EXISTENT value, 4.
+ */
+ short value = 4;
+}
diff --git a/org/omg/PortableInterceptor/ORBIdHelper.java b/org/omg/PortableInterceptor/ORBIdHelper.java
new file mode 100644
index 000000000..8332845a6
--- /dev/null
+++ b/org/omg/PortableInterceptor/ORBIdHelper.java
@@ -0,0 +1,119 @@
+/* ORBIdHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import gnu.CORBA.OrbRestricted;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The ORB Id is defined in OMG specification just as a narrow (not wide)
+ * string. As such, the ORB Id needs no helper, but one is included in
+ * the API anyway.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ORBIdHelper
+{
+ /**
+ * Insert the ORB Id into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the ORB Id from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an alias typecode.
+ */
+ public static TypeCode type()
+ {
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_alias_tc(id(), "ORBId", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the ORB Id repository id.
+ * @return "IDL:omg.org/PortableInterceptor/ORBId:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/ORBId:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param input the stream to read from.
+ */
+ public static String read(InputStream input)
+ {
+ return input.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param output the stream to write into.
+ * @param value the string (ORB Id) value to write.
+ */
+ public static void write(OutputStream output, String value)
+ {
+ output.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
index a5c83fa80..648e9679b 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java
@@ -110,6 +110,7 @@ public abstract class DuplicateNameHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("DuplicateName expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
index 7f1132f98..f89f9d4c6 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor.ORBInitInfoPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -103,6 +104,7 @@ public abstract class InvalidNameHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("InvalidName expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java
index d0946e3fa..c22d14a11 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor.ORBInitInfoPackage;
-import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -81,8 +81,8 @@ public class ObjectIdHelper
*/
public static TypeCode type()
{
- ORB orb = Restricted_ORB.Singleton;
- return orb.create_alias_tc(id(), "Object Id", orb.create_string_tc(0));
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_alias_tc(id(), "ObjectId", orb.create_string_tc(0));
}
/**
@@ -97,7 +97,7 @@ public class ObjectIdHelper
/**
* Calls {@link InputStream#read_string()}.
*
- * @param instream the stream to read from.
+ * @param input the stream to read from.
*/
public static String read(InputStream input)
{
@@ -107,7 +107,7 @@ public class ObjectIdHelper
/**
* Calls {@link OutputStream#write_string()}.
*
- * @param ostream the stream to write into.
+ * @param output the stream to write into.
* @param value the string (Object Id) value to write.
*/
public static void write(OutputStream output, String value)
diff --git a/org/omg/PortableInterceptor/ObjectIdHelper.java b/org/omg/PortableInterceptor/ObjectIdHelper.java
new file mode 100644
index 000000000..600d0a0fb
--- /dev/null
+++ b/org/omg/PortableInterceptor/ObjectIdHelper.java
@@ -0,0 +1,121 @@
+/* ObjectIdHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import gnu.CORBA.OrbRestricted;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.OctetSeqHelper;
+import org.omg.CORBA.OctetSeqHolder;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The Object Id of this package is defined in OMG specification as a byte array.
+ * As such, the Object Id needs no helper, but one is included in the API anyway.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ObjectIdHelper
+{
+ /**
+ * Insert the Object Id into Any.
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, byte[] that)
+ {
+ a.insert_Streamable(new OctetSeqHolder(that));
+ a.type(type());
+ }
+
+ /**
+ * Extract the Object Id from Any.
+ *
+ * @param a the Any to extract from.
+ */
+ public static byte[] extract(Any a)
+ {
+ return ((OctetSeqHolder) a.extract_Streamable()).value;
+ }
+
+ /**
+ * Return an alias typecode (an alias of the octet sequence).
+ */
+ public static TypeCode type()
+ {
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_alias_tc(id(), "ObjectId", OctetSeqHelper.type());
+ }
+
+ /**
+ * Return the Object Id repository id.
+ * @return "IDL:omg.org/PortableInterceptor/ObjectId:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/ObjectId:1.0";
+ }
+
+ /**
+ * Read the Object Id as a byte array.
+ *
+ * @param input the stream to read from.
+ */
+ public static byte[] read(InputStream input)
+ {
+ return OctetSeqHelper.read(input);
+ }
+
+ /**
+ * Write the Object Id as a byte array.
+ *
+ * @param output the stream to write into.
+ * @param value the Object Id value to write.
+ */
+ public static void write(OutputStream output, byte[] value)
+ {
+ OctetSeqHelper.write(output, value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ObjectReferenceFactory.java b/org/omg/PortableInterceptor/ObjectReferenceFactory.java
new file mode 100644
index 000000000..df039901a
--- /dev/null
+++ b/org/omg/PortableInterceptor/ObjectReferenceFactory.java
@@ -0,0 +1,57 @@
+/* ObjectReferenceFactory.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+/**
+ * Provides the possibility to create the CORBA object reference.
+ * The reference is created from repository id (defining the type of the
+ * object) and the object id (defining the identity of the object).
+ * The operation for creating reference is defined separately in
+ * {@link ObjectReferenceFactoryOperations}.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ObjectReferenceFactory
+ extends ObjectReferenceFactoryOperations, IDLEntity, org.omg.CORBA.Object
+{
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
new file mode 100644
index 000000000..55ee0be18
--- /dev/null
+++ b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
@@ -0,0 +1,150 @@
+/* ObjectReferenceFactoryHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import gnu.CORBA.CDR.Vio;
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ValueMember;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.VM_ABSTRACT;
+
+/**
+ * The helper operations for the CORBA object {@link ObjectReferenceFactory}.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ObjectReferenceFactoryHelper
+{
+ /**
+ * The cached {@link ObjectReferenceFactory} typecode, computed once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Get the type code of the {@link ObjectReferenceFactory}.
+ *
+ * @return value type code with the agreed id, named
+ * "ObjectReferenceFactory", abstract, no members, no base type.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ typeCode =
+ ORB.init().create_value_tc(id(), "ObjectReferenceFactory",
+ VM_ABSTRACT.value, null, new ValueMember[ 0 ]
+ );
+ return typeCode;
+ }
+
+ /**
+ * Insert the ObjectReferenceFactory into the given Any.
+ *
+ * @param any the Any to insert into.
+ * @param that the ObjectReferenceFactory to insert.
+ */
+ public static void insert(Any any, ObjectReferenceFactory that)
+ {
+ ObjectReferenceFactoryHolder h = new ObjectReferenceFactoryHolder(that);
+ any.insert_Streamable(h);
+ }
+
+ /**
+ * Extract the ObjectReferenceFactory from given Any.
+ *
+ * @throws BAD_OPERATION if the passed Any does not contain ObjectReferenceFactory.
+ */
+ public static ObjectReferenceFactory extract(Any any)
+ {
+ try
+ {
+ ObjectReferenceFactoryHolder h =
+ (ObjectReferenceFactoryHolder) (any.extract_Streamable());
+ return h.value;
+ }
+ catch (ClassCastException ex)
+ {
+ BAD_OPERATION bad =
+ new BAD_OPERATION("ObjectReferenceFactory expected");
+ bad.minor = Minor.Any;
+ bad.initCause(ex);
+ throw bad;
+ }
+ }
+
+ /**
+ * Get the ObjectReferenceFactory repository id.
+ *
+ * @return "IDL:omg.org/PortableInterceptor/ObjectReferenceFactory:1.0",
+ * always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/ObjectReferenceFactory:1.0";
+ }
+
+ /**
+ * Read the ObjectReferenceFactory from the CDR intput stream
+ * (ValueBase type expected).
+ *
+ * @param input a org.omg.CORBA.portable stream to read from.
+ */
+ public static ObjectReferenceFactory read(InputStream input)
+ {
+ return (ObjectReferenceFactory) Vio.read(input);
+ }
+
+ /**
+ * Write the ObjectReferenceFactory to the CDR output stream (as a ValueBase).
+ *
+ * @param output a org.omg.CORBA.portable stream stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream output, ObjectReferenceFactory value)
+ {
+ Vio.write(output, value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ObjectReferenceFactoryHolder.java b/org/omg/PortableInterceptor/ObjectReferenceFactoryHolder.java
new file mode 100644
index 000000000..fc68ec5c1
--- /dev/null
+++ b/org/omg/PortableInterceptor/ObjectReferenceFactoryHolder.java
@@ -0,0 +1,105 @@
+/* ObjectReferenceFactoryHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * A holder for the object {@link ObjectReferenceFactory}.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ObjectReferenceFactoryHolder
+ implements Streamable
+{
+ /**
+ * The stored ObjectReferenceFactory value.
+ */
+ public ObjectReferenceFactory value;
+
+ /**
+ * Create the unitialised instance, leaving the value field
+ * with default <code>null</code> value.
+ */
+ public ObjectReferenceFactoryHolder()
+ {
+ }
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue the value that will be assigned to
+ * the <code>value</code> field.
+ */
+ public ObjectReferenceFactoryHolder(ObjectReferenceFactory initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ *
+ * @param input the org.omg.CORBA.portable stream to read.
+ */
+ public void _read(InputStream input)
+ {
+ value = ObjectReferenceFactoryHelper.read(input);
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ *
+ * @param output the org.omg.CORBA.portable stream to write.
+ */
+ public void _write(OutputStream output)
+ {
+ ObjectReferenceFactoryHelper.write(output, value);
+ }
+
+ /**
+ * Get the typecode of the ObjectReferenceFactory.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return ObjectReferenceFactoryHelper.type();
+ }
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ObjectReferenceFactoryOperations.java b/org/omg/PortableInterceptor/ObjectReferenceFactoryOperations.java
new file mode 100644
index 000000000..d2ce61423
--- /dev/null
+++ b/org/omg/PortableInterceptor/ObjectReferenceFactoryOperations.java
@@ -0,0 +1,64 @@
+/* ObjectReferenceFactoryOperations.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import org.omg.CORBA.portable.ValueBase;
+
+/**
+ * Defines the operations, applicable to the ObjectReferenceFactory.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface ObjectReferenceFactoryOperations
+ extends ValueBase
+{
+ /**
+ * Create an object with the given repository and object ids. This interface
+ * does not specify where and how the returned object must be connected and
+ * activated.
+ *
+ * @param repositoryId the repository id of the object being created, defines
+ * the type of the object.
+ *
+ * @param objectId the byte array, defining the identity of the object.
+ */
+ org.omg.CORBA.Object make_object(String repositoryId, byte[] objectId);
+} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ServerIdHelper.java b/org/omg/PortableInterceptor/ServerIdHelper.java
new file mode 100644
index 000000000..e4f8fe9c2
--- /dev/null
+++ b/org/omg/PortableInterceptor/ServerIdHelper.java
@@ -0,0 +1,119 @@
+/* ServerIdHelper.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.PortableInterceptor;
+
+import gnu.CORBA.OrbRestricted;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * The Server Id is defined in OMG specification just as a narrow (not wide)
+ * string. As such, the Server Id needs no helper, but one is included in
+ * the API anyway.
+ *
+ * @since 1.5
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ServerIdHelper
+{
+ /**
+ * Insert the Server Id into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the Server Id from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an alias typecode.
+ */
+ public static TypeCode type()
+ {
+ ORB orb = OrbRestricted.Singleton;
+ return orb.create_alias_tc(id(), "ServerId", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the Server Id repository id.
+ * @return "IDL:omg.org/PortableInterceptor/ServerId:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/PortableInterceptor/ServerId:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param input the stream to read from.
+ */
+ public static String read(InputStream input)
+ {
+ return input.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param output the stream to write into.
+ * @param value the string (Server Id) value to write.
+ */
+ public static void write(OutputStream output, String value)
+ {
+ output.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
index 0ba635200..848a3c3d3 100644
--- a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
+++ b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.CurrentPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -105,6 +106,7 @@ public abstract class NoContextHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("NoContext expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/ForwardRequestHelper.java b/org/omg/PortableServer/ForwardRequestHelper.java
index 6f8d5ea6b..f4b0619b0 100644
--- a/org/omg/PortableServer/ForwardRequestHelper.java
+++ b/org/omg/PortableServer/ForwardRequestHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
import gnu.CORBA.Poa.ForwardRequestHolder;
import org.omg.CORBA.Any;
@@ -80,6 +81,7 @@ public abstract class ForwardRequestHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ForwardRequest expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/IdAssignmentPolicyValue.java b/org/omg/PortableServer/IdAssignmentPolicyValue.java
index 2dda0ef2b..ac81d389c 100644
--- a/org/omg/PortableServer/IdAssignmentPolicyValue.java
+++ b/org/omg/PortableServer/IdAssignmentPolicyValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -129,7 +131,9 @@ public class IdAssignmentPolicyValue
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code);
+ bad.minor = Minor.PolicyType;
+ throw bad;
}
}
diff --git a/org/omg/PortableServer/IdUniquenessPolicyValue.java b/org/omg/PortableServer/IdUniquenessPolicyValue.java
index d0992d9db..c0f281249 100644
--- a/org/omg/PortableServer/IdUniquenessPolicyValue.java
+++ b/org/omg/PortableServer/IdUniquenessPolicyValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -129,7 +131,9 @@ public class IdUniquenessPolicyValue
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code);
+ bad.minor = Minor.PolicyType;
+ throw bad;
}
}
diff --git a/org/omg/PortableServer/ImplicitActivationPolicyValue.java b/org/omg/PortableServer/ImplicitActivationPolicyValue.java
index 8d2913bf6..9d81d5fab 100644
--- a/org/omg/PortableServer/ImplicitActivationPolicyValue.java
+++ b/org/omg/PortableServer/ImplicitActivationPolicyValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -129,7 +131,9 @@ public class ImplicitActivationPolicyValue
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code);
+ bad.minor = Minor.PolicyType;
+ throw bad;
}
}
diff --git a/org/omg/PortableServer/LifespanPolicyValue.java b/org/omg/PortableServer/LifespanPolicyValue.java
index 1e046c4e9..117eb5a3c 100644
--- a/org/omg/PortableServer/LifespanPolicyValue.java
+++ b/org/omg/PortableServer/LifespanPolicyValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -126,7 +128,9 @@ public class LifespanPolicyValue
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code);
+ bad.minor = Minor.PolicyType;
+ throw bad;
}
}
diff --git a/org/omg/PortableServer/POAHelper.java b/org/omg/PortableServer/POAHelper.java
index 2928d9f07..3712da00d 100644
--- a/org/omg/PortableServer/POAHelper.java
+++ b/org/omg/PortableServer/POAHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
@@ -126,7 +128,9 @@ public abstract class POAHelper
*/
public static POA read(InputStream input)
{
- throw new MARSHAL("Not applicable");
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
/**
@@ -142,6 +146,8 @@ public abstract class POAHelper
*/
public static void write(OutputStream output, POA value)
{
- throw new MARSHAL("Not applicable");
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
} \ No newline at end of file
diff --git a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
index db7b965bb..2a587a412 100644
--- a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
+++ b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAManagerPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class AdapterInactiveHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("AdapterInactive expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAManagerPackage/State.java b/org/omg/PortableServer/POAManagerPackage/State.java
index 536189a0c..9e856098b 100644
--- a/org/omg/PortableServer/POAManagerPackage/State.java
+++ b/org/omg/PortableServer/POAManagerPackage/State.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer.POAManagerPackage;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -140,7 +142,7 @@ public class State
/**
* Returns the State, matching the given integer constant.
- *
+ *
* @param code one of _HOLDING, _ACTIVE, _DISCARDING, _INACTIVE.
* @return one of HOLDING, ACTIVE, DISCARDING, INACTIVE.
* @throws BAD_PARAM if the parameter is not one of the valid values.
@@ -149,16 +151,19 @@ public class State
{
try
{
- return enume [ code ];
+ return enume[code];
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid state " + code);
+ bad.minor = Minor.Enumeration;
+ throw bad;
}
}
/**
* Returns a short string representation.
+ *
* @return the name of the current enumeration value.
*/
public String toString()
diff --git a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
index 3ffee4ff8..61a410891 100644
--- a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -107,6 +108,7 @@ public abstract class AdapterAlreadyExistsHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("AdapterAlreadyExists expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
index f05daec3d..dd318bf09 100644
--- a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class AdapterNonExistentHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("AdapterNonExistent expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java b/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
index 15aa62d82..5e9e627c7 100644
--- a/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
+++ b/org/omg/PortableServer/POAPackage/InvalidPolicyHelper.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
+import gnu.CORBA.Minor;
import gnu.CORBA.Poa.InvalidPolicyHolder;
import org.omg.CORBA.Any;
@@ -110,6 +111,7 @@ public abstract class InvalidPolicyHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("InvalidPolicy expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/NoServantHelper.java b/org/omg/PortableServer/POAPackage/NoServantHelper.java
index 26b21ce6c..fd2c189fc 100644
--- a/org/omg/PortableServer/POAPackage/NoServantHelper.java
+++ b/org/omg/PortableServer/POAPackage/NoServantHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class NoServantHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("NoServant expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
index 99891dbe5..011867473 100644
--- a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -107,6 +108,7 @@ public abstract class ObjectAlreadyActiveHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ObjectAlreadyActive expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
index 867d5f4f6..0d8ff473c 100644
--- a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class ObjectNotActiveHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ObjectNotActive expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
index 0db0e938b..a74e67401 100644
--- a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -107,6 +108,7 @@ public abstract class ServantAlreadyActiveHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ServantAlreadyActive expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
index 429421853..5fb52cf35 100644
--- a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class ServantNotActiveHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ServantNotActive expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
index ebba304a5..cd862b081 100644
--- a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class WrongAdapterHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("WrongAdapter expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
index 5460d0ea7..a1f27cbb0 100644
--- a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer.POAPackage;
import gnu.CORBA.EmptyExceptionHolder;
+import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -106,6 +107,7 @@ public abstract class WrongPolicyHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("WrongPolicy expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/org/omg/PortableServer/POAPackage/package.html b/org/omg/PortableServer/POAPackage/package.html
new file mode 100644
index 000000000..e95dd68ec
--- /dev/null
+++ b/org/omg/PortableServer/POAPackage/package.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in org.omg.PortableServer.POAPackage package
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.PortableServer.POAPackage</title></head>
+
+<body>
+<p>Contains exceptions that may be thrown by various POA operations.
+Also provides helpers that are used to transfer these exceptions if they
+are thrown on remote side.</p>
+
+@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html>
diff --git a/org/omg/PortableServer/RequestProcessingPolicyValue.java b/org/omg/PortableServer/RequestProcessingPolicyValue.java
index 139010c86..0b1ce4d0b 100644
--- a/org/omg/PortableServer/RequestProcessingPolicyValue.java
+++ b/org/omg/PortableServer/RequestProcessingPolicyValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -151,7 +153,9 @@ public class RequestProcessingPolicyValue
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code);
+ bad.minor = Minor.PolicyType;
+ throw bad;
}
}
diff --git a/org/omg/PortableServer/Servant.java b/org/omg/PortableServer/Servant.java
index 745fc8a7e..5c99ee1a0 100644
--- a/org/omg/PortableServer/Servant.java
+++ b/org/omg/PortableServer/Servant.java
@@ -45,6 +45,8 @@ import org.omg.CORBA.ORB;
import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongPolicy;
import org.omg.PortableServer.portable.Delegate;
+
+import gnu.CORBA.Minor;
import gnu.CORBA.Poa.ORB_1_4;
import gnu.CORBA.Poa.gnuPOA;
@@ -239,6 +241,7 @@ public abstract class Servant
catch (WrongPolicy unexp)
{
BAD_OPERATION bad = new BAD_OPERATION();
+ bad.minor = Minor.Policy;
bad.initCause(unexp);
throw bad;
}
@@ -253,6 +256,7 @@ public abstract class Servant
unexp.initCause(ex);
BAD_OPERATION bad = new BAD_OPERATION();
+ bad.minor = Minor.Activation;
bad.initCause(unexp);
throw bad;
}
diff --git a/org/omg/PortableServer/ServantActivatorHelper.java b/org/omg/PortableServer/ServantActivatorHelper.java
index 1aab99cee..8aa58b2f6 100644
--- a/org/omg/PortableServer/ServantActivatorHelper.java
+++ b/org/omg/PortableServer/ServantActivatorHelper.java
@@ -38,7 +38,10 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.ORB;
@@ -112,6 +115,26 @@ public abstract class ServantActivatorHelper
throw bad;
}
}
+
+ /**
+ * Narrow the given object to the ServantActivator. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted ServantActivator.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static ServantActivator unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
+
/**
* This should read the servant activator, but it cannot be transferred
@@ -125,7 +148,9 @@ public abstract class ServantActivatorHelper
*/
public static ServantActivator read(InputStream input)
{
- throw new MARSHAL();
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
/**
@@ -140,6 +165,8 @@ public abstract class ServantActivatorHelper
*/
public static void write(OutputStream output, ServantActivator value)
{
- throw new MARSHAL();
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
} \ No newline at end of file
diff --git a/org/omg/PortableServer/ServantLocatorHelper.java b/org/omg/PortableServer/ServantLocatorHelper.java
index 984abdffe..082c4c586 100644
--- a/org/omg/PortableServer/ServantLocatorHelper.java
+++ b/org/omg/PortableServer/ServantLocatorHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.MARSHAL;
@@ -108,10 +110,30 @@ public abstract class ServantLocatorHelper
catch (ClassCastException ex)
{
BAD_OPERATION bad = new BAD_OPERATION();
+ bad.minor = Minor.ClassCast;
bad.initCause(ex);
throw bad;
}
}
+
+ /**
+ * Narrow the given object to the ServantLocator. For the objects that are
+ * always local, this operation does not differ from the ordinary
+ * {@link #narrow} (ClassCastException will be thrown if narrowing something
+ * different).
+ *
+ * @param obj the object to cast.
+ *
+ * @return the casted ServantLocator.
+ *
+ * @since 1.5
+ *
+ * @see OMG issue 4158.
+ */
+ public static ServantLocator unchecked_narrow(org.omg.CORBA.Object obj)
+ {
+ return narrow(obj);
+ }
/**
* This should read the servant locator, but it cannot be transferred
@@ -125,7 +147,9 @@ public abstract class ServantLocatorHelper
*/
public static ServantLocator read(InputStream input)
{
- throw new MARSHAL();
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
/**
@@ -140,6 +164,8 @@ public abstract class ServantLocatorHelper
*/
public static void write(OutputStream output, ServantLocator value)
{
- throw new MARSHAL();
+ MARSHAL m = new MARSHAL("Inappropriate");
+ m.minor = Minor.Inappropriate;
+ throw m;
}
} \ No newline at end of file
diff --git a/org/omg/PortableServer/ServantRetentionPolicyValue.java b/org/omg/PortableServer/ServantRetentionPolicyValue.java
index caf8132e6..0b6ecf62f 100644
--- a/org/omg/PortableServer/ServantRetentionPolicyValue.java
+++ b/org/omg/PortableServer/ServantRetentionPolicyValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -126,7 +128,9 @@ public class ServantRetentionPolicyValue
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code);
+ bad.minor = Minor.PolicyType;
+ throw bad;
}
}
diff --git a/org/omg/PortableServer/ThreadPolicyValue.java b/org/omg/PortableServer/ThreadPolicyValue.java
index c7d4d6367..5c771a7d6 100644
--- a/org/omg/PortableServer/ThreadPolicyValue.java
+++ b/org/omg/PortableServer/ThreadPolicyValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import gnu.CORBA.Minor;
+
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.IDLEntity;
@@ -139,7 +141,9 @@ public class ThreadPolicyValue
}
catch (ArrayIndexOutOfBoundsException ex)
{
- throw new BAD_OPERATION("Invalid enumeration code " + code);
+ BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code);
+ bad.minor = Minor.PolicyType;
+ throw bad;
}
}
diff --git a/org/omg/SendingContext/RunTime.java b/org/omg/SendingContext/RunTime.java
new file mode 100644
index 000000000..09d3d505b
--- /dev/null
+++ b/org/omg/SendingContext/RunTime.java
@@ -0,0 +1,60 @@
+/* RunTime.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.SendingContext;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Defines the base class that represents the Sending Context. The sending
+ * context provides access to information about the originator of a
+ * GIOP message. For example, when a value type is sent in a GIOP
+ * Request, the receiver may need to ask the sender about
+ * the CodeBase for the implementation of the value type.
+ *
+ * @since 1.3
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RunTime
+ extends IDLEntity, Object, RunTimeOperations, Serializable
+{
+} \ No newline at end of file
diff --git a/org/omg/SendingContext/RunTimeOperations.java b/org/omg/SendingContext/RunTimeOperations.java
new file mode 100644
index 000000000..dabcb74c0
--- /dev/null
+++ b/org/omg/SendingContext/RunTimeOperations.java
@@ -0,0 +1,57 @@
+/* RunTimeOperations.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package org.omg.SendingContext;
+
+
+/**
+ * Defines the operations, applicable for Sending Context. The sending
+ * context provides access to information about the originator of a
+ * GIOP message. For example, when a value type is sent in a GIOP
+ * Request, the receiver may need to ask the sender about
+ * the CodeBase for the implementation of the value type.
+ *
+ * Unfortunately, no public operations are defined up till 1.4 inclusive.
+ *
+ * @since 1.3
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RunTimeOperations
+{
+} \ No newline at end of file
diff --git a/resource/META-INF/services/javax.sound.midi.spi.MidiDeviceProvider b/resource/META-INF/services/javax.sound.midi.spi.MidiDeviceProvider
new file mode 100644
index 000000000..c701be55b
--- /dev/null
+++ b/resource/META-INF/services/javax.sound.midi.spi.MidiDeviceProvider
@@ -0,0 +1,3 @@
+gnu.javax.sound.midi.alsa.AlsaMidiDeviceProvider
+gnu.javax.sound.midi.dssi.DSSIMidiDeviceProvider
+
diff --git a/test/native/lib/PrimlibInterface.c b/test/native/lib/PrimlibInterface.c
deleted file mode 100644
index 47918470a..000000000
--- a/test/native/lib/PrimlibInterface.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include "PrimlibInterface.h"
-#include <primlib.h>
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapBoolean
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT jboolean JNICALL Java_PrimlibInterface_unwrapBoolean
-(JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapBoolean(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapByte
- * Signature: (Ljava/lang/Object;)B
- */
-JNIEXPORT jbyte JNICALL Java_PrimlibInterface_unwrapByte
- (JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapByte(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapShort
- * Signature: (Ljava/lang/Object;)S
- */
-JNIEXPORT jshort JNICALL Java_PrimlibInterface_unwrapShort
- (JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapShort(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapChar
- * Signature: (Ljava/lang/Object;)C
- */
-JNIEXPORT jchar JNICALL Java_PrimlibInterface_unwrapChar
- (JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapChar(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapInt
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT jint JNICALL Java_PrimlibInterface_unwrapInt
- (JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapInt(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapLong
- * Signature: (Ljava/lang/Object;)J
- */
-JNIEXPORT jlong JNICALL Java_PrimlibInterface_unwrapLong
- (JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapLong(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapFloat
- * Signature: (Ljava/lang/Object;)F
- */
-JNIEXPORT jfloat JNICALL Java_PrimlibInterface_unwrapFloat
- (JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapFloat(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapDouble
- * Signature: (Ljava/lang/Object;)D
- */
-JNIEXPORT jdouble JNICALL Java_PrimlibInterface_unwrapDouble
- (JNIEnv * env, jclass thisClass, jobject o) {
- return PRIMLIB_UnwrapDouble(env, o);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapBoolean
- * Signature: (Z)Ljava/lang/Boolean;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapBoolean
-(JNIEnv * env, jclass thisClass, jboolean val) {
- return PRIMLIB_WrapBoolean(env, val);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapByte
- * Signature: (B)Ljava/lang/Byte;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapByte
-(JNIEnv * env, jclass thisClass, jbyte val) {
- return PRIMLIB_WrapByte(env, val);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapShort
- * Signature: (S)Ljava/lang/Short;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapShort
-(JNIEnv * env, jclass thisClass, jshort val) {
- return PRIMLIB_WrapShort(env, val);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapChar
- * Signature: (C)Ljava/lang/Character;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapChar
-(JNIEnv * env, jclass thisClass, jchar val) {
- return PRIMLIB_WrapChar(env, val);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapInt
- * Signature: (I)Ljava/lang/Integer;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapInt
-(JNIEnv * env, jclass thisClass, jint val) {
- return PRIMLIB_WrapInt(env, val);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapLong
- * Signature: (J)Ljava/lang/Long;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapLong
-(JNIEnv * env, jclass thisClass, jlong val) {
- return PRIMLIB_WrapLong(env, val);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapFloat
- * Signature: (F)Ljava/lang/Float;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapFloat
-(JNIEnv * env, jclass thisClass, jfloat val) {
- return PRIMLIB_WrapFloat(env, val);
-}
-
-/*
- * Class: PrimlibInterface
- * Method: wrapDouble
- * Signature: (D)Ljava/lang/Double;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapDouble
-(JNIEnv * env, jclass thisClass, jdouble val) {
- return PRIMLIB_WrapDouble(env, val);
-}
diff --git a/test/native/lib/PrimlibInterface.h b/test/native/lib/PrimlibInterface.h
deleted file mode 100644
index 2e0463cc2..000000000
--- a/test/native/lib/PrimlibInterface.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class PrimlibInterface */
-
-#ifndef _Included_PrimlibInterface
-#define _Included_PrimlibInterface
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class: PrimlibInterface
- * Method: unwrapBoolean
- * Signature: (Ljava/lang/Object;)Z
- */
-JNIEXPORT jboolean JNICALL Java_PrimlibInterface_unwrapBoolean
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapByte
- * Signature: (Ljava/lang/Object;)B
- */
-JNIEXPORT jbyte JNICALL Java_PrimlibInterface_unwrapByte
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapShort
- * Signature: (Ljava/lang/Object;)S
- */
-JNIEXPORT jshort JNICALL Java_PrimlibInterface_unwrapShort
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapChar
- * Signature: (Ljava/lang/Object;)C
- */
-JNIEXPORT jchar JNICALL Java_PrimlibInterface_unwrapChar
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapInt
- * Signature: (Ljava/lang/Object;)I
- */
-JNIEXPORT jint JNICALL Java_PrimlibInterface_unwrapInt
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapLong
- * Signature: (Ljava/lang/Object;)J
- */
-JNIEXPORT jlong JNICALL Java_PrimlibInterface_unwrapLong
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapFloat
- * Signature: (Ljava/lang/Object;)F
- */
-JNIEXPORT jfloat JNICALL Java_PrimlibInterface_unwrapFloat
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: unwrapDouble
- * Signature: (Ljava/lang/Object;)D
- */
-JNIEXPORT jdouble JNICALL Java_PrimlibInterface_unwrapDouble
- (JNIEnv *, jclass, jobject);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapBoolean
- * Signature: (Z)Ljava/lang/Boolean;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapBoolean
- (JNIEnv *, jclass, jboolean);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapByte
- * Signature: (B)Ljava/lang/Byte;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapByte
- (JNIEnv *, jclass, jbyte);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapShort
- * Signature: (S)Ljava/lang/Short;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapShort
- (JNIEnv *, jclass, jshort);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapChar
- * Signature: (C)Ljava/lang/Character;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapChar
- (JNIEnv *, jclass, jchar);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapInt
- * Signature: (I)Ljava/lang/Integer;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapInt
- (JNIEnv *, jclass, jint);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapLong
- * Signature: (J)Ljava/lang/Long;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapLong
- (JNIEnv *, jclass, jlong);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapFloat
- * Signature: (F)Ljava/lang/Float;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapFloat
- (JNIEnv *, jclass, jfloat);
-
-/*
- * Class: PrimlibInterface
- * Method: wrapDouble
- * Signature: (D)Ljava/lang/Double;
- */
-JNIEXPORT jobject JNICALL Java_PrimlibInterface_wrapDouble
- (JNIEnv *, jclass, jdouble);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/test/native/lib/PrimlibTest.java b/test/native/lib/PrimlibTest.java
deleted file mode 100644
index 94b2fb41c..000000000
--- a/test/native/lib/PrimlibTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-public class PrimlibTest {
- static {
- System.loadLibrary("jnilinktest");
- }
-
- public static void main(String args[]) {
- Object[] o = new Object[8];
- o[0] = new Boolean(true);
- o[1] = new Byte((byte)1);
- o[2] = new Short((short)2);
- o[3] = new Character((char)3);
- o[4] = new Integer(4);
- o[5] = new Long(5L);
- o[6] = new Float(6F);
- o[7] = new Double(7D);
-
- String[] s = {"boolean", "byte", "short", "char", "int", "long", "float", "double"};
- for(int i=0;i<8;i++) {
- try {
- System.out.println(PrimlibInterface.unwrapBoolean(o[i]) ? "CONVERTED: UnwrapBoolean(" + s[i] + ")" : "INCORRECT: UnwrapBoolean(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapBoolean(" + s[i] + ")");
- }
-
- try {
- System.out.println(PrimlibInterface.unwrapByte(o[i]) == i ? "CONVERTED: UnwrapByte(" + s[i] + ")" : "INCORRECT: UnwrapByte(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapByte(" + s[i] + ")");
- }
-
- try {
- System.out.println(PrimlibInterface.unwrapShort(o[i]) == i ? "CONVERTED: UnwrapShort(" + s[i] + ")" : "INCORRECT: UnwrapShort(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapShort(" + s[i] + ")");
- }
-
- try {
- System.out.println(PrimlibInterface.unwrapChar(o[i]) == i ? "CONVERTED: UnwrapChar(" + s[i] + ")" : "INCORRECT: UnwrapChar(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapChar(" + s[i] + ")");
- }
-
- try {
- System.out.println(PrimlibInterface.unwrapInt(o[i]) == i ? "CONVERTED: UnwrapInt(" + s[i] + ")" : "INCORRECT: UnwrapInt(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapInt(" + s[i] + ")");
- }
-
- try {
- System.out.println(PrimlibInterface.unwrapLong(o[i]) == i ? "CONVERTED: UnwrapLong(" + s[i] + ")" : "INCORRECT: UnwrapLong(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapLong(" + s[i] + ")");
- }
-
- try {
- System.out.println(PrimlibInterface.unwrapFloat(o[i]) == i ? "CONVERTED: UnwrapFloat(" + s[i] + ")" : "INCORRECT: UnwrapFloat(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapFloat(" + s[i] + ")");
- }
-
- try {
- System.out.println(PrimlibInterface.unwrapDouble(o[i]) == i ? "CONVERTED: UnwrapDouble(" + s[i] + ")" : "INCORRECT: UnwrapDouble(" + s[i] + ")");
- } catch(Exception E) {
- System.out.println("EXCEPTION: UnwrapDouble(" + s[i] + ")");
- }
- }
- }
-}
-
-class PrimlibInterface {
- static native boolean unwrapBoolean(Object o);
- static native byte unwrapByte(Object o);
- static native short unwrapShort(Object o);
- static native char unwrapChar(Object o);
- static native int unwrapInt(Object o);
- static native long unwrapLong(Object o);
- static native float unwrapFloat(Object o);
- static native double unwrapDouble(Object o);
-
- static native Boolean wrapBoolean(boolean val);
- static native Byte wrapByte(byte val);
- static native Short wrapShort(short val);
- static native Character wrapChar(char val);
- static native Integer wrapInt(int val);
- static native Long wrapLong(long val);
- static native Float wrapFloat(float val);
- static native Double wrapDouble(double val);
-}
diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java
index 4fe124036..a777462aa 100644
--- a/vm/reference/java/lang/VMClassLoader.java
+++ b/vm/reference/java/lang/VMClassLoader.java
@@ -40,6 +40,7 @@ exception statement from your version. */
package java.lang;
import gnu.classpath.SystemProperties;
+import gnu.classpath.Configuration;
import java.io.File;
import java.io.IOException;
@@ -63,6 +64,48 @@ import java.util.zip.ZipFile;
*/
final class VMClassLoader
{
+
+
+ /** packages loaded by the bootstrap class loader */
+ static final HashMap definedPackages = new HashMap();
+
+ /**
+ * Converts the array string of native package names to
+ * Packages. The packages are then put into the
+ * definedPackages hashMap
+ */
+ static
+ {
+ String[] packages = getBootPackages();
+
+ if( packages != null)
+ {
+ String specName =
+ SystemProperties.getProperty("java.specification.name");
+ String vendor =
+ SystemProperties.getProperty("java.specification.vendor");
+ String version =
+ SystemProperties.getProperty("java.specification.version");
+
+ Package p;
+
+ for(int i = 0; i < packages.length; i++)
+ {
+ p = new Package(packages[i],
+ specName,
+ vendor,
+ version,
+ "GNU Classpath",
+ "GNU",
+ Configuration.CLASSPATH_VERSION,
+ null);
+
+ definedPackages.put(packages[i], p);
+ }
+ }
+ }
+
+
/**
* Helper to define a class using a string of bytes. This assumes that
* the security checks have already been performed, if necessary.
@@ -119,6 +162,9 @@ final class VMClassLoader
return null;
}
+ /** jars from property java.boot.class.path */
+ static final HashMap bootjars = new HashMap();
+
/**
* Helper to get a list of resources from the bootstrap class loader.
*
@@ -139,8 +185,9 @@ final class VMClassLoader
{
try
{
- v.add(new URL("file://"
- + new File(file, name).getAbsolutePath()));
+ File f = new File(file, name);
+ if (!f.exists()) continue;
+ v.add(new URL("file://" + f.getAbsolutePath()));
}
catch (MalformedURLException e)
{
@@ -150,30 +197,28 @@ final class VMClassLoader
else if (file.isFile())
{
ZipFile zip;
- try
- {
- zip = new ZipFile(file);
- }
- catch (IOException e)
- {
- continue;
- }
- String zname = name.startsWith("/") ? name.substring(1) : name;
- try
- {
- if (zip.getEntry(zname) == null)
+ synchronized(bootjars)
+ {
+ zip = (ZipFile) bootjars.get(file.getName());
+ }
+ if(zip == null)
+ {
+ try
+ {
+ zip = new ZipFile(file);
+ synchronized(bootjars)
+ {
+ bootjars.put(file.getName(), zip);
+ }
+ }
+ catch (IOException e)
+ {
continue;
- }
- finally
- {
- try
- {
- zip.close();
- }
- catch (IOException e)
- {
- }
- }
+ }
+ }
+ String zname = name.startsWith("/") ? name.substring(1) : name;
+ if (zip.getEntry(zname) == null)
+ continue;
try
{
v.add(new URL("jar:file://"
@@ -188,29 +233,41 @@ final class VMClassLoader
return v.elements();
}
+
+ /**
+ * Returns a String[] of native package names. The default
+ * implementation returns an empty array, or you may decide
+ * this needs native help.
+ */
+ private static String[] getBootPackages()
+ {
+ return new String[0];
+ }
+
+
/**
- * Helper to get a package from the bootstrap class loader. The default
- * implementation of returning null may be adequate, or you may decide
- * that this needs some native help.
+ * Helper to get a package from the bootstrap class loader.
*
* @param name the name to find
* @return the named package, if it exists
*/
static Package getPackage(String name)
{
- return null;
+ return (Package)definedPackages.get(name);
}
+
+
/**
- * Helper to get all packages from the bootstrap class loader. The default
- * implementation of returning an empty array may be adequate, or you may
- * decide that this needs some native help.
+ * Helper to get all packages from the bootstrap class loader.
*
* @return all named packages, if any exist
*/
static Package[] getPackages()
{
- return new Package[0];
+ Package[] packages = new Package[definedPackages.size()];
+ definedPackages.values().toArray(packages);
+ return packages;
}
/**
diff --git a/vm/reference/java/lang/VMThread.java b/vm/reference/java/lang/VMThread.java
index 4f886cc77..b864b7f81 100644
--- a/vm/reference/java/lang/VMThread.java
+++ b/vm/reference/java/lang/VMThread.java
@@ -379,15 +379,11 @@ final class VMThread
*/
static void sleep(long ms, int ns) throws InterruptedException
{
-
- // Round up
- ms += (ns != 0) ? 1 : 0;
-
// Note: JDK treats a zero length sleep is like Thread.yield(),
// without checking the interrupted status of the thread.
// It's unclear if this is a bug in the implementation or the spec.
// See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203
- if (ms == 0)
+ if (ms == 0 && ns == 0)
{
if (Thread.interrupted())
throw new InterruptedException();
@@ -407,11 +403,12 @@ final class VMThread
{
while (true)
{
- vt.wait(ms);
+ vt.wait(ms, ns);
now = System.currentTimeMillis();
if (now >= end)
break;
ms = end - now;
+ ns = 0;
}
}
}
diff --git a/vm/reference/java/security/VMAccessController.java b/vm/reference/java/security/VMAccessController.java
index 7058a5e34..da13c6889 100644
--- a/vm/reference/java/security/VMAccessController.java
+++ b/vm/reference/java/security/VMAccessController.java
@@ -76,7 +76,7 @@ final class VMAccessController
DEFAULT_CONTEXT = new AccessControlContext(domain);
}
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = gnu.classpath.Configuration.DEBUG;
private static void debug(String msg)
{
System.err.print(">>> VMAccessController: ");
@@ -108,6 +108,8 @@ final class VMAccessController
LinkedList stack = (LinkedList) contexts.get();
if (stack == null)
{
+ if (DEBUG)
+ debug("no stack... creating ");
stack = new LinkedList();
contexts.set(stack);
}
@@ -134,6 +136,10 @@ final class VMAccessController
if (stack.isEmpty())
contexts.set(null);
}
+ else if (DEBUG)
+ {
+ debug("no stack during pop?????");
+ }
}
/**
@@ -166,7 +172,7 @@ final class VMAccessController
String[] methods = (String[]) stack[1];
if (DEBUG)
- debug(">>> got trace of length " + classes.length);
+ debug("got trace of length " + classes.length);
HashSet domains = new HashSet();
HashSet seenDomains = new HashSet();
@@ -185,8 +191,9 @@ final class VMAccessController
if (DEBUG)
{
- debug(">>> checking " + clazz + "." + method);
- debug(">>> loader = " + clazz.getClassLoader());
+ debug("checking " + clazz + "." + method);
+ // subject to getClassLoader RuntimePermission
+ debug("loader = " + clazz.getClassLoader());
}
// If the previous frame was a call to doPrivileged, then this is
@@ -198,14 +205,16 @@ final class VMAccessController
&& method.equals ("doPrivileged"))
{
// If there was a call to doPrivileged with a supplied context,
- // return that context.
+ // return that context. If using JAAS doAs*, it should be
+ // a context with a SubjectDomainCombiner
LinkedList l = (LinkedList) contexts.get();
if (l != null)
context = (AccessControlContext) l.getFirst();
privileged = 1;
}
- ProtectionDomain domain = clazz.getProtectionDomain();
+ // subject to getProtectionDomain RuntimePermission
+ ProtectionDomain domain = clazz.getProtectionDomain();
if (domain == null)
continue;
@@ -225,14 +234,25 @@ final class VMAccessController
ProtectionDomain[] result = (ProtectionDomain[])
domains.toArray(new ProtectionDomain[domains.size()]);
- // Intersect the derived protection domain with the context supplied
- // to doPrivileged.
if (context != null)
- context = new AccessControlContext(result, context,
- IntersectingDomainCombiner.SINGLETON);
+ {
+ DomainCombiner dc = context.getDomainCombiner ();
+ // If the supplied context had no explicit DomainCombiner, use
+ // our private version, which computes the intersection of the
+ // context's domains with the derived set.
+ if (dc == null)
+ context = new AccessControlContext
+ (IntersectingDomainCombiner.SINGLETON.combine
+ (result, context.getProtectionDomains ()));
+ // Use the supplied DomainCombiner. This should be secure,
+ // because only trusted code may create an
+ // AccessControlContext with a custom DomainCombiner.
+ else
+ context = new AccessControlContext (result, context, dc);
+ }
// No context was supplied. Return the derived one.
else
- context = new AccessControlContext(result);
+ context = new AccessControlContext (result);
inGetContext.set(Boolean.FALSE);
return context;