diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2005-08-07 18:34:07 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2005-08-07 18:34:07 +0000 |
commit | f251c44339f107b7c5447a1309964cdee46d47c0 (patch) | |
tree | 25786ac62beed90b33debcdf124bb01705f82e8c | |
parent | 728f1bf87e692c7e5f68e4048b4e8025a1d97afd (diff) | |
download | classpath-f251c44339f107b7c5447a1309964cdee46d47c0.tar.gz |
2005-08-07 Andrew John Hughes <gnu_andrew@member.fsf.org>
HEAD-->generics-branch merge for 2005/07/31-2005/08/07.
109 files changed, 7609 insertions, 1511 deletions
@@ -1,8 +1,534 @@ +2005-08-05 Lillian Angel <langel@redhat.com> + + * javax/swing/plaf/basic/BasicTreeUI.java: + (getPathBounds): Changed to use TreeNode and not + DefaultMutableTreeNode. + (getPathForRow): Likewise. + (getRowCount): Likewise. + (getPreferredSize): Likewise. + (keyPressed): Likewise. + (paintNode): Likewise. + (getCellLocation): Likewise. + (paintRecursive): Likewise. + (paintControlIcons): Likewise. + (getNextVisibleNode): Likewise. + (getPreviousVisibleNode): Likewise. + (getNextNode): Implemented because not using DefaultMutableTreeNode. + (getPreviousNode): Implemented + (getNextSibling): Implemented + (getPreviousSibling): Implemented + (getPathToRoot): Implemented + (getLevel): Implemented + +2005-08-05 Mark Wielaard <mark@klomp.org> + + * java/awt/datatransfer/FlavorEvent.java: New class. + * java/awt/datatransfer/FlavorListener.java: Likewise. + * java/awt/datatransfer/Clipboard.java (name): Made final. + (listeners): New final ArrayList field. + (setContents): Reimplemented. + (getAvailableDataFlavors): New method. + (isDataFlavorAvailable): Likewise. + (getData): Likewise. + (addFlavorListener): Likewise. + (removeFlavorListener): Likewise. + (getFlavorListeners): Likewise. + * java/awt/datatransfer/DataFlavor.java (javaFileListFlavor): + Construct with mime media-type application/x-java-file-list. + (DataFlavor(String mimeType, String humanPresentableName)): Call + constructor that uses given mimeType. + (getSubType): Reimplemented. + (getParameter): Handle 'vitual' humanPresentableName parameter. + (isMimeTypeEqual): Reimplement. + (isRepresentationClassRemote): Implement. + (toString): Add formatting. + +2005-08-05 Lillian Angel <langel@redhat.com> + + * java/awt/GridBagLayout.java + (setConstraints): Removed checks in if statements because if the height + or width is less than 0, it should be updated to a positive number in + all cases. + +2005-08-05 Mark Wielaard <mark@klomp.org> + + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Include + jcl.h. + (createRawData): Removed unused variable method. + (getData): Removed unused variable field. + * native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c + (createRawData): Removed unused variable method. + (getData): Removed unused variable field. + * native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c + (createRawData): Removed unused variable method. + (getData): Removed unused variable field. + * native/jni/java-nio/java_nio_VMDirectByteBuffer.c + (Java_java_nio_VMDirectByteBuffer_init): Removed. + * vm/reference/java/nio/VMDirectByteBuffer.java (init): Removed. + * include/java_nio_VMDirectByteBuffer.h: Regenerated. + +2005-08-05 Roman Kennke <roman@kennke.org> + + * java/awt/Container.java: + (preferredSize): Call getLayout() instead of directly referencing + the private field. This makes components work that override + getLayout(). + (minimumSize): Call getLayout() instead of directly referencing + the private field. This makes components work that override + getLayout(). Use cached size if component is still valid. + (maximumSize): Call getLayout() instead of directly referencing + the private field. This makes components work that override + getLayout(). Use cached size if component is still valid. + (update): If we are a top-level-container, call super.update(), + otherwise directly call paint(). + (visitChildren): Also visit children that are itself Containers. + * java/awt/Component.java + (update): Clear the background only for lightweight and top-level + components. + +2005-08-05 Lillian Angel <langel@redhat.com> + + * javax/swing/plaf/basic/BasicGraphicsUtils.java + (getPreferredButtonSize): Added horizontalAdjustment to width + to create gap at end of label text. + * javax/swing/plaf/basic/BasicMenuItemUI.java + (getPreferredSize): Removed "*2" since fix was moved to + BasicGraphicsUtils + +2005-08-05 Roman Kennke <roman@kennke.org> + + * javax/swing/text/DefaultCaret.java: Added API comments all + over. + * javax/swing/text/DefaultEditorKit.java: Added API comments + all over. + +2005-08-05 Jeroen Frijters <jeroen@frijters.net> + + * java/io/ObjectInputStream.java + (read(byte[],int,int)): Simplified and fixed bug 23236. + +2005-08-04 Aaron Luchko <aluchko@redhat.com> + + * gnu/classpath/jdwp/processor/MethodCommandSet.java: Implemented + the Method CommandSet. + +2005-08-04 Lillian Angel <langel@redhat.com> + + * javax/swing/plaf/basic/BasicMenuItemUI.java + (getPreferredSize): Multiplied defaultTextIconGap by 2, + so there is equal space around the MenuItem + +2005-08-04 Lillian Angel <langel@redhat.com> + + * javax/swing/plaf/basic/BasicMenuItemUI.java + (paintIcon): Added in border painting code for MenuItem + * javax/swing/plaf/metal/MetalLookAndFeel.java: + Added in default for CheckBox border + +2005-08-04 Roman Kennke <roman@kennke.org> + + * java/awt/BorderLayout.java: Reformatted this file to meet our + coding standards. + +2005-08-04 Roman Kennke <roman@kennke.org> + + * java/awt/BorderLayout.java + (layoutContainer): Replaced getSize() call with getWidth() and + getHeight(). This avoids heap allocation and fixes a bug in + an application here. + +2005-08-04 Lillian Angel <langel@redhat.com> + + * javax/swing/JCheckBox.java + (init): Moved these to ui + * javax/swing/plaf/basic/BasicCheckBoxUI.java + (installUI): initalized icons + * javax/swing/plaf/metal/MetalLookAndFeel.java: + Took out CheckBoxMenuItem defaults because did not + work as expected. For now it uses the BasicL&F's defaults. + +2005-08-04 Anthony Balkissoon <abalkiss@redhat.com> + + * javax/swing/JList.java: + (getFirstVisibleIndex): Translate visible rectangle by one less pixel. + (getLastVisibleIndex): Likewise. + +2005-08-04 Lillian Angel <langel@redhat.com> + + * javax/swing/JCheckBox.java + (init): Initialized icons. Was not working otherwise. + * javax/swing/plaf/basic/BasicLookAndFeel.java: + Added in checkIcon for the CheckBox. + * javax/swing/plaf/metal/MetalLookAndFeel.java: + Added in checkIcon for CheckBox and defaults for + CheckBoxMenuItem. + +2005-08-03 Lillian Angel <langel@redhat.com> + + * javax/swing/JCheckBoxMenuItem.java + (installUI): set the items visible. Fixes exceptions that are + thrown because item is not explicitly set visible. + 2005-08-03 Ewout Prangsma <ewout@prangsma.net> * java/lang/Enum.java: (valueOf(Class<S>,String)): Implemented. +2005-08-03 Roman Kennke <roman@kennke.org> + + * javax/swing/plaf/basic/BasicViewportUI.java + (paintSimple): Corrected the clip that is used to draw the + viewport's content. This fixes scrolling in JScrollPane and + JViewport. + +2005-08-03 Lillian Angel <langel@redhat.com> + + * javax/swing/plaf/basic/BasicLookAndFeel.java: + Changed the fonts from Helvetica to Dialog. + +2005-08-03 Guilhem Lavaux <guilhem@kaffe.org> + + * include/java_nio_VMDirectByteBuffer.h: + Regenerated. + + * native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c + (getData): Fixed function call. + + Reported by: Andreas Tobler <toa@pop.agri.ch> + +2005-08-03 Lillian Angel <langel@redhat.com> + + * javax/swing/plaf/basic/BasicIconFactory.java: + (getMenuItemCheckIcon): Implemented so a check mark is drawn when + the item is selected. + * javax/swing/plaf/basic/BasicLookAndFeel.java: + Modified the checkbox defaults + * javax/swing/plaf/basic/BasicMenuItemUI.java: + (paintMenuItem): Changed to only draw check when item is selected. + +2005-08-03 Roman Kennke <roman@kennke.org> + + * java/awt/FontMetrics.java + (charsWidth): Iterate to len + offset instead to len. + +2005-08-03 Guilhem Lavaux <guilhem@kaffe.org> + + * native/jni/classpath/jcl.c + (JCL_NewRawDataObject): Fixed typo. + +2005-08-03 Guilhem Lavaux <guilhem@kaffe.org> + + * gnu/classpath/Pointer.java, + gnu/classpath/Pointer32.java, + gnu/classpath/Pointer64.java, + gnu/classpath/RawData.java, + gnu/classpath/RawData32.java, + gnu/classpath/RawData64.java, + gnu/java/awt/peer/gtk/GtkImage.java, + gnu/java/nio/charset/iconv/IconvDecoder.java, + gnu/java/nio/charset/iconv/IconvEncoder.java, + java/nio/Buffer.java, + java/nio/DirectByteBufferImpl.java, + java/nio/MappedByteBufferImpl.java, + native/jni/classpath/jcl.c, + native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c, + native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c, + native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c, + native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c, + native/jni/java-nio/java_nio_MappedByteBufferImpl.c, + native/jni/java-nio/java_nio_VMDirectByteBuffer.c, + vm/reference/java/nio/VMDirectByteBuffer.java: Renamed + references to gnu/classpath/RawData to gnu/classpath/Pointer. + +2005-08-03 Guilhem Lavaux <guilhem@kaffe.org> + + * java-nio/gnu_java_nio_channels_FileChannelImpl.c + (mapImpl): Fixed typo. + +2005-08-03 Guilhem Lavaux <guilhem@kaffe.org> + + * classpath/jcl.c + (JCl_NewRawDataObject): Added error handling. + + * classpath/jcl.h + (jpointer): New integer type to represent a pointer. + + * gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c, + java-nio/gnu_java_nio_channels_FileChannelImpl.c, + java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c, + java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c, + java-nio/java_nio_MappedByteBufferImpl.c, + java-nio/java_nio_VMDirectByteBuffer.c, + xmlj/xmlj_util.c: Use JCL functions instead of directly + accessing gnu/classpath/RawData. + +2005-08-03 Roman Kennke <roman@kennke.org> + + * javax/swing/text/AttributeSet.java: Added some API comments + to class description. + * javax/swing/text/BadLocationException.java: Added / fixed + API comments all over. + * javax/swing/text/Caret.java: Added API comments all over. + +2005-08-02 Roman Kennke <roman@kennke.org> + + * java/awt/Component.java + (getBounds): Removed debug statements that accidentally slipped in. + +2005-08-02 Anthony Balkissoon <abalkiss@redhat.com> + + * javax/swing/JTable.java: + (getCellRect): Height should be the row height, not the entire table + height. + (getRowHeight): New public method, part of API. + * javax/swing/JViewport.java: + (scrollRectToVisible): Fixed buggy scrolling conditions. + * javax/swing/plaf/basic/BasicTableUI.java: + (KeyHandler.keyPressed): Implemented PAGE-UP, PAGE-DOWN, CTRL-PAGE-UP, + and CTRL-PAGE-DOWN key actions. Also added line to scroll the table + appropriately after changing the selection. + (KeyHandler.getFirstVisibleColumnIndex): New implementation method. + (KeyHandler.getLastVisibleColumnIndex): Likewise. + (KeyHandler.getFirstVisibleRowIndex): Likewise. + (KeyHandler.getLastVisibleRowIndex): Likewise. + +2005-08-02 Roman Kennke <roman@kennke.org> + + * javax/swing/text/AbstractDocument.java + (AbstractElement.AbstractElement): Create an empty AttributeSet + if the argument s == null. + (AbstractElement.getAttribute): Return the element itself instead + of the wrapped attributes. + +2005-08-02 Roman Kennke <roman@kennke.org> + + * java/awt/Toolkit.java + (createCustomCursor): Added check for headless environment. + (getBestCursorSize): Added check for headless environment. + +2005-08-02 Lillian Angel <langel@redhat.com> + + * javax/swing/text/GapContent.java + (shiftGap): Changed to used '&&'. both indexes should be + greater than 0. + +2005-08-02 Lillian Angel <langel@redhat.com> + + * javax/swing/text/GapContent.java: + Formatting code. + +2005-08-02 Lillian Angel <langel@redhat.com> + + * javax/swing/text/GapContent.java + (shiftGap): Added in if statement to check if indexes are negative. + Does not work properly if they are. + +2005-08-02 Roman Kennke <roman@kennke.org> + + * javax/swing/plaf/basic/BasicTextUI.java + (RootView.viewToModel): New method. + * javax/swing/text/BoxView.java + (isBefore): New method. This is a stub method to implement the + new abstract method from CompositeView. + (isAfter): New method. This is a stub method to implement the + new abstract method from CompositeView. + (getViewAtPoint): New method. This is a stub method to implement the + new abstract method from CompositeView. + (childAllocation): New method. This is a stub method to implement the + new abstract method from CompositeView. + * javax/swing/text/ComponentView.java + (viewToModel): New method. This is a stub method to implement the + new abstract method from View. + * javax/swing/text/CompositeView.java + (loadChildren): Implemented new method. + (setParent): Implemented new method. + (getViewCount): Implemented new method. + (getView): Implemented new method. + (replace): Implemented new method. + (getChildAllocation): Implemented new method. + (modelToView(int, Shape, Position.Bias)): Implemented this method. + (modelToView(int, Position.Bias, int, Position.Bias, Shape): + Implemented new method. + (viewToModel): Implemented new method. + (getNextVisualPositionFrom): Implemented new method. + (getViewIndex): Implemented new method. + (isBefore): New abstract method. + (isAfter): New abstract method. + (getViewAtPoint): New abstract method. + (childAllocation): New abstract method. + (getViewAtPosition): Implemented new method. + (getViewIndexAtPosition): Implemented new method. + (getInsideAllocation): Implemented new method. + (setParagraphInsets): Implemented new method. + (setInsets): Implemented new method. + (getLeftInset): Implemented new method. + (getRightInset): Implemented new method. + (getTopInset): Implemented new method. + (getBottomInset): Implemented new method. + (getNextNorthSouthVisualPositionFrom): New method. + (getNextEastWestVisualPositionFrom): New method. + (flipEastAndWestAtEnds): Implemented new method. + * javax/swing/text/GlyphView.java + (viewToModel): New method. This is a stub method to implement the + new abstract method from View. + * javax/swing/text/IconView.java + (viewToModel): New method. This is a stub method to implement the + new abstract method from View. + * javax/swing/text/PlainView.java + (viewToModel): New method. This is a stub method to implement the + new abstract method from View. + * javax/swing/text/View.java + (viewToModel): New abstract method. + +2005-08-02 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + * org/omg/DynamicAny/DynValueCommon.java: Inherit from + DynValueOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable. + * org/omg/DynamicAny/DynValueCommonOperations.java: Inherit from + DynAnyOperations. + * org/omg/DynamicAny/DynAnyHelper.java, + org/omg/DynamicAny/DynStructHelper.java, + org/omg/DynamicAny/DynUnionHelper.java, + org/omg/DynamicAny/DynValueHelper.java, + org/omg/DynamicAny/DynAnyFactoryHelper.java, + org/omg/DynamicAny/DynArrayHelper.java, + org/omg/DynamicAny/DynEnumHelper.java, + org/omg/DynamicAny/DynFixedHelper.java, + org/omg/DynamicAny/DynSequenceHelper.java: New files. + +2005-08-01 Andreas Tobler <a.tobler@schweiz.ch> + + * examples/README: Add GNULookAndFeel.java to the compile command. + +2005-08-01 Mark Wielaard <mark@klomp.org> + + * examples/gnu/classpath/examples/swing/Demo.java (mkTreeWorld): + Remove double declaration of int i. + +2005-08-01 Andreas Tobler <a.tobler@schweiz.ch> + + * examples/gnu/classpath/examples/swing/Demo.java: Exit when + pressing 'Close' on the panel. + +2005-08-01 Andreas Tobler <a.tobler@schweiz.ch> + + * configure.ac (LIBVERSION): Check against darwin to set module + 'no' for it. Modules under darwin are not linkable. + +2005-08-01 Roman Kennke <roman@kennke.org> + + * javax/swing/text/AttributeSet.java: Added API comments all over. + +2005-08-01 Roman Kennke <roman@kennke.org> + + * javax/swing/text/AbstractDocument.java: Added API comments all over. + +2005-08-01 Jeroen Frijters <jeroen@frijters.net> + + * java/lang/ClassLoader.java + (defineClass(String,byte[],int,int,ProtectionDomain), + resolveClass, findSystemClass, setSigners, findLoadedClass): + Added call to checkInitialized(). + (checkInitialized): New method. + +2005-08-01 Jeroen Frijters <jeroen@frijters.net> + + * NEWS: Added info about VM interfaces changes. + * java/lang/Class.java + (forName(String), forName(String, boolean, ClassLoader)): Simplified + VM interface. + * java/lang/ClassLoader.java + (loadedClasses): Removed field. + (defineClass(String,byte[],int,int,ProtectionDomain)): Removed + code to add class to loadedClasses. + * vm/reference/java/lang/VMClass.java + (forName(String)): Removed method. + (forName(String,boolean,ClassLoader)): New method. + (initialize): Removed method. + (loadArrayClass): Removed method. + * vm/reference/java/lang/VMClassLoader.java + (USE_VM_CACHE): Removed field. + (findLoadedClass): Made native. + +2005-08-01 Mark Wielaard <mark@klomp.org> + + Reported by Wolfgang Baer <WBaer@gmx.de> + * javax/swing/text/GapContent.java (shiftGap): Use new + CapContentPosition in binarySearch. + (shiftEnd): Likewise. + +2005-08-01 Mark Wielaard <mark@klomp.org> + + * doc/www.gnu.org/bugs.wml: New file. + * doc/www.gnu.org/newsitems.txt: Add bugzilla entry. + * doc/www.gnu.org/events/events.wml: Correct Fosdem 2005 date. + * doc/www.gnu.org/include/layout.wml: Direct bug reports to bugs.html. + +2005-08-01 Jan Roehrich <jan@roehrich.info> + + * javax.swing.plaf.basic.BasicTreeUI: Method drawCentered + added / corrected javadoc issues in paintHorizonalLine + and paintVerticalLine / fixed getRightChildIndent signature + (problem probably caused by copy/paste) + +2005-08-01 Jan Roehrich <jan@roehrich.info> + + * javax.swing.plaf.basic.BasicTreeUI: paintVerticalLine and + paintHorizontalLine added. + +2005-07-31 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + org/omg/DynamicAny/DynValueOperations.java, + org/omg/DynamicAny/DynAnyFactory.java, + org/omg/DynamicAny/DynAnyFactoryOperations.java, + org/omg/DynamicAny/DynValue.java, + org/omg/DynamicAny/DynValueBox.java, + org/omg/DynamicAny/DynValueBoxOperations.java, + org/omg/DynamicAny/DynValueCommon.java, + org/omg/DynamicAny/DynValueCommonOperations.java: New files. + +2005-07-31 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + * org/omg/DynamicAny/DynFixedOperations.java, + org/omg/DynamicAny/DynEnum.java, + org/omg/DynamicAny/DynArrayOperations.java: Inherit from + DynAnyOperations. + * org/omg/DynamicAny/NameDynAnyPair.java: Inherit from + org.omg.CORBA.portable.IDLEntity. + * org/omg/DynamicAny/DynAnyOperations.java + (assign, current_component): Fixes in throws declaration. + * org/omg/DynamicAny/DynEnumOperations.java, + org/omg/DynamicAny/DynSequenceOperations.java, + org/omg/DynamicAny/DynStructOperations.java, + org/omg/DynamicAny/DynUnionOperations.java, + org/omg/DynamicAny/DynAny.java, + org/omg/DynamicAny/DynFixed.java, + org/omg/DynamicAny/DynSequence.java, + org/omg/DynamicAny/DynStruct.java, + org/omg/DynamicAny/DynUnion.java, + org/omg/DynamicAny/DynArray.java, + org/omg/DynamicAny/NameValuePair.java: Reformatted. + +2005-07-31 Mark Wielaard <mark@klomp.org> + + * gnu/java/nio/FileLockImpl.java: Mark class final. + (ch): Removed field. + (valid): New field. + (FileLockImpl): Set valid to true. + (isValid): Test and set valid field. + (release): Release lock if it is still valid. + * java/nio/channels/FileLock.java: Mark all fields private final. + * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c + (Java_gnu_java_nio_channels_FileChannelImpl_lock): Translate + Long.MAX_VALUE to zero for fcntl. + (Java_gnu_java_nio_channels_FileChannelImpl_unlock): Likewise. + +2005-07-31 Audrius Meskauskas <AudriusA@Bioinformatics.org> + + * scripts/eclipse-gnu.xml: Drop extends, implements, + throws into new line. + 2005-07-31 Jan Roehrich <jan@roehrich.info> * javax.swing.plaf.basic.BasicTreeUI: fixed indentation. @@ -1,3 +1,6 @@ +* Simplified the Class/VMClass interface. +* Removed loadedClasses map from ClassLoader. It's now the VMs responsibility + to manage the list of defined and loaded classes for each class loader. * Moved native methods from java.lang.reflect.Proxy to VMProxy. * Added hook to VMClassLoader to allow VM to do class caching. * The Portable Object Adapter should support the output of the diff --git a/configure.ac b/configure.ac index daf537c81..6f9a0156a 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,16 @@ dnl We will not track/change lib version until we reach version 1.0 dnl at which time we'll have to be more anal about such things dnl ----------------------------------------------------------- AC_SUBST(LIBVERSION, "0:0:0") -CLASSPATH_MODULE="-module -version-info ${LIBVERSION} -no-undefined" +case "$host_os" in + darwin*) + cp_module="" + ;; + *) + cp_module="-module" + ;; +esac + +CLASSPATH_MODULE="${cp_module} -version-info ${LIBVERSION} -no-undefined" AC_SUBST(CLASSPATH_MODULE) AC_PREREQ(2.59) diff --git a/doc/www.gnu.org/bugs.wml b/doc/www.gnu.org/bugs.wml new file mode 100755 index 000000000..e1b7ddf47 --- /dev/null +++ b/doc/www.gnu.org/bugs.wml @@ -0,0 +1,46 @@ +#include "include/layout.wml" + +<subject "GNU Classpath Bug Reports"> + +<box> + +<boxtitle>GNU Classpath::Bugs</boxtitle> +<boxitem> +Unfortunately GNU Classpath is not bug free yet. +<br> +But you can help! +<br> +If you find a bug please report it here. +</boxitem> + +<boxtitle>Query</boxtitle> +<boxitem> +Please first check the following lists: +<ul> +<li><a href="http://gcc.gnu.org/bugzilla/query.cgi?product=classpath">Query bugs</a></li> +<li><a href="http://gcc.gnu.org/bugzilla/buglist.cgi?product=classpath&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=SUSPENDED&bug_status=WAITING&bug_status=REOPENED">All open bugs</a></li> +<li><a href="http://gcc.gnu.org/bugzilla/duplicates.cgi?sortby=count&product=classpath">Most Frequently Reported Bugs</a></li> +</ul> +<p> +</boxitem> + +<boxtitle>Report</boxtitle> +<boxitem> +If your bug wasn't in any of the above lists, please +<ul> +<li><a href="http://gcc.gnu.org/bugzilla/enter_bug.cgi?product=classpath">Report it</a></li> +<ul> +<p> +</boxitem> + +<boxtitle>Overview</boxtitle> +<boxitem> +You can also look at some pretty +<ul> +<li><a href="http://gcc.gnu.org/bugzilla/reports.cgi?product=classpath&datasets=NEW%3A&datasets=ASSIGNED%3A&datasets=REOPENED%3A&datasets=UNCONFIRMED%3A&datasets=RESOLVED%3A&datasets=VERIFIED%3A&datasets=CLOSED%3A&datasets=FIXED%3A&datasets=INVALID%3A&datasets=WONTFIX%3A&datasets=DUPLICATE%3A&datasets=WORKSFORME%3A">Status Counts</a></li> +<li><a href="http://gcc.gnu.org/bugzilla/report.cgi?bug_file_loc_type=allwordssubstr&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=SUSPENDED&bug_status=WAITING&bug_status=REOPENED&bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&cumulate=1&gccbuild_type=allwordssubstr&gcchost_type=allwordssubstr&gcctarget_type=allwordssubstr&keywords_type=allwords&known_to_fail_type=allwordssubstr&known_to_work_type=allwordssubstr&long_desc_type=substring&product=classpath&short_desc_type=allwordssubstr&x_axis_field=component&y_axis_field=bug_status&width=600&height=350&action=wrap&format=table">Component/Status Tables</a></li> +</ul> +<p> +</boxitem> + +</box> diff --git a/doc/www.gnu.org/events/events.wml b/doc/www.gnu.org/events/events.wml index decbb9689..873d4fae1 100644 --- a/doc/www.gnu.org/events/events.wml +++ b/doc/www.gnu.org/events/events.wml @@ -9,11 +9,12 @@ <boxitem> <strong>Upcoming Events:</strong><br> <ul> -[1-5 Aug 2005] <a href="http://conferences.oreillynet.com/os2005/">OSCON</a>, Portland, Oregon - USA +<li>[1-5 Aug 2005] <a href="http://conferences.oreillynet.com/os2005/">OSCON</a>, Portland, Oregon - USA <ul> <li><a href="http://conferences.oreillynet.com/cs/os2005/view/e_sess/6730">The State of Free JVMs</a> Tom Tromey</li> </ul> +</ul> </boxitem> <boxitem> @@ -49,7 +50,7 @@ Andrew Haley (in English) (<a href="http://people.redhat.com/~aph/linuxtag.tar.gz">slides</a>)</li> </ul> <p> -<li>[26+27 Feb. 2004] FOSDEM'05 in Brussels, Belgium. [<createlink name="Escape The Java Trap!" url="events/escape_fosdem05.html">] +<li>[26+27 Feb. 2005] FOSDEM'05 in Brussels, Belgium. [<createlink name="Escape The Java Trap!" url="events/escape_fosdem05.html">] <p> <li>[21+22 Feb. 2004] FOSDEM'04 in Brussels, Belgium. [<createlink name="report" url="events/fosdem04.html">] <p> diff --git a/doc/www.gnu.org/include/layout.wml b/doc/www.gnu.org/include/layout.wml index 61cf0bcbb..a82849205 100644 --- a/doc/www.gnu.org/include/layout.wml +++ b/doc/www.gnu.org/include/layout.wml @@ -105,7 +105,7 @@ <menutitle>Savannah</menutitle> <menuitem><createlink name="Project Home" url="http://savannah.gnu.org/projects/classpath/"></menuitem> -<menuitem><createlink name="Bug Reports" url="http://savannah.gnu.org/bugs/?group=classpath"></menuitem> +<menuitem><createlink name="Bug Reports" url="bugs.html"></menuitem> <!-- <menuitem><createlink name="Support" url="http://savannah.gnu.org/support/?group=classpath"></menuitem> <menuitem><createlink name="Patches" url="http://savannah.gnu.org/patch/?group=classpath"></menuitem> diff --git a/doc/www.gnu.org/newsitems.txt b/doc/www.gnu.org/newsitems.txt index 815a60ff7..d3d08e4e7 100644 --- a/doc/www.gnu.org/newsitems.txt +++ b/doc/www.gnu.org/newsitems.txt @@ -1,3 +1,8 @@ +<newsitem date="01 Aug 2005"> +<createlink name="Bugs moved to bugzilla" + url="bugs.html"> +</newsitem> + <newsitem date="15 Jul 2005"> <createlink name="GNU Classpath 0.17" url="announce/20050715.html"> diff --git a/examples/README b/examples/README index d850c2c17..3f612f3a0 100644 --- a/examples/README +++ b/examples/README @@ -7,7 +7,8 @@ class Demo which contains a main() method to run that particular example. The examples can be compiled and run with gcj as follows: gcj -o swingdemo --main=gnu.classpath.examples.swing.Demo \ - gnu/classpath/examples/swing/Demo.java + gnu/classpath/examples/swing/Demo.java \ + gnu/classpath/examples/swing/GNULookAndFeel.java ./swingdemo Or with a traditional byte code interpreter like: diff --git a/examples/gnu/classpath/examples/swing/Demo.java b/examples/gnu/classpath/examples/swing/Demo.java index eef300619..e6390252b 100644 --- a/examples/gnu/classpath/examples/swing/Demo.java +++ b/examples/gnu/classpath/examples/swing/Demo.java @@ -501,7 +501,6 @@ public class Demo JButton add = mkButton("add element"); add.addActionListener(new ActionListener() { - int i = 0; public void actionPerformed(ActionEvent e) { for (int i = 0; i < tree.getRowCount(); i++) @@ -1065,7 +1064,13 @@ public class Demo JButton exitDisposer = mkDisposerButton(frame); panel.add(exitDisposer); - + exitDisposer.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + System.exit(1); + } + }); return panel; } diff --git a/gnu/classpath/RawData.java b/gnu/classpath/Pointer.java index 3ce97482c..27634a894 100644 --- a/gnu/classpath/RawData.java +++ b/gnu/classpath/Pointer.java @@ -1,4 +1,4 @@ -/* RawData.java -- Pointer to VM specific data +/* Pointer.java -- Pointer to VM specific data Copyright (C) 1999, 2000, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -42,6 +42,6 @@ package gnu.classpath; /** A type used to indicate special data used by native code that should not be marked by the garbage collector. */ -public abstract class RawData +public abstract class Pointer { } diff --git a/gnu/classpath/RawData32.java b/gnu/classpath/Pointer32.java index c77163152..42b6c1d2d 100644 --- a/gnu/classpath/RawData32.java +++ b/gnu/classpath/Pointer32.java @@ -1,4 +1,4 @@ -/* RawData32.java -- 32 bit Pointer +/* Pointer32.java -- 32 bit Pointer Copyright (C) 2004 Free Software Foundation This file is part of GNU Classpath. @@ -41,11 +41,11 @@ package gnu.classpath; * A type used to indicate special data used by native code that should not * be marked by the garbage collector. */ -public final class RawData32 extends RawData +public final class Pointer32 extends Pointer { final int data; - public RawData32(int data) + public Pointer32(int data) { this.data = data; } diff --git a/gnu/classpath/RawData64.java b/gnu/classpath/Pointer64.java index e3b6a93e2..6d27e1ba1 100644 --- a/gnu/classpath/RawData64.java +++ b/gnu/classpath/Pointer64.java @@ -1,4 +1,4 @@ -/* RawData64.java -- 64 bit Pointer +/* Pointer64.java -- 64 bit Pointer Copyright (C) 2004 Free Software Foundation This file is part of GNU Classpath. @@ -41,11 +41,11 @@ package gnu.classpath; * A type used to indicate special data used by native code that should not * be marked by the garbage collector. */ -public final class RawData64 extends RawData +public final class Pointer64 extends Pointer { final long data; - public RawData64(long data) + public Pointer64(long data) { this.data = data; } diff --git a/gnu/classpath/jdwp/processor/MethodCommandSet.java b/gnu/classpath/jdwp/processor/MethodCommandSet.java new file mode 100644 index 000000000..952b94a55 --- /dev/null +++ b/gnu/classpath/jdwp/processor/MethodCommandSet.java @@ -0,0 +1,159 @@ +/* MethodCommandSet.java -- class to implement the Method Command Set + Copyright (C) 2005 Free Software Foundation + +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.jdwp.processor; + +import gnu.classpath.jdwp.IVirtualMachine; +import gnu.classpath.jdwp.Jdwp; +import gnu.classpath.jdwp.JdwpConstants; +import gnu.classpath.jdwp.exception.JdwpException; +import gnu.classpath.jdwp.exception.JdwpInternalErrorException; +import gnu.classpath.jdwp.exception.NotImplementedException; +import gnu.classpath.jdwp.id.IdManager; +import gnu.classpath.jdwp.id.ObjectId; +import gnu.classpath.jdwp.id.ReferenceTypeId; +import gnu.classpath.jdwp.util.LineTable; +import gnu.classpath.jdwp.util.VariableTable; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.nio.ByteBuffer; + +/** + * A class representing the Method Command Set. + * + * @author Aaron Luchko <aluchko@redhat.com> + */ +public class MethodCommandSet implements CommandSet +{ + // Our hook into the jvm + private final IVirtualMachine vm = Jdwp.getIVirtualMachine(); + + // Manages all the different ids that are assigned by jdwp + private final IdManager idMan = Jdwp.getIdManager(); + + public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) + throws JdwpException + { + try + { + switch (command) + { + case JdwpConstants.CommandSet.Method.LINE_TABLE: + executeLineTable(bb, os); + break; + case JdwpConstants.CommandSet.Method.VARIABLE_TABLE: + executeVariableTable(bb, os); + break; + case JdwpConstants.CommandSet.Method.BYTE_CODES: + executeByteCodes(bb, os); + break; + case JdwpConstants.CommandSet.Method.IS_OBSOLETE: + executeIsObsolete(bb, os); + break; + case JdwpConstants.CommandSet.Method.VARIABLE_TABLE_WITH_GENERIC: + executeVariableTableWithGeneric(bb, os); + break; + default: + throw new NotImplementedException( + "Command " + command + " not found in Method Command Set."); + } + } + catch (IOException ex) + { + // The DataOutputStream we're using isn't talking to a socket at all + // So if we throw an IOException we're in serious trouble + throw new JdwpInternalErrorException(ex); + } + return true; + } + + private void executeLineTable(ByteBuffer bb, DataOutputStream os) + throws JdwpException, IOException + { + ReferenceTypeId refId = idMan.readReferenceTypeId(bb); + Class clazz = refId.getType(); + + ObjectId oid = idMan.readId(bb); + Method method = (Method) oid.getObject(); + + LineTable lt = vm.getLineTable(clazz, method); + lt.write(os); + } + + private void executeVariableTable(ByteBuffer bb, DataOutputStream os) + throws JdwpException, IOException + { + ReferenceTypeId refId = idMan.readReferenceTypeId(bb); + Class clazz = refId.getType(); + + ObjectId oid = idMan.readId(bb); + Method method = (Method) oid.getObject(); + + VariableTable vt = vm.getVarTable(clazz, method); + vt.write(os); + } + + private void executeByteCodes(ByteBuffer bb, DataOutputStream os) + throws JdwpException + { + // This command is optional, determined by VirtualMachines CapabilitiesNew + // so we'll leave it till later to implement + throw new NotImplementedException("Command ByteCodes not implemented."); + } + + private void executeIsObsolete(ByteBuffer bb, DataOutputStream os) + throws IOException + { + // The debugger is really asking if this method has been redefined using + // VirtualMachineCommandSet.RedefineClasses. Since we don't implement that + // command the answer to this will always be false. + os.writeBoolean(false); + } + + private void executeVariableTableWithGeneric(ByteBuffer bb, + DataOutputStream os) + throws JdwpException + { + // We don't have generics yet + throw new NotImplementedException( + "Command SourceDebugExtension not implemented."); + } + +} diff --git a/gnu/java/awt/peer/gtk/GtkImage.java b/gnu/java/awt/peer/gtk/GtkImage.java index abb4137f4..ad5988ea2 100644 --- a/gnu/java/awt/peer/gtk/GtkImage.java +++ b/gnu/java/awt/peer/gtk/GtkImage.java @@ -51,7 +51,7 @@ import java.io.File; import java.io.IOException; import java.util.Hashtable; import java.util.Vector; -import gnu.classpath.RawData; +import gnu.classpath.Pointer; /** * GtkImage - wraps a GdkPixbuf or GdkPixmap. @@ -87,7 +87,7 @@ public class GtkImage extends Image /** * Pointer to the GdkPixbuf */ - RawData pixmap; + Pointer pixmap; /** * Observer queue. diff --git a/gnu/java/nio/FileLockImpl.java b/gnu/java/nio/FileLockImpl.java index 245fa7340..673ca2522 100644 --- a/gnu/java/nio/FileLockImpl.java +++ b/gnu/java/nio/FileLockImpl.java @@ -1,5 +1,5 @@ -/* FileLockImpl.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. +/* FileLockImpl.java -- FileLock associated with a FileChannelImpl. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,20 +44,29 @@ import java.io.IOException; import java.nio.channels.FileLock; /** + * A FileLock associated with a FileChannelImpl. + * * @author Michael Koch * @since 1.4 */ -public class FileLockImpl extends FileLock +public final class FileLockImpl extends FileLock { - private FileChannelImpl ch; - + /** + * Whether or not this lock is valid, false when channel is closed or + * release has been explicitly called. + */ + private boolean valid; + public FileLockImpl (FileChannelImpl channel, long position, long size, boolean shared) { super (channel, position, size, shared); - ch = channel; + valid = true; } + /** + * Releases this lock. + */ protected void finalize() { try @@ -70,13 +79,26 @@ public class FileLockImpl extends FileLock } } - public boolean isValid () + /** + * Whether or not this lock is valid, false when channel is closed or + * release has been explicitly called. + */ + public boolean isValid() { - return channel().isOpen(); + if (valid) + valid = channel().isOpen(); + return valid; } - public synchronized void release () throws IOException + /** + * Releases the lock if it is still valid. Marks this lock as invalid. + */ + public void release() throws IOException { - ch.unlock(position(), size()); + if (isValid()) + { + valid = false; + ((FileChannelImpl) channel()).unlock(position(), size()); + } } } diff --git a/gnu/java/nio/charset/iconv/IconvDecoder.java b/gnu/java/nio/charset/iconv/IconvDecoder.java index fa265a923..fa6f49700 100644 --- a/gnu/java/nio/charset/iconv/IconvDecoder.java +++ b/gnu/java/nio/charset/iconv/IconvDecoder.java @@ -38,7 +38,7 @@ exception statement from your version. */ package gnu.java.nio.charset.iconv; -import gnu.classpath.RawData; +import gnu.classpath.Pointer; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -55,7 +55,7 @@ final class IconvDecoder extends CharsetDecoder openIconv(info.iconvName()); } - private RawData data; + private Pointer data; private int inremaining; private int outremaining; diff --git a/gnu/java/nio/charset/iconv/IconvEncoder.java b/gnu/java/nio/charset/iconv/IconvEncoder.java index bb10c9b63..d5cc8877f 100644 --- a/gnu/java/nio/charset/iconv/IconvEncoder.java +++ b/gnu/java/nio/charset/iconv/IconvEncoder.java @@ -38,7 +38,7 @@ exception statement from your version. */ package gnu.java.nio.charset.iconv; -import gnu.classpath.RawData; +import gnu.classpath.Pointer; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -49,7 +49,7 @@ import java.nio.charset.CoderResult; final class IconvEncoder extends CharsetEncoder { - private RawData data; + private Pointer data; private int inremaining; private int outremaining; diff --git a/include/java_nio_VMDirectByteBuffer.h b/include/java_nio_VMDirectByteBuffer.h index 408426a2d..3214d38e3 100644 --- a/include/java_nio_VMDirectByteBuffer.h +++ b/include/java_nio_VMDirectByteBuffer.h @@ -10,13 +10,12 @@ extern "C" { #endif -JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_init (JNIEnv *env, jclass); JNIEXPORT jobject JNICALL Java_java_nio_VMDirectByteBuffer_allocate (JNIEnv *env, jclass, jint); JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_free (JNIEnv *env, jclass, jobject); -JNIEXPORT jbyte JNICALL Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I (JNIEnv *env, jclass, jobject, jint); -JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I_3BII (JNIEnv *env, jclass, jobject, jint, jbyteArray, jint, jint); -JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_RawData_2IB (JNIEnv *env, jclass, jobject, jint, jbyte); -JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_RawData_2I_3BII (JNIEnv *env, jclass, jobject, jint, jbyteArray, jint, jint); +JNIEXPORT jbyte JNICALL Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_Pointer_2I (JNIEnv *env, jclass, jobject, jint); +JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_Pointer_2I_3BII (JNIEnv *env, jclass, jobject, jint, jbyteArray, jint, jint); +JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_Pointer_2IB (JNIEnv *env, jclass, jobject, jint, jbyte); +JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_Pointer_2I_3BII (JNIEnv *env, jclass, jobject, jint, jbyteArray, jint, jint); JNIEXPORT jobject JNICALL Java_java_nio_VMDirectByteBuffer_adjustAddress (JNIEnv *env, jclass, jobject, jint); JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_shiftDown (JNIEnv *env, jclass, jobject, jint, jint, jint); diff --git a/java/awt/BorderLayout.java b/java/awt/BorderLayout.java index 7bbcf797f..adf2ebf65 100644 --- a/java/awt/BorderLayout.java +++ b/java/awt/BorderLayout.java @@ -48,34 +48,30 @@ package java.awt; public class BorderLayout implements LayoutManager2, java.io.Serializable { -/* - * Static Variables - */ - -/** - * Constant indicating the top of the container - */ -public static final String NORTH = "North"; + /** + * Constant indicating the top of the container + */ + public static final String NORTH = "North"; -/** - * Constant indicating the bottom of the container - */ -public static final String SOUTH = "South"; + /** + * Constant indicating the bottom of the container + */ + public static final String SOUTH = "South"; -/** - * Constant indicating the right side of the container - */ -public static final String EAST = "East"; + /** + * Constant indicating the right side of the container + */ + public static final String EAST = "East"; -/** - * Constant indicating the left side of the container - */ -public static final String WEST = "West"; + /** + * Constant indicating the left side of the container + */ + public static final String WEST = "West"; -/** - * Constant indicating the center of the container - */ -public static final String CENTER = "Center"; + /** + * Constant indicating the center of the container + */ + public static final String CENTER = "Center"; /** @@ -91,7 +87,6 @@ public static final String CENTER = "Center"; */ public static final String BEFORE_FIRST_LINE = "First"; - /** * The constant indicating the position after the last line of the * layout. The exact position depends on the writing system: For a @@ -105,7 +100,6 @@ public static final String CENTER = "Center"; */ public static final String AFTER_LAST_LINE = "Last"; - /** * The constant indicating the position before the first item of the * layout. The exact position depends on the writing system: For a @@ -119,7 +113,6 @@ public static final String CENTER = "Center"; */ public static final String BEFORE_LINE_BEGINS = "Before"; - /** * The constant indicating the position after the last item of the * layout. The exact position depends on the writing system: For a @@ -133,7 +126,6 @@ public static final String CENTER = "Center"; */ public static final String AFTER_LINE_ENDS = "After"; - /** * The constant indicating the position before the first line of the * layout. The exact position depends on the writing system: For a @@ -144,7 +136,6 @@ public static final String CENTER = "Center"; */ public static final String PAGE_START = BEFORE_FIRST_LINE; - /** * The constant indicating the position after the last line of the * layout. The exact position depends on the writing system: For a @@ -155,7 +146,6 @@ public static final String CENTER = "Center"; */ public static final String PAGE_END = AFTER_LAST_LINE; - /** * The constant indicating the position before the first item of the * layout. The exact position depends on the writing system: For a @@ -166,7 +156,6 @@ public static final String CENTER = "Center"; */ public static final String LINE_START = BEFORE_LINE_BEGINS; - /** * The constant indicating the position after the last item of the * layout. The exact position depends on the writing system: For a @@ -178,398 +167,341 @@ public static final String CENTER = "Center"; public static final String LINE_END = AFTER_LINE_ENDS; + /** + * Serialization constant. + */ + private static final long serialVersionUID = -8658291919501921765L; -// Serialization constant -private static final long serialVersionUID = -8658291919501921765L; - -/*************************************************************************/ - -/* - * Instance Variables - */ - -/** - * @serial - */ -private Component north; - -/** - * @serial - */ -private Component south; - -/** - * @serial - */ -private Component east; - -/** - * @serial - */ -private Component west; - -/** - * @serial - */ -private Component center; - -/** - * @serial - */ -private Component firstLine; - -/** - * @serial - */ -private Component lastLine; - -/** - * @serial - */ -private Component firstItem; - -/** - * @serial - */ -private Component lastItem; - -/** - * @serial The horizontal gap between components - */ -private int hgap; - -/** - * @serial The vertical gap between components - */ -private int vgap; - -/*************************************************************************/ - -/* - * Constructors - */ - -/** - * Initializes a new instance of <code>BorderLayout</code> with no - * horiztonal or vertical gaps between components. - */ -public -BorderLayout() -{ - this(0,0); -} -/*************************************************************************/ + /** + * @serial + */ + private Component north; -/** - * Initializes a new instance of <code>BorderLayout</code> with the - * specified horiztonal and vertical gaps between components. - * - * @param hgap The horizontal gap between components. - * @param vgap The vertical gap between components. - */ -public -BorderLayout(int hgap, int vgap) -{ - this.hgap = hgap; - this.vgap = vgap; -} + /** + * @serial + */ + private Component south; -/*************************************************************************/ + /** + * @serial + */ + private Component east; -/* - * Instance Variables - */ + /** + * @serial + */ + private Component west; -/** - * Returns the horitzontal gap value. - * - * @return The horitzontal gap value. + /** + * @serial */ -public int -getHgap() -{ - return(hgap); -} + private Component center; -/*************************************************************************/ - -/** - * Sets the horizontal gap to the specified value. - * - * @param hgap The new horizontal gap. - */ -public void -setHgap(int hgap) -{ - this.hgap = hgap; -} - -/*************************************************************************/ - -/** - * Returns the vertical gap value. - * - * @return The vertical gap value. - */ -public int -getVgap() -{ - return(vgap); -} + /** + * @serial + */ + private Component firstLine; -/*************************************************************************/ + /** + * @serial + */ + private Component lastLine; -/** - * Sets the vertical gap to the specified value. - * - * @param vgap The new vertical gap value. - */ -public void -setVgap(int vgap) -{ - this.vgap = vgap; -} + /** + * @serial + */ + private Component firstItem; -/*************************************************************************/ + /** + * @serial + */ + private Component lastItem; -/** - * Adds a component to the layout in the specified constraint position, - * which must be one of the string constants defined in this class. - * - * @param component The component to add. - * @param constraints The constraint string. - * - * @exception IllegalArgumentException If the constraint object is not - * a string, or is not one of the specified constants in this class. - */ -public void -addLayoutComponent(Component component, Object constraints) -{ - if (constraints != null && ! (constraints instanceof String)) - throw new IllegalArgumentException("Constraint must be a string"); + /** + * @serial The horizontal gap between components + */ + private int hgap; - addLayoutComponent((String) constraints, component); -} + /** + * @serial The vertical gap between components + */ + private int vgap; -/*************************************************************************/ -/** - * Adds a component to the layout in the specified constraint position, - * which must be one of the string constants defined in this class. - * - * @param constraints The constraint string. - * @param component The component to add. - * - * @exception IllegalArgumentException If the constraint object is not - * one of the specified constants in this class. - * - * @deprecated This method is deprecated in favor of - * <code>addLayoutComponent(Component, Object)</code>. - */ -public void -addLayoutComponent(String constraints, Component component) -{ - String str = constraints; - - if (str == null || str.equals(CENTER)) - center = component; - else if (str.equals(NORTH)) - north = component; - else if (str.equals(SOUTH)) - south = component; - else if (str.equals(EAST)) - east = component; - else if (str.equals(WEST)) - west = component; - else if (str.equals(BEFORE_FIRST_LINE)) - firstLine = component; - else if (str.equals(AFTER_LAST_LINE)) - lastLine = component; - else if (str.equals(BEFORE_LINE_BEGINS)) - firstItem = component; - else if (str.equals(AFTER_LINE_ENDS)) - lastItem = component; - else - throw new IllegalArgumentException("Constraint value not valid: " + str); -} + /** + * Initializes a new instance of <code>BorderLayout</code> with no + * horiztonal or vertical gaps between components. + */ + public BorderLayout() + { + this(0,0); + } -/*************************************************************************/ + /** + * Initializes a new instance of <code>BorderLayout</code> with the + * specified horiztonal and vertical gaps between components. + * + * @param hgap The horizontal gap between components. + * @param vgap The vertical gap between components. + */ + public BorderLayout(int hgap, int vgap) + { + this.hgap = hgap; + this.vgap = vgap; + } -/** - * Removes the specified component from the layout. - * - * @param component The component to remove from the layout. - */ -public void -removeLayoutComponent(Component component) -{ - if (north == component) - north = null; - if (south == component) - south = null; - if (east == component) - east = null; - if (west == component) - west = null; - if (center == component) - center = null; - if (firstItem == component) - firstItem = null; - if (lastItem == component) - lastItem = null; - if (firstLine == component) - firstLine = null; - if (lastLine == component) - lastLine = null; -} + /** + * Returns the horitzontal gap value. + * + * @return The horitzontal gap value. + */ + public int getHgap() + { + return(hgap); + } -/*************************************************************************/ + /** + * Sets the horizontal gap to the specified value. + * + * @param hgap The new horizontal gap. + */ + public void setHgap(int hgap) + { + this.hgap = hgap; + } -/** - * Returns the minimum size of the specified container using this layout. - * - * @param target The container to calculate the minimum size for. - * - * @return The minimum size of the container - */ -public Dimension -minimumLayoutSize(Container target) -{ - return calcSize(target, MIN); -} + /** + * Returns the vertical gap value. + * + * @return The vertical gap value. + */ + public int getVgap() + { + return(vgap); + } -/*************************************************************************/ + /** + * Sets the vertical gap to the specified value. + * + * @param vgap The new vertical gap value. + */ + public void setVgap(int vgap) + { + this.vgap = vgap; + } -/** - * Returns the preferred size of the specified container using this layout. - * - * @param target The container to calculate the preferred size for. - * - * @return The preferred size of the container - */ -public Dimension -preferredLayoutSize(Container target) -{ - return calcSize(target, PREF); -} + /** + * Adds a component to the layout in the specified constraint position, + * which must be one of the string constants defined in this class. + * + * @param component The component to add. + * @param constraints The constraint string. + * + * @exception IllegalArgumentException If the constraint object is not + * a string, or is not one of the specified constants in this class. + */ + public void addLayoutComponent(Component component, Object constraints) + { + if (constraints != null && ! (constraints instanceof String)) + throw new IllegalArgumentException("Constraint must be a string"); -/*************************************************************************/ + addLayoutComponent((String) constraints, component); + } -/** - * Returns the maximum size of the specified container using this layout. - * - * @param target The container to calculate the maximum size for. - * - * @return The maximum size of the container - */ -public Dimension -maximumLayoutSize(Container target) -{ - return calcSize(target, MAX); -} + /** + * Adds a component to the layout in the specified constraint position, + * which must be one of the string constants defined in this class. + * + * @param constraints The constraint string. + * @param component The component to add. + * + * @exception IllegalArgumentException If the constraint object is not + * one of the specified constants in this class. + * + * @deprecated This method is deprecated in favor of + * <code>addLayoutComponent(Component, Object)</code>. + */ + public void addLayoutComponent(String constraints, Component component) + { + String str = constraints; + + if (str == null || str.equals(CENTER)) + center = component; + else if (str.equals(NORTH)) + north = component; + else if (str.equals(SOUTH)) + south = component; + else if (str.equals(EAST)) + east = component; + else if (str.equals(WEST)) + west = component; + else if (str.equals(BEFORE_FIRST_LINE)) + firstLine = component; + else if (str.equals(AFTER_LAST_LINE)) + lastLine = component; + else if (str.equals(BEFORE_LINE_BEGINS)) + firstItem = component; + else if (str.equals(AFTER_LINE_ENDS)) + lastItem = component; + else + throw new IllegalArgumentException("Constraint value not valid: " + str); + } -/*************************************************************************/ + /** + * Removes the specified component from the layout. + * + * @param component The component to remove from the layout. + */ + public void removeLayoutComponent(Component component) + { + if (north == component) + north = null; + if (south == component) + south = null; + if (east == component) + east = null; + if (west == component) + west = null; + if (center == component) + center = null; + if (firstItem == component) + firstItem = null; + if (lastItem == component) + lastItem = null; + if (firstLine == component) + firstLine = null; + if (lastLine == component) + lastLine = null; + } -/** - * Returns the X axis alignment, which is a <code>float</code> indicating - * where along the X axis this container wishs to position its layout. - * 0 indicates align to the left, 1 indicates align to the right, and 0.5 - * indicates align to the center. - * - * @param parent The parent container. - * - * @return The X alignment value. - */ -public float -getLayoutAlignmentX(Container parent) -{ - return(parent.getAlignmentX()); -} + /** + * Returns the minimum size of the specified container using this layout. + * + * @param target The container to calculate the minimum size for. + * + * @return The minimum size of the container + */ + public Dimension minimumLayoutSize(Container target) + { + return calcSize(target, MIN); + } -/*************************************************************************/ + /** + * Returns the preferred size of the specified container using this layout. + * + * @param target The container to calculate the preferred size for. + * + * @return The preferred size of the container + */ + public Dimension preferredLayoutSize(Container target) + { + return calcSize(target, PREF); + } -/** - * Returns the Y axis alignment, which is a <code>float</code> indicating - * where along the Y axis this container wishs to position its layout. - * 0 indicates align to the top, 1 indicates align to the bottom, and 0.5 - * indicates align to the center. - * - * @param parent The parent container. - * - * @return The Y alignment value. - */ -public float -getLayoutAlignmentY(Container parent) -{ - return(parent.getAlignmentY()); -} + /** + * Returns the maximum size of the specified container using this layout. + * + * @param target The container to calculate the maximum size for. + * + * @return The maximum size of the container + */ + public Dimension maximumLayoutSize(Container target) + { + return calcSize(target, MAX); + } -/*************************************************************************/ + /** + * Returns the X axis alignment, which is a <code>float</code> indicating + * where along the X axis this container wishs to position its layout. + * 0 indicates align to the left, 1 indicates align to the right, and 0.5 + * indicates align to the center. + * + * @param parent The parent container. + * + * @return The X alignment value. + */ + public float getLayoutAlignmentX(Container parent) + { + return(parent.getAlignmentX()); + } -/** - * Instructs this object to discard any layout information it might - * have cached. - * - * @param parent The parent container. - */ -public void -invalidateLayout(Container parent) -{ -} + /** + * Returns the Y axis alignment, which is a <code>float</code> indicating + * where along the Y axis this container wishs to position its layout. + * 0 indicates align to the top, 1 indicates align to the bottom, and 0.5 + * indicates align to the center. + * + * @param parent The parent container. + * + * @return The Y alignment value. + */ + public float getLayoutAlignmentY(Container parent) + { + return(parent.getAlignmentY()); + } -/*************************************************************************/ + /** + * Instructs this object to discard any layout information it might + * have cached. + * + * @param parent The parent container. + */ + public void invalidateLayout(Container parent) + { + // FIXME: Implement this properly! + } -/** - * Lays out the specified container according to the constraints - * in this object. - * - * @param target The container to lay out. - */ -public void -layoutContainer(Container target) -{ - synchronized (target.getTreeLock ()) - { - Insets i = target.getInsets(); - - ComponentOrientation orient = target.getComponentOrientation (); - boolean left_to_right = orient.isLeftToRight (); - - Component my_north = north; - Component my_east = east; - Component my_south = south; - Component my_west = west; - - // Note that we currently don't handle vertical layouts. Neither - // does JDK 1.3. - if (firstLine != null) - my_north = firstLine; - if (lastLine != null) - my_south = lastLine; - if (firstItem != null) - { - if (left_to_right) - my_west = firstItem; - else - my_east = firstItem; - } - if (lastItem != null) - { - if (left_to_right) - my_east = lastItem; - else - my_west = lastItem; - } - - Dimension c = calcCompSize(center, PREF); - Dimension n = calcCompSize(my_north, PREF); - Dimension s = calcCompSize(my_south, PREF); - Dimension e = calcCompSize(my_east, PREF); - Dimension w = calcCompSize(my_west, PREF); - Dimension t = target.getSize(); - - /* + /** + * Lays out the specified container according to the constraints + * in this object. + * + * @param target The container to lay out. + */ + public void layoutContainer(Container target) + { + synchronized (target.getTreeLock ()) + { + Insets i = target.getInsets(); + + ComponentOrientation orient = target.getComponentOrientation (); + boolean left_to_right = orient.isLeftToRight (); + + Component my_north = north; + Component my_east = east; + Component my_south = south; + Component my_west = west; + + // Note that we currently don't handle vertical layouts. Neither + // does JDK 1.3. + if (firstLine != null) + my_north = firstLine; + if (lastLine != null) + my_south = lastLine; + if (firstItem != null) + { + if (left_to_right) + my_west = firstItem; + else + my_east = firstItem; + } + if (lastItem != null) + { + if (left_to_right) + my_east = lastItem; + else + my_west = lastItem; + } + + Dimension c = calcCompSize(center, PREF); + Dimension n = calcCompSize(my_north, PREF); + Dimension s = calcCompSize(my_south, PREF); + Dimension e = calcCompSize(my_east, PREF); + Dimension w = calcCompSize(my_west, PREF); + int targetWidth = target.getWidth(); + int targetHeight = target.getHeight(); + + /* <-> hgap <-> hgap +----------------------------+ } |t | } i.top @@ -588,144 +520,144 @@ layoutContainer(Container target) <----------------------> <--> ww <--> i.left i.right - */ - - int x1 = i.left; - int x2 = x1 + w.width + (w.width == 0 ? 0 : hgap); - int x3; - if (t.width <= i.right + e.width) - x3 = x2 + w.width + (w.width == 0 ? 0 : hgap); - else - x3 = t.width - i.right - e.width; - int ww = t.width - i.right - i.left; - - int y1 = i.top; - int y2 = y1 + n.height + (n.height == 0 ? 0 : vgap); - int midh = Math.max(e.height, Math.max(w.height, c.height)); - int y3; - if (t.height <= i.bottom + s.height) - y3 = y2 + midh + vgap; - else - y3 = t.height - i.bottom - s.height; - int hh = y3-y2-(s.height == 0 ? 0 : vgap); - - setBounds(center, x2, y2, x3-x2-(w.width == 0 ? 0 : hgap), hh); - setBounds(my_north, x1, y1, ww, n.height); - setBounds(my_south, x1, y3, ww, s.height); - setBounds(my_west, x1, y2, w.width, hh); - setBounds(my_east, x3, y2, e.width, hh); - } -} - -/*************************************************************************/ + */ + + int x1 = i.left; + int x2 = x1 + w.width + (w.width == 0 ? 0 : hgap); + int x3; + if (targetWidth <= i.right + e.width) + x3 = x2 + w.width + (w.width == 0 ? 0 : hgap); + else + x3 = targetWidth - i.right - e.width; + int ww = targetWidth - i.right - i.left; + + int y1 = i.top; + int y2 = y1 + n.height + (n.height == 0 ? 0 : vgap); + int midh = Math.max(e.height, Math.max(w.height, c.height)); + int y3; + if (targetHeight <= i.bottom + s.height) + y3 = y2 + midh + vgap; + else + y3 = targetHeight - i.bottom - s.height; + int hh = y3-y2-(s.height == 0 ? 0 : vgap); + + setBounds(center, x2, y2, x3-x2-(w.width == 0 ? 0 : hgap), hh); + setBounds(my_north, x1, y1, ww, n.height); + setBounds(my_south, x1, y3, ww, s.height); + setBounds(my_west, x1, y2, w.width, hh); + setBounds(my_east, x3, y2, e.width, hh); + } + } -/** - * Returns a string representation of this layout manager. - * - * @return A string representation of this object. - */ -public String -toString() -{ - return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]"; -} - -private void -setBounds(Component comp, int x, int y, int w, int h) -{ - if (comp == null) - return; - comp.setBounds(x, y, w, h); -} - -// Some constants for use with calcSize(). -private static final int MIN = 0; -private static final int MAX = 1; -private static final int PREF = 2; + /** + * Returns a string representation of this layout manager. + * + * @return A string representation of this object. + */ + public String toString() + { + return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]"; + } -private Dimension -calcCompSize(Component comp, int what) -{ - if (comp == null || !comp.isVisible()) - return new Dimension(0, 0); - if (what == MIN) - return comp.getMinimumSize(); - else if (what == MAX) - return comp.getMaximumSize(); - return comp.getPreferredSize(); -} + /** + * FIXME: Document me! + */ + private void setBounds(Component comp, int x, int y, int w, int h) + { + if (comp == null) + return; + 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()) + return new Dimension(0, 0); + if (what == MIN) + return comp.getMinimumSize(); + else if (what == MAX) + return comp.getMaximumSize(); + return comp.getPreferredSize(); + } -// This is a helper function used to compute the various sizes for -// this layout. -private Dimension -calcSize(Container target, int what) -{ - synchronized (target.getTreeLock ()) - { - Insets ins = target.getInsets(); - - ComponentOrientation orient = target.getComponentOrientation (); - boolean left_to_right = orient.isLeftToRight (); - - Component my_north = north; - Component my_east = east; - Component my_south = south; - Component my_west = west; - - // Note that we currently don't handle vertical layouts. Neither - // does JDK 1.3. - if (firstLine != null) - my_north = firstLine; - if (lastLine != null) - my_south = lastLine; - if (firstItem != null) - { - if (left_to_right) - my_west = firstItem; - else - my_east = firstItem; - } - if (lastItem != null) - { - if (left_to_right) - my_east = lastItem; - else - my_west = lastItem; - } - - Dimension ndim = calcCompSize(my_north, what); - Dimension sdim = calcCompSize(my_south, what); - Dimension edim = calcCompSize(my_east, what); - Dimension wdim = calcCompSize(my_west, what); - Dimension cdim = calcCompSize(center, what); - - int width = edim.width + cdim.width + wdim.width + (hgap * 2); - // check for overflow - if (width < edim.width || width < cdim.width || width < cdim.width) + /** + * This is a helper function used to compute the various sizes for + * this layout. + */ + private Dimension calcSize(Container target, int what) + { + synchronized (target.getTreeLock ()) + { + Insets ins = target.getInsets(); + + ComponentOrientation orient = target.getComponentOrientation (); + boolean left_to_right = orient.isLeftToRight (); + + Component my_north = north; + Component my_east = east; + Component my_south = south; + Component my_west = west; + + // Note that we currently don't handle vertical layouts. Neither + // does JDK 1.3. + if (firstLine != null) + my_north = firstLine; + if (lastLine != null) + my_south = lastLine; + if (firstItem != null) + { + if (left_to_right) + my_west = firstItem; + else + my_east = firstItem; + } + if (lastItem != null) + { + if (left_to_right) + my_east = lastItem; + else + my_west = lastItem; + } + + Dimension ndim = calcCompSize(my_north, what); + Dimension sdim = calcCompSize(my_south, what); + Dimension edim = calcCompSize(my_east, what); + Dimension wdim = calcCompSize(my_west, what); + Dimension cdim = calcCompSize(center, what); + + int width = edim.width + cdim.width + wdim.width + (hgap * 2); + // Check for overflow. + if (width < edim.width || width < cdim.width || width < cdim.width) width = Integer.MAX_VALUE; - if (ndim.width > width) - width = ndim.width; - if (sdim.width > width) - width = sdim.width; + if (ndim.width > width) + width = ndim.width; + if (sdim.width > width) + width = sdim.width; - width += (ins.left + ins.right); + width += (ins.left + ins.right); - int height = edim.height; - if (cdim.height > height) - height = cdim.height; - if (wdim.height > height) - height = wdim.height; + int height = edim.height; + if (cdim.height > height) + height = cdim.height; + if (wdim.height > height) + height = wdim.height; - int addedHeight = height + (ndim.height + sdim.height + (vgap * 2) - + ins.top + ins.bottom); - // check for overflow - if (addedHeight < height) + int addedHeight = height + (ndim.height + sdim.height + (vgap * 2) + + ins.top + ins.bottom); + // Check for overflow. + if (addedHeight < height) height = Integer.MAX_VALUE; - else + else height = addedHeight; - return(new Dimension(width, height)); - } + return(new Dimension(width, height)); + } + } } -} // class BorderLayout diff --git a/java/awt/Component.java b/java/awt/Component.java index 8245eb49a..d5b8027eb 100644 --- a/java/awt/Component.java +++ b/java/awt/Component.java @@ -1848,10 +1848,19 @@ public abstract class Component * * @see #paint(Graphics) * @see #repaint() + * + * @specnote In contrast to what the spec says, tests show that the exact + * behaviour is to clear the background on lightweight and + * top-level components only. Heavyweight components are not + * affected by this method and only call paint(). */ public void update(Graphics g) { - if (!isLightweight()) + // Tests show that the clearing of the background is only done in + // two cases: + // - If the component is lightwight (yes this is in contrast to the spec). + // - If the component is a toplevel container. + if (isLightweight() || getParent() == null) { Rectangle clip = g.getClipBounds(); if (clip == null) @@ -1859,7 +1868,6 @@ public abstract class Component else g.clearRect(clip.x, clip.y, clip.width, clip.height); } - paint(g); } diff --git a/java/awt/Container.java b/java/awt/Container.java index 70567d586..d17a7602a 100644 --- a/java/awt/Container.java +++ b/java/awt/Container.java @@ -656,10 +656,10 @@ public class Container extends Component { if(valid && prefSize != null) return new Dimension(prefSize); - - if (layoutMgr != null) + LayoutManager layout = getLayout(); + if (layout != null) { - Dimension layoutSize = layoutMgr.preferredLayoutSize (this); + Dimension layoutSize = layout.preferredLayoutSize(this); if(valid) prefSize = layoutSize; return new Dimension(layoutSize); @@ -688,8 +688,15 @@ public class Container extends Component */ public Dimension minimumSize() { - if (layoutMgr != null) - return layoutMgr.minimumLayoutSize (this); + if(valid && minSize != null) + return new Dimension(minSize); + + LayoutManager layout = getLayout(); + if (layout != null) + { + minSize = layout.minimumLayoutSize (this); + return minSize; + } else return super.minimumSize (); } @@ -701,10 +708,15 @@ public class Container extends Component */ public Dimension getMaximumSize() { - if (layoutMgr != null && layoutMgr instanceof LayoutManager2) + if (valid && maxSize != null) + return new Dimension(maxSize); + + LayoutManager layout = getLayout(); + if (layout != null && layout instanceof LayoutManager2) { - LayoutManager2 lm2 = (LayoutManager2) layoutMgr; - return lm2.maximumLayoutSize(this); + LayoutManager2 lm2 = (LayoutManager2) layout; + maxSize = lm2.maximumLayoutSize(this); + return maxSize; } else return super.getMaximumSize(); @@ -762,10 +774,21 @@ public class Container extends Component * drawn. * * @param g The graphics context for this update. + * + * @specnote The specification suggests that this method forwards the + * update() call to all its lightweight children. Tests show + * that this is not done either in the JDK. The exact behaviour + * seems to be that top-level container call super.update() + * (causing the background to be cleared), and all other containers + * directly call paint(), causing the (lightweight) children to + * be painted. */ public void update(Graphics g) { - super.update(g); + if (getParent() == null) + super.update(g); + + paint(g); } /** @@ -1496,12 +1519,8 @@ public class Container extends Component for (int i = ncomponents - 1; i >= 0; --i) { Component comp = component[i]; - // If we're visiting heavyweights as well, - // don't recurse into Containers here. This avoids - // painting the same nested child multiple times. boolean applicable = comp.isVisible() - && (comp.isLightweight() - || !lightweightOnly && ! (comp instanceof Container)); + && (comp.isLightweight() || !lightweightOnly); if (applicable) visitChild(gfx, visitor, comp); diff --git a/java/awt/FontMetrics.java b/java/awt/FontMetrics.java index e702a6257..a03d59a10 100644 --- a/java/awt/FontMetrics.java +++ b/java/awt/FontMetrics.java @@ -235,7 +235,8 @@ public abstract class FontMetrics implements java.io.Serializable public int charsWidth(char[] buf, int offset, int len) { int total_width = 0; - for (int i = offset; i < len; i++) + int endOffset = offset + len; + for (int i = offset; i < endOffset; i++) total_width += charWidth(buf[i]); return total_width; } diff --git a/java/awt/GridBagLayout.java b/java/awt/GridBagLayout.java index 256de0940..f912bf97b 100644 --- a/java/awt/GridBagLayout.java +++ b/java/awt/GridBagLayout.java @@ -193,16 +193,12 @@ public class GridBagLayout if (clone.gridwidth == 0) clone.gridwidth = GridBagConstraints.REMAINDER; - else if (clone.gridwidth < 0 - && clone.gridwidth != GridBagConstraints.REMAINDER - && clone.gridwidth != GridBagConstraints.RELATIVE) + else if (clone.gridwidth < 0) clone.gridwidth = 1; if (clone.gridheight == 0) clone.gridheight = GridBagConstraints.REMAINDER; - else if (clone.gridheight < 0 - && clone.gridheight != GridBagConstraints.REMAINDER - && clone.gridheight != GridBagConstraints.RELATIVE) + else if (clone.gridheight < 0) clone.gridheight = 1; comptable.put (component, clone); diff --git a/java/awt/Toolkit.java b/java/awt/Toolkit.java index c7c6f9f0e..2ca88b6f5 100644 --- a/java/awt/Toolkit.java +++ b/java/awt/Toolkit.java @@ -790,6 +790,9 @@ public abstract class Toolkit { // Presumably the only reason this isn't abstract is for backwards // compatibility? FIXME? + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException("No custom cursor in an headless graphics " + + "environment."); return null; } @@ -801,6 +804,9 @@ public abstract class Toolkit */ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) { + if (GraphicsEnvironment.isHeadless()) + throw new HeadlessException("No best cursor size in an headless " + + "graphics environment."); return new Dimension (0,0); } diff --git a/java/awt/datatransfer/Clipboard.java b/java/awt/datatransfer/Clipboard.java index 9953a724d..5fa1d1ab1 100644 --- a/java/awt/datatransfer/Clipboard.java +++ b/java/awt/datatransfer/Clipboard.java @@ -1,5 +1,5 @@ /* Clipboard.java -- Class for transferring data via cut and paste. - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,16 +38,21 @@ exception statement from your version. */ package java.awt.datatransfer; +import java.io.IOException; +import java.util.ArrayList; + /** * This class allows data to be transferred using a cut and paste type * mechanism. * * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Mark J. Wielaard (mark@klomp.org) */ public class Clipboard { /** - * The data being transferred. + * The data currently on this clipboard. For use by + * subclasses. Also returned by the public method getContents(). */ protected Transferable contents; @@ -57,7 +62,10 @@ public class Clipboard protected ClipboardOwner owner; // The clipboard name - private String name; + private final String name; + + // The flavor listeners (most likely small). + private final ArrayList listeners = new ArrayList(3); /** * Initializes a new instance of <code>Clipboard</code> with the @@ -81,7 +89,8 @@ public class Clipboard /** * Returns the contents of the clipboard. * - * @param requestor The object requesting the contents. + * @param requestor The object requesting the contents. This + * implementation ignores this parameter. * * @exception IllegalStateException If the clipboard is currently unavailable */ @@ -91,24 +100,108 @@ public class Clipboard } /** - * Sets the content and owner of this clipboard. - * If the given owner is different from the current owner - * then lostOwnership is called on the current owner. - * XXX - is this called with the old or new contents. + * Sets the content and owner of this clipboard. If the given owner + * is different from the current owner then <code>lostOwnership()</code> + * is called on the current owner with the old contents of the given + * clipboard. * * @param contents The new clipboard contents. * @param owner The new clipboard owner * * @exception IllegalStateException If the clipboard is currently unavailable */ - public synchronized void setContents(Transferable contents, ClipboardOwner owner) + public synchronized void setContents(Transferable contents, + ClipboardOwner owner) { - if (this.owner != owner) - if (this.owner != null) - this.owner.lostOwnership(this, contents); - - this.owner = owner; + Transferable oldContents = getContents(null); this.contents = contents; + if (this.owner != owner) + { + ClipboardOwner oldOwner = this.owner; + this.owner = owner; + if (oldOwner != null) + oldOwner.lostOwnership(this, oldContents); + } + + FlavorListener[] fs = getFlavorListeners(); + if (fs.length > 0) + { + // We are a bit optimistic here. We assume DataFlavors will be + // given in the same order. If the number of flavors is + // different or the order of the DataFlavors in the list then + // fire a change event. + boolean newFlavors = ((contents != null && oldContents == null) + || (contents == null && oldContents != null)); + if (!newFlavors && contents != null && oldContents != null) + { + DataFlavor[] df1 = contents.getTransferDataFlavors(); + DataFlavor[] df2 = oldContents.getTransferDataFlavors(); + newFlavors = df1.length != df2.length; + + for (int i = 0; !newFlavors && i < df1.length; i++) + newFlavors = !df1[i].equals(df2[i]); + } + + if (newFlavors) + { + FlavorEvent e = new FlavorEvent(this); + for (int i = 0; i < fs.length; i++) + fs[i].flavorsChanged(e); + } + } + } + + public DataFlavor[] getAvailableDataFlavors() + { + Transferable c = getContents(null); + if (c == null) + return new DataFlavor[0]; + else + return c.getTransferDataFlavors(); + } + + public boolean isDataFlavorAvailable(DataFlavor flavor) + { + DataFlavor[] fs = getAvailableDataFlavors(); + for (int i = 0; i < fs.length; i++) + if (flavor.equals(fs[i])) + return true; + + return false; } -} + public Object getData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException + { + Transferable c = getContents(null); + if (c == null) + throw new UnsupportedFlavorException(flavor); + else + return c.getTransferData(flavor); + } + + public void addFlavorListener(FlavorListener listener) + { + synchronized(listeners) + { + listeners.add(listener); + } + } + + public void removeFlavorListener(FlavorListener listener) + { + synchronized(listeners) + { + listeners.remove(listener); + } + } + + public FlavorListener[] getFlavorListeners() + { + synchronized(listeners) + { + return (FlavorListener[]) + listeners.toArray(new FlavorListener[listeners.size()]); + } + } +} diff --git a/java/awt/datatransfer/DataFlavor.java b/java/awt/datatransfer/DataFlavor.java index e5fbd2402..38f415b75 100644 --- a/java/awt/datatransfer/DataFlavor.java +++ b/java/awt/datatransfer/DataFlavor.java @@ -49,6 +49,7 @@ import java.io.StringReader; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.CharBuffer; +import java.rmi.Remote; /** * This class represents a particular data format used for transferring @@ -127,10 +128,9 @@ static javaFileListFlavor = new DataFlavor(java.util.List.class, + "application/x-java-file-list; class=java.util.List", "Java File List"); - // javaFileListFlavor.mimeType = "application/x-java-file-list"; - imageFlavor = new DataFlavor(java.awt.Image.class, "Java Image"); @@ -335,7 +335,8 @@ getRepresentationClassFromMime(String mimeString, ClassLoader classLoader) public DataFlavor(String mimeType, String humanPresentableName) { - this (getRepresentationClassFromMime (mimeType, null), humanPresentableName); + this (getRepresentationClassFromMime (mimeType, null), + mimeType, humanPresentableName); } /*************************************************************************/ @@ -426,17 +427,15 @@ getPrimaryType() public String getSubType() { - int idx = mimeType.indexOf("/"); - if (idx == -1) - return(""); - - String subtype = mimeType.substring(idx + 1); + int start = mimeType.indexOf("/"); + if (start == -1) + return ""; - idx = subtype.indexOf(" "); - if (idx == -1) - return(subtype); + int end = mimeType.indexOf(";", start + 1); + if (end == -1) + return mimeType.substring(start + 1); else - return(subtype.substring(0, idx)); + return mimeType.substring(start + 1, end); } /*************************************************************************/ @@ -480,6 +479,9 @@ getParameter(String paramName, String mimeString) public String getParameter(String paramName) { + if ("humanPresentableName".equals(paramName)) + return getHumanPresentableName(); + return getParameter(paramName, mimeType); } @@ -500,21 +502,28 @@ setHumanPresentableName(String humanPresentableName) /** * Tests the MIME type of this object for equality against the specified - * MIME type. + * MIME type. Ignores parameters. * * @param mimeType The MIME type to test against. * * @return <code>true</code> if the MIME type is equal to this object's - * MIME type, <code>false</code> otherwise. + * MIME type (ignoring parameters), <code>false</code> otherwise. * * @exception NullPointerException If mimeType is null. */ public boolean isMimeTypeEqual(String mimeType) { - // FIXME: Need to handle default attributes and parameters + String mime = getMimeType(); + int i = mime.indexOf(";"); + if (i != -1) + mime = mime.substring(0, i); + + i = mimeType.indexOf(";"); + if (i != -1) + mimeType = mimeType.substring(0, i); - return(this.mimeType.equals(mimeType)); + return mime.equals(mimeType); } /*************************************************************************/ @@ -599,8 +608,7 @@ isRepresentationClassSerializable() public boolean isRepresentationClassRemote() { - // FIXME: Implement - throw new RuntimeException("Not implemented"); + return Remote.class.isAssignableFrom (representationClass); } /*************************************************************************/ @@ -852,12 +860,11 @@ readExternal(ObjectInput stream) throws IOException, ClassNotFoundException public String toString() { - return("DataFlavor[representationClass=" - + representationClass.getName() - + ",mimeType=" - + mimeType - + "humanPresentableName=" - + humanPresentableName); + return(getClass().getName() + + "[representationClass=" + getRepresentationClass().getName() + + ",mimeType=" + getMimeType() + + ",humanPresentableName=" + getHumanPresentableName() + + "]"); } /*************************************************************************/ diff --git a/java/awt/datatransfer/FlavorEvent.java b/java/awt/datatransfer/FlavorEvent.java new file mode 100644 index 000000000..8252dea3b --- /dev/null +++ b/java/awt/datatransfer/FlavorEvent.java @@ -0,0 +1,55 @@ +/* FlavorEvent -- Event indicating a ClipBoard has different flavors 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 java.awt.datatransfer; + +import java.util.EventObject; + +/** + * Event indicating a Clipboard has different flavors available. + * Fired by a ClipBoard for registered FlavorListeners. + * + * @author Mark J. Wielaard (mark@klomp.org) + */ +public class FlavorEvent extends EventObject +{ + public FlavorEvent(Clipboard board) + { + super(board); + } +} diff --git a/java/awt/datatransfer/FlavorListener.java b/java/awt/datatransfer/FlavorListener.java new file mode 100644 index 000000000..31b164d6b --- /dev/null +++ b/java/awt/datatransfer/FlavorListener.java @@ -0,0 +1,54 @@ +/* FlavorListener -- Interface for tagging an interest in FlavorEvents. + 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.awt.datatransfer; + +import java.util.EventListener; + +/** + * Interface for tagging an interest in FlavorEvents by a class. The + * flavorsChanged() method will be called with a FlavorEvent pointing + * to the Clipboard which has content in different Flavors available. + * + * @author Mark J. Wielaard (mark@klomp.org) + */ +public interface FlavorListener + extends EventListener +{ + void flavorsChanged(FlavorEvent event); +} diff --git a/java/io/ObjectInputStream.java b/java/io/ObjectInputStream.java index 4b6b7ac7b..83e5ece67 100644 --- a/java/io/ObjectInputStream.java +++ b/java/io/ObjectInputStream.java @@ -964,19 +964,13 @@ public class ObjectInputStream extends InputStream { if (this.readDataFromBlock) { - if (this.blockDataPosition + length > this.blockDataBytes) - { - int remain = this.blockDataBytes - this.blockDataPosition; - if (remain != 0) - { - System.arraycopy(this.blockData, this.blockDataPosition, - data, offset, remain); - offset += remain; - length -= remain; - } - readNextBlock (); - } - + int remain = this.blockDataBytes - this.blockDataPosition; + if (remain == 0) + { + readNextBlock(); + remain = this.blockDataBytes - this.blockDataPosition; + } + length = Math.min(length, remain); System.arraycopy(this.blockData, this.blockDataPosition, data, offset, length); this.blockDataPosition += length; diff --git a/java/lang/Class.java b/java/lang/Class.java index d6ba44e81..f7e768443 100644 --- a/java/lang/Class.java +++ b/java/lang/Class.java @@ -163,11 +163,7 @@ public final class Class<T> */ public static Class<?> forName(String name) throws ClassNotFoundException { - Class<?> result = VMClass.forName (name); - if (result == null) - result = Class.forName(name, true, - VMStackWalker.getCallingClassLoader()); - return result; + return VMClass.forName(name, true, VMStackWalker.getCallingClassLoader()); } /** @@ -212,24 +208,8 @@ public final class Class<T> if (cl != null) sm.checkPermission(new RuntimePermission("getClassLoader")); } - if (name.startsWith("[")) - return VMClass.loadArrayClass(name, null); - Class<?> c = VMClassLoader.loadClass(name, true); - if (c != null) - { - if (initialize) - VMClass.initialize(c); - return c; - } - throw new ClassNotFoundException(name); } - if (name.startsWith("[")) - return VMClass.loadArrayClass(name, classloader); - Class<?> c = classloader.loadClass(name); - classloader.resolveClass(c); - if (initialize) - VMClass.initialize(c); - return c; + return (Class<?>) VMClass.forName(name, initialize, classloader); } /** diff --git a/java/lang/ClassLoader.java b/java/lang/ClassLoader.java index d73b9f600..3dc12677b 100644 --- a/java/lang/ClassLoader.java +++ b/java/lang/ClassLoader.java @@ -124,14 +124,6 @@ import java.util.StringTokenizer; public abstract class ClassLoader { /** - * All classes loaded by this classloader. If the VM's chooses to implement - * this cache natively this field will be null. - * It is not private in order to allow VMClassLoader access to this field. - */ - final HashMap<String, Class<?>> loadedClasses = - VMClassLoader.USE_VM_CACHE ? null : new HashMap<String, Class<?>>(); - - /** * All packages defined by this classloader. It is not private in order to * allow native code (and trusted subclasses) access to this field. */ @@ -472,16 +464,10 @@ public abstract class ClassLoader ProtectionDomain domain) throws ClassFormatError { + checkInitialized(); if (domain == null) domain = StaticData.defaultProtectionDomain; - if (! initialized) - throw new SecurityException("attempt to define class from uninitialized class loader"); - - Class<?> retval = VMClassLoader.defineClass(this, name, data, - offset, len, domain); - if (! VMClassLoader.USE_VM_CACHE) - loadedClasses.put(retval.getName(), retval); - return retval; + return VMClassLoader.defineClass(this, name, data, offset, len, domain); } protected final Class<?> defineClass(String name, ByteBuffer buf, @@ -503,6 +489,7 @@ public abstract class ClassLoader */ protected final void resolveClass(Class<?> c) { + checkInitialized(); VMClassLoader.resolveClass(c); } @@ -518,6 +505,7 @@ public abstract class ClassLoader protected final Class<?> findSystemClass(String name) throws ClassNotFoundException { + checkInitialized(); return Class.forName(name, false, StaticData.systemClassLoader); } @@ -554,6 +542,7 @@ public abstract class ClassLoader */ protected final void setSigners(Class<?> c, Object[] signers) { + checkInitialized(); c.setSigners(signers); } @@ -566,6 +555,7 @@ public abstract class ClassLoader */ protected final synchronized Class<?> findLoadedClass(String name) { + checkInitialized(); return VMClassLoader.findLoadedClass(this, name); } @@ -1123,4 +1113,17 @@ public abstract class ClassLoader .initCause(e); } } + + /** + * Before doing anything "dangerous" please call this method to make sure + * this class loader instance was properly constructed (and not obtained + * by exploiting the finalizer attack) + * @see #initialized + */ + private void checkInitialized() + { + if (! initialized) + throw new SecurityException("attempt to use uninitialized class loader"); + } + } diff --git a/java/nio/Buffer.java b/java/nio/Buffer.java index 47dabf29e..2c7e00dcb 100644 --- a/java/nio/Buffer.java +++ b/java/nio/Buffer.java @@ -38,7 +38,7 @@ exception statement from your version. */ package java.nio; -import gnu.classpath.RawData; +import gnu.classpath.Pointer; /** * @since 1.4 @@ -49,7 +49,7 @@ public abstract class Buffer int limit = 0; int pos = 0; int mark = -1; - RawData address; + Pointer address; /** * Creates a new Buffer. diff --git a/java/nio/DirectByteBufferImpl.java b/java/nio/DirectByteBufferImpl.java index 796a157b6..53bb668aa 100644 --- a/java/nio/DirectByteBufferImpl.java +++ b/java/nio/DirectByteBufferImpl.java @@ -38,7 +38,7 @@ exception statement from your version. */ package java.nio; -import gnu.classpath.RawData; +import gnu.classpath.Pointer; abstract class DirectByteBufferImpl extends ByteBuffer { @@ -59,7 +59,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer static final class ReadOnly extends DirectByteBufferImpl { - ReadOnly(Object owner, RawData address, + ReadOnly(Object owner, Pointer address, int capacity, int limit, int position) { @@ -89,7 +89,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer super(capacity); } - ReadWrite(Object owner, RawData address, + ReadWrite(Object owner, Pointer address, int capacity, int limit, int position) { @@ -109,7 +109,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer this.address = VMDirectByteBuffer.allocate(capacity); } - DirectByteBufferImpl(Object owner, RawData address, + DirectByteBufferImpl(Object owner, Pointer address, int capacity, int limit, int position) { diff --git a/java/nio/MappedByteBufferImpl.java b/java/nio/MappedByteBufferImpl.java index 1b075d875..a53040f57 100644 --- a/java/nio/MappedByteBufferImpl.java +++ b/java/nio/MappedByteBufferImpl.java @@ -38,7 +38,7 @@ exception statement from your version. */ package java.nio; -import gnu.classpath.RawData; +import gnu.classpath.Pointer; import java.io.IOException; @@ -48,12 +48,12 @@ final class MappedByteBufferImpl extends MappedByteBuffer /** Posix uses this for the pointer returned by mmap; * Win32 uses it for the pointer returned by MapViewOfFile. */ - public RawData implPtr; + public Pointer implPtr; /** Posix uses this for the actual length passed to mmap; * Win32 uses it for the pointer returned by CreateFileMapping. */ public long implLen; - public MappedByteBufferImpl(RawData address, int size, boolean readOnly) + public MappedByteBufferImpl(Pointer address, int size, boolean readOnly) throws IOException { super(size, size, 0, -1); diff --git a/java/nio/channels/FileLock.java b/java/nio/channels/FileLock.java index 151c23f9f..c46695837 100644 --- a/java/nio/channels/FileLock.java +++ b/java/nio/channels/FileLock.java @@ -45,10 +45,10 @@ import java.io.IOException; */ public abstract class FileLock { - FileChannel channel; - long position; - long size; - boolean shared; + private final FileChannel channel; + private final long position; + private final long size; + private final boolean shared; /** * Initializes the file lock. diff --git a/javax/swing/JCheckBoxMenuItem.java b/javax/swing/JCheckBoxMenuItem.java index 39fbc191c..f9dd56500 100644 --- a/javax/swing/JCheckBoxMenuItem.java +++ b/javax/swing/JCheckBoxMenuItem.java @@ -149,6 +149,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants, super(text, icon); setModel(new JToggleButton.ToggleButtonModel()); this.state = state; + this.setVisible(true); } private void writeObject(ObjectOutputStream stream) throws IOException diff --git a/javax/swing/JList.java b/javax/swing/JList.java index fb8d18b85..0e38fb1c8 100644 --- a/javax/swing/JList.java +++ b/javax/swing/JList.java @@ -574,7 +574,7 @@ public class JList extends JComponent implements Accessible, Scrollable ComponentOrientation or = getComponentOrientation(); Rectangle r = getVisibleRect(); if (or == ComponentOrientation.RIGHT_TO_LEFT) - r.translate((int) r.getWidth(), 0); + r.translate((int) r.getWidth() - 1, 0); return getUI().locationToIndex(this, r.getLocation()); } @@ -612,9 +612,9 @@ public class JList extends JComponent implements Accessible, Scrollable { ComponentOrientation or = getComponentOrientation(); Rectangle r = getVisibleRect(); - r.translate(0, (int) r.getHeight()); + r.translate(0, (int) r.getHeight() - 1); if (or == ComponentOrientation.LEFT_TO_RIGHT) - r.translate((int) r.getWidth(), 0); + r.translate((int) r.getWidth() - 1, 0); return getUI().locationToIndex(this, r.getLocation()); } diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java index 04ea714f2..e683d509f 100644 --- a/javax/swing/JTable.java +++ b/javax/swing/JTable.java @@ -872,7 +872,7 @@ public class JTable extends JComponent int column, boolean includeSpacing) { - int height = getHeight(); + int height = getRowHeight(row); int width = columnModel.getColumn(column).getWidth(); int x_gap = columnModel.getColumnMargin(); int y_gap = rowMargin; @@ -1100,6 +1100,19 @@ public class JTable extends JComponent } /** + * Get the height of the specified row. + * + * @param row the row whose height to return + */ + public int getRowHeight(int row) + { + // FIXME: return the height of the specified row + // which may be different from the general rowHeight + return rowHeight; + } + + + /** * Get the value of the {@link #rowMargin} property. * * @return The current value of the property diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java index f5eee8a19..d750bad29 100644 --- a/javax/swing/JViewport.java +++ b/javax/swing/JViewport.java @@ -498,11 +498,11 @@ public class JViewport extends JComponent 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) @@ -510,24 +510,22 @@ public class JViewport extends JComponent setViewPosition(new Point(contentRect.x, contentRect.y)); return; } - + // Y-DIRECTION - if (contentRect.y + viewBounds.y < portBounds.y) + if (contentRect.y < -viewBounds.y) setViewPosition(new Point(pos.x, contentRect.y)); - else if (contentRect.y + viewBounds.y + contentRect.height > - (portBounds.y+portBounds.height)) + else if (contentRect.y + contentRect.height > + -viewBounds.y + portBounds.height) setViewPosition (new Point(pos.x, contentRect.y - - (portBounds.height - contentRect.height) - - portBounds.y)); - + (portBounds.height - contentRect.height))); + // X-DIRECTION pos = getViewPosition(); - if (contentRect.x + viewBounds.x < portBounds.x) + if (contentRect.x < -viewBounds.x) setViewPosition(new Point(contentRect.x, pos.y)); - else if (contentRect.x + viewBounds.x + contentRect.width > - (portBounds.x + portBounds.height)) + else if (contentRect.x + contentRect.width > + -viewBounds.x + portBounds.width) setViewPosition (new Point(contentRect.x - - (portBounds.width - contentRect.width) - - portBounds.x, pos.y)); + (portBounds.width - contentRect.width), pos.y)); } } diff --git a/javax/swing/plaf/basic/BasicCheckBoxUI.java b/javax/swing/plaf/basic/BasicCheckBoxUI.java index e3167327c..a2085ecba 100644 --- a/javax/swing/plaf/basic/BasicCheckBoxUI.java +++ b/javax/swing/plaf/basic/BasicCheckBoxUI.java @@ -38,6 +38,7 @@ exception statement from your version. */ package javax.swing.plaf.basic; +import javax.swing.AbstractButton; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.UIDefaults; @@ -59,6 +60,9 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI public void installUI(final JComponent c) { super.installUI(c); + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + ((AbstractButton) c).setIcon(defaults.getIcon("CheckBox.icon")); + ((AbstractButton) c).setSelectedIcon(defaults.getIcon("CheckBox.checkIcon")); } // Overridden to change method access. diff --git a/javax/swing/plaf/basic/BasicGraphicsUtils.java b/javax/swing/plaf/basic/BasicGraphicsUtils.java index 78ee62f95..757ac47c9 100644 --- a/javax/swing/plaf/basic/BasicGraphicsUtils.java +++ b/javax/swing/plaf/basic/BasicGraphicsUtils.java @@ -609,7 +609,7 @@ public class BasicGraphicsUtils * LineMetrics, not a FontMetrics argument. But fixing this that * would change the public API. */ - SwingUtilities.layoutCompoundLabel( + SwingUtilities.layoutCompoundLabel( b, // for the component orientation b.getToolkit().getFontMetrics(b.getFont()), // see comment above b.getText(), @@ -630,10 +630,10 @@ public class BasicGraphicsUtils */ contentRect = textRect.union(iconRect); - + return new Dimension(insets.left + contentRect.width - + insets.right, + + insets.right + b.getHorizontalAlignment(), insets.top + contentRect.height + insets.bottom); diff --git a/javax/swing/plaf/basic/BasicIconFactory.java b/javax/swing/plaf/basic/BasicIconFactory.java index 43380c203..8dc209c50 100644 --- a/javax/swing/plaf/basic/BasicIconFactory.java +++ b/javax/swing/plaf/basic/BasicIconFactory.java @@ -157,16 +157,37 @@ public class BasicIconFactory implements Serializable // The icon is empty and needs no painting. } } - /** The cached CheckBoxIcon instance. */ private static CheckBoxIcon checkBoxIcon; - - /** The cached CheckBoxIcon instance. */ + + /** The cached RadioButtonIcon instance. */ private static RadioButtonIcon radioButtonIcon; public static Icon getMenuItemCheckIcon() { - return new DummyIcon(); + return new Icon() + { + public int getIconHeight() + { + return 13; + } + + public int getIconWidth() + { + return 13; + } + + public void paintIcon(Component c, Graphics g, int x, int y) + { + Color saved = g.getColor(); + g.setColor(Color.BLACK); + g.drawLine(3 + x, 5 + y, 3 + x, 9 + y); + g.drawLine(4 + x, 5 + y, 4 + x, 9 + y); + g.drawLine(5 + x, 7 + y, 9 + x, 3 + y); + g.drawLine(5 + x, 8 + y, 9 + x, 4 + y); + g.setColor(saved); + } + }; } public static Icon getMenuItemArrowIcon() { @@ -236,10 +257,12 @@ public class BasicIconFactory implements Serializable { return getCheckBoxIcon(); } + public static Icon getRadioButtonMenuItemIcon() { return getRadioButtonIcon(); } + public static Icon createEmptyFrameIcon() { return new DummyIcon(); diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java index 54d91d888..2161d5d97 100644 --- a/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -277,7 +277,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "Button.shadow", new ColorUIResource(Color.GRAY), "Button.textIconGap", new Integer(4), "Button.textShiftOffset", new Integer(0), - "CheckBox.background", new ColorUIResource(light), + "CheckBox.background", new ColorUIResource(new Color(204, 204, 204)), "CheckBox.border", new BorderUIResource.CompoundBorderUIResource(null, null), "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { @@ -294,20 +294,43 @@ public abstract class BasicLookAndFeel extends LookAndFeel return BasicIconFactory.getCheckBoxIcon(); } }, + "CheckBox.checkIcon", + new UIDefaults.LazyValue() + { + public Object createValue(UIDefaults def) + { + return BasicIconFactory.getMenuItemCheckIcon(); + } + }, "CheckBox.margin",new InsetsUIResource(2, 2, 2, 2), "CheckBox.textIconGap", new Integer(4), "CheckBox.textShiftOffset", new Integer(0), + "CheckBoxMenuItem.icon", + new UIDefaults.LazyValue() + { + public Object createValue(UIDefaults def) + { + return BasicIconFactory.getCheckBoxIcon(); + } + }, "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 12), "CheckBoxMenuItem.acceleratorForeground", - new ColorUIResource(darkShadow), + new ColorUIResource(new Color(16, 16, 16)), "CheckBoxMenuItem.acceleratorSelectionForeground", new ColorUIResource(Color.white), "CheckBoxMenuItem.arrowIcon", BasicIconFactory.getMenuItemArrowIcon(), "CheckBoxMenuItem.background", new ColorUIResource(light), "CheckBoxMenuItem.border", new BasicBorders.MarginBorder(), "CheckBoxMenuItem.borderPainted", Boolean.FALSE, - "CheckBoxMenuItem.checkIcon", BasicIconFactory.getCheckBoxMenuItemIcon(), + "CheckBoxMenuItem.checkIcon", + new UIDefaults.LazyValue() + { + public Object createValue(UIDefaults def) + { + return BasicIconFactory.getMenuItemCheckIcon(); + } + }, "CheckBoxMenuItem.font", new FontUIResource("Dialog", Font.PLAIN, 12), "CheckBoxMenuItem.foreground", new ColorUIResource(darkShadow), "CheckBoxMenuItem.margin", new InsetsUIResource(2, 2, 2, 2), diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java index bbacc5028..724e32f4c 100644 --- a/javax/swing/plaf/basic/BasicMenuItemUI.java +++ b/javax/swing/plaf/basic/BasicMenuItemUI.java @@ -355,7 +355,8 @@ public class BasicMenuItemUI extends MenuItemUI */ public Dimension getPreferredSize(JComponent c) { - return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap); + return getPreferredMenuItemSize(c, checkIcon, arrowIcon, + defaultTextIconGap); } protected String getPropertyPrefix() @@ -532,7 +533,11 @@ public class BasicMenuItemUI extends MenuItemUI SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); - checkIcon.paintIcon(m, g, cr.x, cr.y); + if (m.isSelected()) + checkIcon.paintIcon(m, g, cr.x, cr.y); + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + defaults.getBorder("CheckBox.border").paintBorder(m, g, cr.x, cr.y, + cr.width, cr.height); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java index aa8f21a62..d13373008 100644 --- a/javax/swing/plaf/basic/BasicTableUI.java +++ b/javax/swing/plaf/basic/BasicTableUI.java @@ -40,6 +40,7 @@ package javax.swing.plaf.basic; import java.awt.Color; import java.awt.Component; +import java.awt.ComponentOrientation; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Point; @@ -366,7 +367,8 @@ public class BasicTableUI } else if (evt.getKeyCode() == KeyEvent.VK_HOME) { - if (evt.getModifiers() == (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK)) + if (evt.getModifiers() == + (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK)) { rowModel.setLeadSelectionIndex(0); colModel.setLeadSelectionIndex(colLead); @@ -395,11 +397,93 @@ public class BasicTableUI } else if (evt.getKeyCode() == KeyEvent.VK_PAGE_UP) { - // FIXME: implement, need JList.ensureIndexIsVisible to work + int target; + if (!evt.isControlDown()) + { + if (rowLead == getFirstVisibleRowIndex()) + target = Math.max + (0, rowLead - (getLastVisibleRowIndex() - + getFirstVisibleRowIndex() + 1)); + else + target = getFirstVisibleRowIndex(); + + if (evt.getModifiers() == 0) + { + rowModel.setSelectionInterval(target, target); + colModel.setSelectionInterval(colLead, colLead); + } + else if (evt.getModifiers() == InputEvent.SHIFT_MASK) + { + rowModel.setLeadSelectionIndex(target); + colModel.setLeadSelectionIndex(colLead); + } + } + else + { + if (colLead == getFirstVisibleColumnIndex()) + target = Math.max + (0, colLead - (getLastVisibleColumnIndex() - + getFirstVisibleColumnIndex() + 1)); + else + target = getFirstVisibleColumnIndex(); + + if (evt.getModifiers() == InputEvent.CTRL_MASK) + { + colModel.setSelectionInterval(target, target); + rowModel.setSelectionInterval(rowLead, rowLead); + } + else if (evt.getModifiers() == + (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK)) + { + colModel.setLeadSelectionIndex(target); + rowModel.setLeadSelectionIndex(rowLead); + } + } } else if (evt.getKeyCode() == KeyEvent.VK_PAGE_DOWN) { - // FIXME: implement, need JList.ensureIndexIsVisible to work + int target; + if (!evt.isControlDown()) + { + if (rowLead == getLastVisibleRowIndex()) + target = Math.min + (rowMax, rowLead + (getLastVisibleRowIndex() - + getFirstVisibleRowIndex() + 1)); + else + target = getLastVisibleRowIndex(); + + if (evt.getModifiers() == 0) + { + rowModel.setSelectionInterval(target, target); + colModel.setSelectionInterval(colLead, colLead); + } + else if (evt.getModifiers() == InputEvent.SHIFT_MASK) + { + rowModel.setLeadSelectionIndex(target); + colModel.setLeadSelectionIndex(colLead); + } + } + else + { + if (colLead == getLastVisibleColumnIndex()) + target = Math.min + (colMax, colLead + (getLastVisibleColumnIndex() - + getFirstVisibleColumnIndex() + 1)); + else + target = getLastVisibleColumnIndex(); + + if (evt.getModifiers() == InputEvent.CTRL_MASK) + { + colModel.setSelectionInterval(target, target); + rowModel.setSelectionInterval(rowLead, rowLead); + } + else if (evt.getModifiers() == + (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK)) + { + colModel.setLeadSelectionIndex(target); + rowModel.setLeadSelectionIndex(rowLead); + } + } } else if (evt.getKeyCode() == KeyEvent.VK_TAB || evt.getKeyCode() == KeyEvent.VK_ENTER) @@ -504,6 +588,9 @@ public class BasicTableUI { table.changeSelection(rowLead, colLead, true, false); } + table.scrollRectToVisible + (table.getCellRect(rowModel.getLeadSelectionIndex(), + colModel.getLeadSelectionIndex(), false)); } public void keyReleased(KeyEvent e) @@ -513,6 +600,69 @@ public class BasicTableUI public void keyTyped(KeyEvent e) { } + + /** + * Returns the column index of the first visible column. + * + */ + int getFirstVisibleColumnIndex() + { + ComponentOrientation or = table.getComponentOrientation(); + Rectangle r = table.getVisibleRect(); + if (!or.isLeftToRight()) + r.translate((int) r.getWidth() - 1, 0); + return table.columnAtPoint(r.getLocation()); + } + + /** + * Returns the column index of the last visible column. + * + */ + int getLastVisibleColumnIndex() + { + ComponentOrientation or = table.getComponentOrientation(); + Rectangle r = table.getVisibleRect(); + if (or.isLeftToRight()) + r.translate((int) r.getWidth() - 1, 0); + return table.columnAtPoint(r.getLocation()); + } + + /** + * Returns the row index of the first visible row. + * + */ + int getFirstVisibleRowIndex() + { + ComponentOrientation or = table.getComponentOrientation(); + Rectangle r = table.getVisibleRect(); + if (!or.isLeftToRight()) + r.translate((int) r.getWidth() - 1, 0); + return table.rowAtPoint(r.getLocation()); + } + + /** + * Returns the row index of the last visible row. + * + */ + int getLastVisibleRowIndex() + { + ComponentOrientation or = table.getComponentOrientation(); + Rectangle r = table.getVisibleRect(); + r.translate(0, (int) r.getHeight() - 1); + if (or.isLeftToRight()) + r.translate((int) r.getWidth() - 1, 0); + // The next if makes sure that we don't return -1 simply because + // there is white space at the bottom of the table (ie, the display + // area is larger than the table) + if (table.rowAtPoint(r.getLocation()) == -1) + { + if (getFirstVisibleRowIndex() == -1) + return -1; + else + return table.getModel().getRowCount() - 1; + } + return table.rowAtPoint(r.getLocation()); + } } class MouseInputHandler implements MouseInputListener diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java index acd0261ed..236c0ccd0 100644 --- a/javax/swing/plaf/basic/BasicTextUI.java +++ b/javax/swing/plaf/basic/BasicTextUI.java @@ -229,13 +229,27 @@ public abstract class BasicTextUI extends TextUI public Shape modelToView(int position, Shape a, Position.Bias bias) throws BadLocationException { - if (view == null) - return null; - return ((View) view).modelToView(position, a, bias); } /** + * Maps coordinates from the <code>View</code>'s space into a position + * in the document model. + * + * @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> + * @param b the bias to use + * + * @return the position in the document that corresponds to the screen + * coordinates <code>x, y</code> + */ + public int viewToModel(float x, float y, Shape a, Position.Bias b) + { + return view.viewToModel(x, y, a, b); + } + + /** * Notification about text insertions. These are forwarded to the * real root view. * diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java index 067cb0c3b..0ccc0f5be 100644 --- a/javax/swing/plaf/basic/BasicTreeUI.java +++ b/javax/swing/plaf/basic/BasicTreeUI.java @@ -88,7 +88,6 @@ import javax.swing.event.TreeSelectionListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.TreeUI; import javax.swing.tree.AbstractLayoutCache; -import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellEditor; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.FixedHeightLayoutCache; @@ -326,7 +325,7 @@ public class BasicTreeUI extends TreeUI * * @return the indent value for the right child. */ - public int getRightChildIndent(int newAmount) + public int getRightChildIndent() { return rightChildIndent; } @@ -584,10 +583,10 @@ public class BasicTreeUI extends TreeUI { Object cell = path.getLastPathComponent(); TreeModel mod = tree.getModel(); - DefaultMutableTreeNode root = (DefaultMutableTreeNode) mod.getRoot(); + TreeNode root = (TreeNode) mod.getRoot(); if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root))) - root = root.getNextNode(); + root = getNextNode(root); Point loc = getCellLocation(0, 0, tree, mod, cell, root); return getCellBounds(loc.x, loc.y, cell); @@ -606,12 +605,10 @@ public class BasicTreeUI extends TreeUI */ public TreePath getPathForRow(JTree tree, int row) { - DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel()) - .getRoot()); + TreeNode node = ((TreeNode) (tree.getModel()).getRoot()); if (!tree.isRootVisible() - && tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node) - .getPath()))) - node = node.getNextNode(); + && tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) + node = getNextNode(node); for (int i = 0; i < row; i++) node = getNextVisibleNode(node); @@ -621,7 +618,7 @@ public class BasicTreeUI extends TreeUI return null; // something was found - return new TreePath(node.getPath()); + return new TreePath(getPathToRoot(node, 0)); } /** @@ -650,12 +647,11 @@ public class BasicTreeUI extends TreeUI */ public int getRowCount(JTree tree) { - DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel()) + TreeNode node = ((TreeNode) (tree.getModel()) .getRoot()); if (!tree.isRootVisible() - && tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node) - .getPath()))) - node = node.getNextNode(); + && tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) + node = getNextNode(node); int count = 0; @@ -1309,8 +1305,7 @@ public class BasicTreeUI extends TreeUI while (node != null) { count++; - DefaultMutableTreeNode nextNode = getNextVisibleNode( - new DefaultMutableTreeNode(node)); + TreeNode nextNode = getNextVisibleNode(node); if (nextNode != null) maxWidth = Math.max(maxWidth, (int) (getCellBounds(0, 0, nextNode) .getWidth())); @@ -1695,9 +1690,9 @@ public class BasicTreeUI extends TreeUI public void keyPressed(KeyEvent e) { TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath(); - DefaultMutableTreeNode last = null; + TreeNode last = null; if (start != null) - last = (DefaultMutableTreeNode) start.getLastPathComponent(); + last = (TreeNode) start.getLastPathComponent(); if (last != null) { @@ -1705,11 +1700,11 @@ public class BasicTreeUI extends TreeUI if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN) { - DefaultMutableTreeNode next = (DefaultMutableTreeNode) - BasicTreeUI.this.getNextVisibleNode(last); + TreeNode next = (TreeNode) BasicTreeUI.this. + getNextVisibleNode(last); if (next != null) { - TreePath newPath = new TreePath(next.getPath()); + TreePath newPath = new TreePath(getPathToRoot(next, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); @@ -1724,14 +1719,14 @@ public class BasicTreeUI extends TreeUI else if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP) { - DefaultMutableTreeNode prev = (DefaultMutableTreeNode) - BasicTreeUI.this.getPreviousVisibleNode(last); + TreeNode prev = (TreeNode) BasicTreeUI.this. + getPreviousVisibleNode(last); if (prev != null) { - TreePath newPath = new TreePath(prev.getPath()); + TreePath newPath = new TreePath(getPathToRoot(prev, 0)); BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, - new TreePath(prev.getPath())); + new TreePath(getPathToRoot(prev, 0))); if (e.isControlDown()) tree.setLeadSelectionPath(newPath); else if (!prev.isLeaf() && e.isShiftDown()) @@ -1745,9 +1740,8 @@ public class BasicTreeUI extends TreeUI else if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_KP_LEFT) { - TreePath path = new TreePath(last.getPath()); - DefaultMutableTreeNode p = (DefaultMutableTreeNode) last - .getParent(); + TreePath path = new TreePath(getPathToRoot(last, 0)); + TreeNode p = last.getParent(); if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path)) { @@ -1756,13 +1750,13 @@ public class BasicTreeUI extends TreeUI } else if (p != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, - new TreePath(p.getPath())); + new TreePath(getPathToRoot(p, 0))); } // RIGHT, KP_RIGHT else if (e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_KP_RIGHT) { - TreePath path = new TreePath(last.getPath()); + TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path)) { @@ -1771,18 +1765,18 @@ public class BasicTreeUI extends TreeUI } else { - DefaultMutableTreeNode next = (DefaultMutableTreeNode) - BasicTreeUI.this.getNextVisibleNode(last); + TreeNode next = (TreeNode) BasicTreeUI.this. + getNextVisibleNode(last); if (next != null) BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, - new TreePath(next.getPath())); + new TreePath(getPathToRoot(next, 0))); } } // Enter else if (e.getKeyCode() == KeyEvent.VK_ENTER) { - TreePath path = new TreePath(last.getPath()); + TreePath path = new TreePath(getPathToRoot(last, 0)); if (!last.isLeaf()) { if (BasicTreeUI.this.tree.isExpanded(path)) @@ -2535,16 +2529,16 @@ public class BasicTreeUI extends TreeUI if (startNode == null || startNode.equals(node)) { if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot()))) - return new Point(x + ((((DefaultMutableTreeNode) node).getLevel()) - * rightChildIndent), y); + return new Point(x + ((getLevel((TreeNode) node)) * + rightChildIndent), y); - return new Point(x + ((((DefaultMutableTreeNode) node).getLevel() + 1) + return new Point(x + ((getLevel((TreeNode) node) + 1) * rightChildIndent), y); } if (!mod.isLeaf(startNode) - && tree.isExpanded(new TreePath( - ((DefaultMutableTreeNode) startNode).getPath()))) + && tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) startNode), + 0)))) { Object child = mod.getChild(startNode, 0); if (child != null) @@ -2553,7 +2547,7 @@ public class BasicTreeUI extends TreeUI } return getCellLocation(x, y + rowHeight, tree, mod, node, - getNextVisibleNode((DefaultMutableTreeNode) startNode)); + getNextVisibleNode((TreeNode) startNode)); } /** @@ -2568,15 +2562,15 @@ public class BasicTreeUI extends TreeUI void paintNode(Graphics g, int x, int y, JTree tree, Object node, boolean isLeaf) { - TreePath curr = new TreePath(((DefaultMutableTreeNode) node).getPath()); + TreePath curr = new TreePath(getPathToRoot(((TreeNode) node), 0)); boolean selected = tree.isPathSelected(curr); boolean expanded = false; boolean hasIcons = false; if (tree.isVisible(curr)) { - DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tree - .getCellRenderer(); + DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) + createDefaultCellRenderer(); if (!isLeaf) expanded = tree.isExpanded(curr); @@ -2667,8 +2661,7 @@ public class BasicTreeUI extends TreeUI } int max = mod.getChildCount(curr); - if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr) - .getPath()))) + if (tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) curr), 0)))) { for (int i = 0; i < max; ++i) { @@ -2685,13 +2678,13 @@ public class BasicTreeUI extends TreeUI } descent = paintRecursive(g, indent, - descent, i, depth + 1, tree, mod, mod.getChild(curr, i)); + descent, i, depth + 1, tree, mod, + mod.getChild(curr, i)); } } } - if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr) - .getPath()))) + if (tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) curr), 0)))) if (y0 != heightOfLine) { g.setColor(getHashColor()); @@ -2739,11 +2732,10 @@ public class BasicTreeUI extends TreeUI descent += rowHeight; int max = mod.getChildCount(node); - if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node) - .getPath()))) + if (tree.isExpanded(new TreePath(getPathToRoot(((TreeNode) node), 0)))) { if (!node.equals(mod.getRoot())) - ei.paintIcon(tree, g, indentation - rightChildIndent - 3, h); + drawCentered(tree, g, ei, indentation - rightChildIndent - 3, h); for (int i = 0; i < max; ++i) { @@ -2752,11 +2744,12 @@ public class BasicTreeUI extends TreeUI indent = -1; descent = paintControlIcons(g, indent, - descent, i, depth + 1, tree, mod, mod.getChild(node, i)); + descent, i, depth + 1, tree, mod, + mod.getChild(node, i)); } } else if (!node.equals(mod.getRoot())) - ci.paintIcon(tree, g, indentation - rightChildIndent - 3, + drawCentered(tree, g, ei, indentation - rightChildIndent - 3, descent - getRowHeight()); } @@ -2787,26 +2780,26 @@ public class BasicTreeUI extends TreeUI * @return the next visible node in the JTree. Return null if there are no * more. */ - DefaultMutableTreeNode getNextVisibleNode(DefaultMutableTreeNode node) + TreeNode getNextVisibleNode(TreeNode node) { - DefaultMutableTreeNode next = null; + TreeNode next = null; TreePath current = null; if (node != null) - next = node.getNextNode(); + next = getNextNode(node); if (next != null) { - current = new TreePath(next.getPath()); + current = new TreePath(getPathToRoot(next, 0)); if (tree.isVisible(current)) return next; while (next != null && !tree.isVisible(current)) { - next = next.getNextNode(); + next = getNextNode(next); if (next != null) - current = new TreePath(next.getPath()); + current = new TreePath(getPathToRoot(next, 0)); } } return next; @@ -2820,33 +2813,124 @@ public class BasicTreeUI extends TreeUI * @return the next visible node in the JTree. Return null if there are no * more. */ - DefaultMutableTreeNode getPreviousVisibleNode - (DefaultMutableTreeNode node) + TreeNode getPreviousVisibleNode(TreeNode node) { - DefaultMutableTreeNode prev = null; + TreeNode prev = null; TreePath current = null; if (node != null) - prev = node.getPreviousNode(); + prev = getPreviousNode(node); if (prev != null) { - current = new TreePath(prev.getPath()); + current = new TreePath(getPathToRoot(prev, 0)); if (tree.isVisible(current)) return prev; while (prev != null && !tree.isVisible(current)) { - prev = prev.getPreviousNode(); + prev = getPreviousNode(prev); if (prev != null) - current = new TreePath(prev.getPath()); + current = new TreePath(getPathToRoot(prev, 0)); } } return prev; } /** + * Returns the next node in the tree + * Package private for use in inner classes. + * + * @return TreeNode, the next node in the tree + */ + TreeNode getNextNode(TreeNode curr) + { + if (curr.getChildCount() != 0) + return curr.getChildAt(0); + + TreeNode node = curr; + TreeNode sibling; + + do + { + sibling = getNextSibling(node); + node = node.getParent(); + } + while (sibling == null && + node != null); + + return sibling; + } + + /** + * Returns the previous node in the tree + * Package private for use in inner classes. + * + * @return TreeNode, the previous node in the tree + */ + TreeNode getPreviousNode(TreeNode node) + { + TreeNode parent = node.getParent(); + if (parent == null) + return null; + + TreeNode sibling = getPreviousSibling(node); + + if (sibling == null) + return parent; + + int size = sibling.getChildCount(); + while (size > 0) + { + sibling = sibling.getChildAt(size - 1); + size = sibling.getChildCount(); + } + + return sibling; + } + + /** + * Returns the next sibling in the tree + * Package private for use in inner classes. + * + * @return TreeNode, the next sibling in the tree + */ + TreeNode getNextSibling(TreeNode node) + { + TreeNode parent = node.getParent(); + if (parent == null) + return null; + + int index = parent.getIndex(node) + 1; + + if (index == parent.getChildCount()) + return null; + + return parent.getChildAt(index); + } + + /** + * Returns the previous sibling in the tree + * Package private for use in inner classes. + * + * @return TreeNode, the previous sibling in the tree + */ + TreeNode getPreviousSibling(TreeNode node) + { + TreeNode parent = node.getParent(); + if (parent == null) + return null; + + int index = parent.getIndex(node) - 1; + + if (index < 0) + return null; + + return parent.getChildAt(index); + } + + /** * Selects the specified path in the tree depending on modes. * Package private for use in inner classes. * @@ -2880,4 +2964,91 @@ public class BasicTreeUI extends TreeUI } } } + + /** + * Returns the path from node to the root. + * Package private for use in inner classes. + * + * @param node the node to get the path to + * @param depth the depth of the tree to return a path for + * + * @return an array of tree nodes that represent the path to node. + */ + TreeNode[] getPathToRoot(TreeNode node, int depth) + { + if (node == null) + { + if (depth == 0) + return null; + + return new TreeNode[depth]; + } + + TreeNode[] path = getPathToRoot(node.getParent(), depth + 1); + path[path.length - depth - 1] = node; + return path; + } + + /** + * Returns the level of the node in the tree. + * + * @return the number of the level + */ + public int getLevel(TreeNode node) + { + int count = -1; + TreeNode current = node; + + do + { + current = current.getParent(); + count++; + } + while (current != null); + + return count; + } + + /** + * Draws a vertical line using the given graphic context + * + * @param g is the graphic context + * @param c is the component the new line will belong to + * @param x is the horizonal position + * @param top specifies the top of the line + * @param bottom specifies the bottom of the line + */ + protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom) { + g.drawLine(x, top, x, bottom); + } + + /** + * Draws a horizontal line using the given graphic context + * + * @param g is the graphic context + * @param c is the component the new line will belong to + * @param y is the vertical position + * @param left specifies the left point of the line + * @param right specifies the right point of the line + */ + protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right) { + g.drawLine(left, y, right, y); + } + + /** + * Draws an icon at around a specific position + * + * @param c is the component the new line will belong to + * @param g is the graphic context + * @param icon is the icon which will be drawn + * @param x is the center position in x-direction + * @param y 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) { + int beginPositionX = x - icon.getIconWidth() / 2; + int beginPositionY = y - icon.getIconHeight() / 2; + icon.paintIcon(c, g, beginPositionX, beginPositionY); + } } // BasicTreeUI
\ No newline at end of file diff --git a/javax/swing/plaf/basic/BasicViewportUI.java b/javax/swing/plaf/basic/BasicViewportUI.java index 8ce772bed..29074e60f 100644 --- a/javax/swing/plaf/basic/BasicViewportUI.java +++ b/javax/swing/plaf/basic/BasicViewportUI.java @@ -160,8 +160,8 @@ public class BasicViewportUI extends ViewportUI Rectangle viewBounds, Rectangle portBounds) { - Rectangle oldClip = g.getClipBounds (); - g.setClip (oldClip.intersection (viewBounds)); + Rectangle oldClip = g.getClipBounds(); + g.setClip(portBounds); g.translate (-pos.x, -pos.y); try { diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java index 373fb0593..a6cce510d 100644 --- a/javax/swing/plaf/metal/MetalLookAndFeel.java +++ b/javax/swing/plaf/metal/MetalLookAndFeel.java @@ -772,8 +772,12 @@ public class MetalLookAndFeel extends BasicLookAndFeel "Button.select", new ColorUIResource(getPrimaryControlShadow()), "Button.shadow", new ColorUIResource(getPrimaryControlShadow()), "CheckBox.background", new ColorUIResource(getControl()), + "CheckBox.border", MetalBorders.getButtonBorder(), "CheckBox.icon", new UIDefaults.ProxyLazyValue + ("javax.swing.plaf.metal.MetalCheckBoxIcon"), + "CheckBox.checkIcon", + new UIDefaults.ProxyLazyValue ("javax.swing.plaf.metal.MetalCheckBoxIcon"), "CheckBoxMenuItem.background", new ColorUIResource(getControl()), "ToolBar.background", new ColorUIResource(getControl()), diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java index 58d85732b..5dbbf51c6 100644 --- a/javax/swing/text/AbstractDocument.java +++ b/javax/swing/text/AbstractDocument.java @@ -56,61 +56,193 @@ import javax.swing.undo.AbstractUndoableEdit; import javax.swing.undo.CompoundEdit; import javax.swing.undo.UndoableEdit; +/** + * An abstract base implementation for the {@link Document} interface. + * This class provides some common functionality for all <code>Element</code>s, + * most notably it implements a locking mechanism to make document modification + * thread-safe. + * + * @author original author unknown + * @author Roman Kennke (roman@kennke.org) + */ public abstract class AbstractDocument implements Document, Serializable { + /** The serial version UID for this class as of JDK1.4. */ private static final long serialVersionUID = -116069779446114664L; - + + /** + * Standard error message to indicate a bad location. + */ protected static final String BAD_LOCATION = "document location failure"; - + + /** + * Standard name for unidirectional <code>Element</code>s. + */ public static final String BidiElementName = "bidi level"; + + /** + * Standard name for content <code>Element</code>s. These are usually + * {@link LeafElement}s. + */ public static final String ContentElementName = "content"; + + /** + * Standard name for paragraph <code>Element</code>s. These are usually + * {@link BranchElement}s. + */ public static final String ParagraphElementName = "paragraph"; + + /** + * Standard name for section <code>Element</code>s. These are usually + * {@link DefaultStyledDocument.SectionElement}s. + */ public static final String SectionElementName = "section"; + + /** + * Attribute key for storing the element name. + */ public static final String ElementNameAttribute = "$ename"; + /** + * The actual content model of this <code>Document</code>. + */ Content content; + + /** + * The AttributeContext for this <code>Document</code>. + */ AttributeContext context; + + /** + * The currently installed <code>DocumentFilter</code>. + */ DocumentFilter documentFilter; - /** The documents properties. */ + /** + * The documents properties. + */ Dictionary properties; + /** + * Manages event listeners for this <code>Document</code>. + */ protected EventListenerList listenerList = new EventListenerList(); + /** + * Creates a new <code>AbstractDocument</code> with the specified + * {@link Content} model. + * + * @param doc the <code>Content</code> model to be used in this + * <code>Document<code> + * + * @see {@link GapContent} + * @see {@link StringContent} + */ protected AbstractDocument(Content doc) { this(doc, StyleContext.getDefaultStyleContext()); } + /** + * Creates a new <code>AbstractDocument</code> with the specified + * {@link Content} model and {@link AttributeContext}. + * + * @param doc the <code>Content</code> model to be used in this + * <code>Document<code> + * @param ctx the <code>AttributeContext</code> to use + * + * @see {@link GapContent} + * @see {@link StringContent} + */ protected AbstractDocument(Content doc, AttributeContext ctx) { content = doc; context = ctx; } - // These still need to be implemented by a derived class: + /** + * Returns the paragraph {@link Element} that holds the specified position. + * + * @param pos the position for which to get the paragraph element + * + * @return the paragraph {@link Element} that holds the specified position + */ public abstract Element getParagraphElement(int pos); + /** + * Returns the default root {@link Element} of this <code>Document</code>. + * Usual <code>Document</code>s only have one root element and return this. + * However, there may be <code>Document</code> implementations that + * support multiple root elements, they have to return a default root element + * here. + * + * @return the default root {@link Element} of this <code>Document</code> + */ public abstract Element getDefaultRootElement(); + /** + * Creates and returns a branch element with the specified + * <code>parent</code> and <code>attributes</code>. Note that the new + * <code>Element</code> is linked to the parent <code>Element</code> + * through {@link Element#getParentElement}, but it is not yet added + * to the parent <code>Element</code> as child. + * + * @param parent the parent <code>Element</code> for the new branch element + * @param attributes the text attributes to be installed in the new element + * + * @return the new branch <code>Element</code> + * + * @see {@link BranchElement} + */ protected Element createBranchElement(Element parent, AttributeSet attributes) { return new BranchElement(parent, attributes); } + /** + * Creates and returns a leaf element with the specified + * <code>parent</code> and <code>attributes</code>. Note that the new + * <code>Element</code> is linked to the parent <code>Element</code> + * through {@link Element#getParentElement}, but it is not yet added + * to the parent <code>Element</code> as child. + * + * @param parent the parent <code>Element</code> for the new branch element + * @param attributes the text attributes to be installed in the new element + * + * @return the new branch <code>Element</code> + * + * @see {@link LeafElement} + */ protected Element createLeafElement(Element parent, AttributeSet attributes, int start, int end) { return new LeafElement(parent, attributes, start, end); } + /** + * Creates a {@link Position} that keeps track of the location at the + * specified <code>offset</code>. + * + * @param offset the location in the document to keep track by the new + * <code>Position</code> + * + * @return the newly created <code>Position</code> + * + * @throws BadLocationException if <code>offset</code> is not a valid + * location in the documents content model + */ public Position createPosition(final int offset) throws BadLocationException { return content.createPosition(offset); } + /** + * Notifies all registered listeners when the document model changes. + * + * @param event the <code>DocumentEvent</code> to be fired + */ protected void fireChangedUpdate(DocumentEvent event) { DocumentListener[] listeners = getDocumentListeners(); @@ -119,6 +251,12 @@ public abstract class AbstractDocument listeners[index].changedUpdate(event); } + /** + * Notifies all registered listeners when content is inserted in the document + * model. + * + * @param event the <code>DocumentEvent</code> to be fired + */ protected void fireInsertUpdate(DocumentEvent event) { DocumentListener[] listeners = getDocumentListeners(); @@ -127,6 +265,12 @@ public abstract class AbstractDocument listeners[index].insertUpdate(event); } + /** + * Notifies all registered listeners when content is removed from the + * document model. + * + * @param event the <code>DocumentEvent</code> to be fired + */ protected void fireRemoveUpdate(DocumentEvent event) { DocumentListener[] listeners = getDocumentListeners(); @@ -135,6 +279,12 @@ public abstract class AbstractDocument listeners[index].removeUpdate(event); } + /** + * Notifies all registered listeners when an <code>UndoableEdit</code> has + * been performed on this <code>Document</code>. + * + * @param event the <code>UndoableEditEvent</code> to be fired + */ protected void fireUndoableEditUpdate(UndoableEditEvent event) { UndoableEditListener[] listeners = getUndoableEditListeners(); @@ -143,31 +293,70 @@ public abstract class AbstractDocument listeners[index].undoableEditHappened(event); } + /** + * Returns the asynchronous loading priority. Returns <code>-1</code> if this + * document should not be loaded asynchronously. + * + * @return the asynchronous loading priority + */ public int getAsynchronousLoadPriority() { return 0; } + /** + * Returns the {@link AttributeContext} used in this <code>Document</code>. + * + * @return the {@link AttributeContext} used in this <code>Document</code> + */ protected AttributeContext getAttributeContext() { return context; } + /** + * Returns the root element for bidirectional content. + * + * @return the root element for bidirectional content + */ public Element getBidiRootElement() { return null; } + /** + * Returns the {@link Content} model for this <code>Document</code> + * + * @return the {@link Content} model for this <code>Document</code> + * + * @see {@link GapContent} + * @see {@link StringContent} + */ protected Content getContent() { return content; } + /** + * Returns the thread that currently modifies this <code>Document</code> + * if there is one, otherwise <code>null</code>. This can be used to + * distinguish between a method call that is part of an ongoing modification + * or if it is a separate modification for which a new lock must be aquired. + * + * @return the thread that currently modifies this <code>Document</code> + * if there is one, otherwise <code>null</code> + */ protected Thread getCurrentWriter() { + // FIXME: Implement locking! return null; } + /** + * Returns the properties of this <code>Document</code>. + * + * @return the properties of this <code>Document</code> + */ public Dictionary getDocumentProperties() { // FIXME: make me thread-safe @@ -177,8 +366,16 @@ public abstract class AbstractDocument return properties; } + /** + * Returns a {@link Position} which will always mark the end of the + * <code>Document</code>. + * + * @return a {@link Position} which will always mark the end of the + * <code>Document</code> + */ public Position getEndPosition() { + // FIXME: Properly implement this by calling Content.createPosition(). return new Position() { public int getOffset() @@ -188,16 +385,39 @@ public abstract class AbstractDocument }; } + /** + * Returns the length of this <code>Document</code>'s content. + * + * @return the length of this <code>Document</code>'s content + */ public int getLength() { + // We return Content.getLength() -1 here because there is always an + // implicit \n at the end of the Content which does count in Content + // but not in Document. return content.length() - 1; } + /** + * Returns all registered listeners of a given listener type. + * + * @return the type of the listeners to be queried + * + * @return all registered listeners of the specified type + */ public EventListener[] getListeners(Class listenerType) { return listenerList.getListeners(listenerType); } + /** + * Returns a property from this <code>Document</code>'s property list. + * + * @param key the key of the property to be fetched + * + * @return the property for <code>key</code> or <code>null</code> if there + * is no such property stored + */ public Object getProperty(Object key) { // FIXME: make me thread-safe @@ -208,6 +428,15 @@ public abstract class AbstractDocument return value; } + /** + * Returns all root elements of this <code>Document</code>. By default + * this just returns the single root element returned by + * {@link #getDefaultRootElement()}. <code>Document</code> implementations + * that support multiple roots must override this method and return all roots + * here. + * + * @return all root elements of this <code>Document</code> + */ public Element[] getRootElements() { Element[] elements = new Element[1]; @@ -215,8 +444,16 @@ public abstract class AbstractDocument return elements; } + /** + * Returns a {@link Position} which will always mark the beginning of the + * <code>Document</code>. + * + * @return a {@link Position} which will always mark the beginning of the + * <code>Document</code> + */ public Position getStartPosition() { + // FIXME: Properly implement this using Content.createPosition(). return new Position() { public int getOffset() @@ -226,17 +463,53 @@ public abstract class AbstractDocument }; } + /** + * Returns a piece of this <code>Document</code>'s content. + * + * @param offset the start offset of the content + * @param length the length of the content + * + * @return the piece of content specified by <code>offset</code> and + * <code>length</code> + * + * @throws BadLocationException if <code>offset</code> or <code>offset + + * length</code> are invalid locations with this + * <code>Document</code> + */ public String getText(int offset, int length) throws BadLocationException { return content.getString(offset, length); } + /** + * Fetches a piece of this <code>Document</code>'s content and stores + * it in the given {@link Segment}. + * + * @param offset the start offset of the content + * @param length the length of the content + * @param segment the <code>Segment</code> to store the content in + * + * @throws BadLocationException if <code>offset</code> or <code>offset + + * length</code> are invalid locations with this + * <code>Document</code> + */ public void getText(int offset, int length, Segment segment) throws BadLocationException { content.getChars(offset, length, segment); } + /** + * Inserts a String into this <code>Document</code> at the specified + * position and assigning the specified attributes to it. + * + * @param offset the location at which the string should be inserted + * @param text the content to be inserted + * @param attributes the text attributes to be assigned to that string + * + * @throws BadLocationException if <code>offset</code> is not a valid + * location in this <code>Document</code> + */ public void insertString(int offset, String text, AttributeSet attributes) throws BadLocationException { @@ -252,14 +525,37 @@ public abstract class AbstractDocument fireInsertUpdate(event); } + /** + * Called to indicate that text has been inserted into this + * <code>Document</code>. The default implementation does nothing. + * This method is executed within a write lock. + * + * @param chng the <code>DefaultDocumentEvent</code> describing the change + * @param attr the attributes of the changed content + */ protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr) { + // Do nothing here. Subclasses may want to override this. } + /** + * Called after some content has been removed from this + * <code>Document</code>. The default implementation does nothing. + * This method is executed within a write lock. + * + * @param chng the <code>DefaultDocumentEvent</code> describing the change + */ protected void postRemoveUpdate(DefaultDocumentEvent chng) { + // Do nothing here. Subclasses may want to override this. } + /** + * Stores a property in this <code>Document</code>'s property list. + * + * @param key the key of the property to be stored + * @param value the value of the property to be stored + */ public void putProperty(Object key, Object value) { // FIXME: make me thread-safe @@ -269,14 +565,31 @@ public abstract class AbstractDocument properties.put(key, value); } + /** + * Blocks until a read lock can be obtained. + */ public void readLock() { } + /** + * Releases the read lock. If this was the only reader on this + * <code>Document</code>, writing may begin now. + */ public void readUnlock() { } + /** + * Removes a piece of content from this <code>Document</code>. + * + * @param offset the start offset of the fragment to be removed + * @param length the length of the fragment to be removed + * + * @throws BadLocationException if <code>offset</code> or + * <code>offset + length</code> or invalid locations within this + * document + */ public void remove(int offset, int length) throws BadLocationException { DefaultDocumentEvent event = @@ -289,7 +602,17 @@ public abstract class AbstractDocument } /** - * Replaces some text in the document. + * Replaces a piece of content in this <code>Document</code> with + * another piece of content. + * + * @param offset the start offset of the fragment to be removed + * @param length the length of the fragment to be removed + * @param text the text to replace the content with + * @param attributes the text attributes to assign to the new content + * + * @throws BadLocationException if <code>offset</code> or + * <code>offset + length</code> or invalid locations within this + * document * * @since 1.4 */ @@ -322,9 +645,9 @@ public abstract class AbstractDocument } /** - * Returns add added <code>DocumentListener</code> objects. + * Returns all registered <code>DocumentListener</code>s. * - * @return an array of listeners + * @return all registered <code>DocumentListener</code>s */ public DocumentListener[] getDocumentListeners() { @@ -332,7 +655,7 @@ public abstract class AbstractDocument } /** - * Adds a <code>UndoableEditListener</code> object to this document. + * Adds an {@link UndoableEditListener} to this <code>Document</code>. * * @param listener the listener to add */ @@ -342,7 +665,7 @@ public abstract class AbstractDocument } /** - * Removes a <code>UndoableEditListener</code> object from this document. + * Removes an {@link UndoableEditListener} from this <code>Document</code>. * * @param listener the listener to remove */ @@ -352,42 +675,93 @@ public abstract class AbstractDocument } /** - * Returns add added <code>UndoableEditListener</code> objects. + * Returns all registered {@link UndoableEditListener}s. * - * @return an array of listeners + * @return all registered {@link UndoableEditListener}s */ public UndoableEditListener[] getUndoableEditListeners() { return (UndoableEditListener[]) getListeners(UndoableEditListener.class); } + /** + * Called before some content gets removed from this <code>Document</code>. + * The default implementation does nothing but may be overridden by + * subclasses to modify the <code>Document</code> structure in response + * to a remove request. The method is executed within a write lock. + * + * @param chng the <code>DefaultDocumentEvent</code> describing the change + */ protected void removeUpdate(DefaultDocumentEvent chng) { + // Do nothing here. Subclasses may wish to override this. } - public void render(Runnable r) + /** + * Called to render this <code>Document</code> visually. It obtains a read + * lock, ensuring that no changes will be made to the <code>document</code> + * during the rendering process. It then calls the {@link Runnable#run()} + * method on <code>runnable</code>. This method <em>must not</em> attempt + * to modifiy the <code>Document</code>, since a deadlock will occur if it + * tries to obtain a write lock. When the {@link Runnable#run()} method + * completes (either naturally or by throwing an exception), the read lock + * is released. Note that there is nothing in this method related to + * the actual rendering. It could be used to execute arbitrary code within + * a read lock. + * + * @param runnable the {@link Runnable} to execute + */ + public void render(Runnable runnable) { + // FIXME: Implement me! } + /** + * Sets the asynchronous loading priority for this <code>Document</code>. + * A value of <code>-1</code> indicates that this <code>Document</code> + * should be loaded synchronously. + * + * @param p the asynchronous loading priority to set + */ public void setAsynchronousLoadPriority(int p) { } - public void setDocumentProperties(Dictionary x) + /** + * Sets the properties of this <code>Document</code>. + * + * @param p the document properties to set + */ + public void setDocumentProperties(Dictionary p) { // FIXME: make me thread-safe - properties = x; + properties = p; } + /** + * Blocks until a write lock can be obtained. + */ protected void writeLock() { + // FIXME: Implement me. } + /** + * Releases the write lock. This allows waiting readers or writers to + * obtain the lock. + */ protected void writeUnlock() { + // FIXME: Implement me. } /** + * Returns the currently installed {@link DocumentFilter} for this + * <code>Document</code>. + * + * @return the currently installed {@link DocumentFilter} for this + * <code>Document</code> + * * @since 1.4 */ public DocumentFilter getDocumentFilter() @@ -396,6 +770,10 @@ public abstract class AbstractDocument } /** + * Sets the {@link DocumentFilter} for this <code>Document</code>. + * + * @param filter the <code>DocumentFilter</code> to set + * * @since 1.4 */ public void setDocumentFilter(DocumentFilter filter) @@ -403,207 +781,590 @@ public abstract class AbstractDocument this.documentFilter = filter; } + /** + * Dumps diagnostic information to the specified <code>PrintStream</code>. + * + * @param out the stream to write the diagnostic information to + */ public void dump(PrintStream out) { ((AbstractElement) getDefaultRootElement()).dump(out, 0); } + /** + * Defines a set of methods for managing text attributes for one or more + * <code>Document</code>s. + * + * Replicating {@link AttributeSet}s throughout a <code>Document</code> can + * be very expensive. Implementations of this interface are intended to + * provide intelligent management of <code>AttributeSet</code>s, eliminating + * costly duplication. + * + * @see {@link StyleContext} + */ public interface AttributeContext { + /** + * Returns an {@link AttributeSet} that contains the attributes + * of <code>old</code> plus the new attribute specified by + * <code>name</code> and <code>value</code>. + * + * @param old the attribute set to be merged with the new attribute + * @param name the name of the attribute to be added + * @param value the value of the attribute to be added + * + * @return the old attributes plus the new attribute + */ AttributeSet addAttribute(AttributeSet old, Object name, Object value); + /** + * Returns an {@link AttributeSet} that contains the attributes + * of <code>old</code> plus the new attributes in <code>attributes</code>. + * + * @param old the set of attributes where to add the new attributes + * @param attributes the attributes to be added + * + * @return an {@link AttributeSet} that contains the attributes + * of <code>old</code> plus the new attributes in + * <code>attributes</code> + */ AttributeSet addAttributes(AttributeSet old, AttributeSet attributes); + /** + * Returns an empty {@link AttributeSet}. + * + * @return an empty {@link AttributeSet} + */ AttributeSet getEmptySet(); + /** + * Called to indicate that the attributes in <code>attributes</code> are + * no longer used. + * + * @param attributes the attributes are no longer used + */ void reclaim(AttributeSet attributes); + /** + * Returns a {@link AttributeSet} that has the attribute with the specified + * <code>name</code> removed from <code>old</code>. + * + * @param old the attribute set from which an attribute is removed + * @param name the name of the attribute to be removed + * + * @return the attributes of <code>old</code> minus the attribute + * specified by <code>name</code> + */ AttributeSet removeAttribute(AttributeSet old, Object name); + /** + * Removes all attributes in <code>attributes</code> from <code>old</code> + * and returns the resulting <code>AttributeSet</code>. + * + * @param old the set of attributes from which to remove attributes + * @param attributes the attributes to be removed from <code>old</code> + * + * @return the attributes of <code>old</code> minus the attributes in + * <code>attributes</code> + */ AttributeSet removeAttributes(AttributeSet old, AttributeSet attributes); + /** + * Removes all attributes specified by <code>names</code> from + * <code>old</code> and returns the resulting <code>AttributeSet</code>. + * + * @param old the set of attributes from which to remove attributes + * @param names the names of the attributes to be removed from + * <code>old</code> + * + * @return the attributes of <code>old</code> minus the attributes in + * <code>attributes</code> + */ AttributeSet removeAttributes(AttributeSet old, Enumeration names); } + /** + * A sequence of data that can be edited. This is were the actual content + * in <code>AbstractDocument</code>'s is stored. + */ public interface Content { + /** + * Creates a {@link Position} that keeps track of the location at + * <code>offset</code>. + * + * @return a {@link Position} that keeps track of the location at + * <code>offset</code>. + * + * @throw BadLocationException if <code>offset</code> is not a valid + * location in this <code>Content</code> model + */ Position createPosition(int offset) throws BadLocationException; + /** + * Returns the length of the content. + * + * @return the length of the content + */ int length(); + /** + * Inserts a string into the content model. + * + * @param where the offset at which to insert the string + * @param str the string to be inserted + * + * @return an <code>UndoableEdit</code> or <code>null</code> if undo is + * not supported by this <code>Content</code> model + * + * @throws BadLocationException if <code>where</code> is not a valid + * location in this <code>Content</code> model + */ UndoableEdit insertString(int where, String str) throws BadLocationException; + /** + * Removes a piece of content from the content model. + * + * @param where the offset at which to remove content + * @param nitems the number of characters to be removed + * + * @return an <code>UndoableEdit</code> or <code>null</code> if undo is + * not supported by this <code>Content</code> model + * + * @throws BadLocationException if <code>where</code> is not a valid + * location in this <code>Content</code> model + */ UndoableEdit remove(int where, int nitems) throws BadLocationException; + /** + * Returns a piece of content. + * + * @param where the start offset of the requested fragment + * @param len the length of the requested fragment + * + * @return the requested fragment + * @throws BadLocationException if <code>offset</code> or + * <code>offset + len</code>is not a valid + * location in this <code>Content</code> model + */ String getString(int where, int len) throws BadLocationException; + /** + * Fetches a piece of content and stores it in <code>txt</code>. + * + * @param where the start offset of the requested fragment + * @param len the length of the requested fragment + * @param txt the <code>Segment</code> where to fragment is stored into + * + * @throws BadLocationException if <code>offset</code> or + * <code>offset + len</code>is not a valid + * location in this <code>Content</code> model + */ void getChars(int where, int len, Segment txt) throws BadLocationException; } + /** + * An abstract base implementation of the {@link Element} interface. + */ public abstract class AbstractElement implements Element, MutableAttributeSet, TreeNode, Serializable { + /** The serial version UID for AbstractElement. */ private static final long serialVersionUID = 1265312733007397733L; + + /** The number of characters that this Element spans. */ int count; + + /** The starting offset of this Element. */ int offset; + /** The attributes of this Element. */ AttributeSet attributes; + /** The parent element. */ Element element_parent; + /** The parent in the TreeNode interface. */ TreeNode tree_parent; + + /** The children of this element. */ Vector tree_children; + /** + * Creates a new instance of <code>AbstractElement</code> with a + * specified parent <code>Element</code> and <code>AttributeSet</code>. + * + * @param p the parent of this <code>AbstractElement</code> + * @param s the attributes to be assigned to this + * <code>AbstractElement</code> + */ public AbstractElement(Element p, AttributeSet s) { element_parent = p; - attributes = s; + AttributeContext ctx = getAttributeContext(); + attributes = ctx.getEmptySet(); + if (s != null) + attributes = ctx.addAttributes(attributes, s); } - // TreeNode implementation - + /** + * Returns the child nodes of this <code>Element</code> as an + * <code>Enumeration</code> of {@link TreeNode}s. + * + * @return the child nodes of this <code>Element</code> as an + * <code>Enumeration</code> of {@link TreeNode}s + */ public abstract Enumeration children(); - + + /** + * Returns <code>true</code> if this <code>AbstractElement</code> + * allows children. + * + * @return <code>true</code> if this <code>AbstractElement</code> + * allows children + */ public abstract boolean getAllowsChildren(); - + + /** + * Returns the child of this <code>AbstractElement</code> at + * <code>index</code>. + * + * @param index the position in the child list of the child element to + * be returned + * + * @return the child of this <code>AbstractElement</code> at + * <code>index</code> + */ public TreeNode getChildAt(int index) { return (TreeNode) tree_children.get(index); } - + + /** + * Returns the number of children of this <code>AbstractElement</code>. + * + * @return the number of children of this <code>AbstractElement</code> + */ public int getChildCount() { return tree_children.size(); } - + + /** + * Returns the index of a given child <code>TreeNode</code> or + * <code>-1</code> if <code>node</code> is not a child of this + * <code>AbstractElement</code>. + * + * @param node the node for which the index is requested + * + * @return the index of a given child <code>TreeNode</code> or + * <code>-1</code> if <code>node</code> is not a child of this + * <code>AbstractElement</code> + */ public int getIndex(TreeNode node) { return tree_children.indexOf(node); } + /** + * Returns the parent <code>TreeNode</code> of this + * <code>AbstractElement</code> or <code>null</code> if this element + * has no parent. + * + * @return the parent <code>TreeNode</code> of this + * <code>AbstractElement</code> or <code>null</code> if this + * element has no parent + */ public TreeNode getParent() { return tree_parent; } + /** + * Returns <code>true</code> if this <code>AbstractElement</code> is a + * leaf element, <code>false</code> otherwise. + * + * @return <code>true</code> if this <code>AbstractElement</code> is a + * leaf element, <code>false</code> otherwise + */ public abstract boolean isLeaf(); - - // MutableAttributeSet support - + /** + * Adds an attribute to this element. + * + * @param name the name of the attribute to be added + * @param value the value of the attribute to be added + */ public void addAttribute(Object name, Object value) { attributes = getAttributeContext().addAttribute(attributes, name, value); } + /** + * Adds a set of attributes to this element. + * + * @param attrs the attributes to be added to this element + */ public void addAttributes(AttributeSet attrs) { attributes = getAttributeContext().addAttributes(attributes, attrs); } + /** + * Removes an attribute from this element. + * + * @param name the name of the attribute to be removed + */ public void removeAttribute(Object name) { attributes = getAttributeContext().removeAttribute(attributes, name); } + /** + * Removes a set of attributes from this element. + * + * @param attrs the attributes to be removed + */ public void removeAttributes(AttributeSet attrs) { attributes = getAttributeContext().removeAttributes(attributes, attrs); } + /** + * Removes a set of attribute from this element. + * + * @param the names of the attributes to be removed + */ public void removeAttributes(Enumeration names) { attributes = getAttributeContext().removeAttributes(attributes, names); } + /** + * Sets the parent attribute set against which the element can resolve + * attributes that are not defined in itself. + * + * @param parent the resolve parent to set + */ public void setResolveParent(AttributeSet parent) { - attributes = getAttributeContext().addAttribute(attributes, ResolveAttribute, parent); + attributes = getAttributeContext().addAttribute(attributes, + ResolveAttribute, + parent); } - - // AttributeSet interface support - + /** + * Returns <code>true</code> if this element contains the specified + * attribute. + * + * @param name the name of the attribute to check + * @param value the value of the attribute to check + * + * @return <code>true</code> if this element contains the specified + * attribute + */ public boolean containsAttribute(Object name, Object value) { return attributes.containsAttribute(name, value); } + /** + * Returns <code>true</code> if this element contains all of the + * specified attributes. + * + * @param attrs the attributes to check + * + * @return <code>true</code> if this element contains all of the + * specified attributes + */ public boolean containsAttributes(AttributeSet attrs) { return attributes.containsAttributes(attrs); } + /** + * Returns a copy of the attributes of this element. + * + * @return a copy of the attributes of this element + */ public AttributeSet copyAttributes() { return attributes.copyAttributes(); } + /** + * Returns the attribute value with the specified key. If this attribute + * is not defined in this element and this element has a resolving + * parent, the search goes upward to the resolve parent chain. + * + * @param key the key of the requested attribute + * + * @return the attribute value for <code>key</code> of <code>null</code> + * if <code>key</code> is not found locally and cannot be resolved + * in this element's resolve parents + */ public Object getAttribute(Object key) { return attributes.getAttribute(key); } + /** + * Returns the number of defined attributes in this element. + * + * @return the number of defined attributes in this element + */ public int getAttributeCount() { return attributes.getAttributeCount(); } - + + /** + * Returns the names of the attributes of this element. + * + * @return the names of the attributes of this element + */ public Enumeration getAttributeNames() { return attributes.getAttributeNames(); } - + + /** + * Returns the resolve parent of this element. + * + * @return the resolve parent of this element + * + * @see {@link #setResolveParent(AttributeSet)} + */ public AttributeSet getResolveParent() { return attributes.getResolveParent(); } + /** + * Returns <code>true</code> if an attribute with the specified name + * is defined in this element, <code>false</code> otherwise. + * + * @param attrName the name of the requested attributes + * + * @return <code>true</code> if an attribute with the specified name + * is defined in this element, <code>false</code> otherwise + */ public boolean isDefined(Object attrName) { return attributes.isDefined(attrName); } - + + /** + * Returns <code>true</code> if the specified <code>AttributeSet</code> + * is equal to this element's <code>AttributeSet</code>, <code>false</code> + * otherwise. + * + * @param attrs the attributes to compare this element to + * + * @return <code>true</code> if the specified <code>AttributeSet</code> + * is equal to this element's <code>AttributeSet</code>, + * <code>false</code> otherwise + */ public boolean isEqual(AttributeSet attrs) { return attributes.isEqual(attrs); } - // Element interface support - + /** + * Returns the attributes of this element. + * + * @return the attributes of this element + */ public AttributeSet getAttributes() { - return attributes; + return this; } + /** + * Returns the {@link Document} to which this element belongs. + * + * @return the {@link Document} to which this element belongs + */ public Document getDocument() { return AbstractDocument.this; } - + + /** + * Returns the child element at the specified <code>index</code>. + * + * @param index the index of the requested child element + * + * @return the requested element + */ public abstract Element getElement(int index); - + + /** + * Returns the name of this element. + * + * @return the name of this element + */ public String getName() { return (String) getAttribute(NameAttribute); } - + + /** + * Returns the parent element of this element. + * + * @return the parent element of this element + */ public Element getParentElement() { return element_parent; } - + + /** + * Returns the offset inside the document model that is after the last + * character of this element. + * + * @return the offset inside the document model that is after the last + * character of this element + */ public abstract int getEndOffset(); - + + /** + * Returns the number of child elements of this element. + * + * @return the number of child elements of this element + */ public abstract int getElementCount(); - + + /** + * Returns the index of the child element that spans the specified + * offset in the document model. + * + * @param offset the offset for which the responsible element is searched + * + * @return the index of the child element that spans the specified + * offset in the document model + */ public abstract int getElementIndex(int offset); - + + /** + * Returns the start offset if this element inside the document model. + * + * @return the start offset if this element inside the document model + */ public abstract int getStartOffset(); - private void dumpElement(PrintStream stream, String indent, Element element) + /** + * Prints diagnostic information to the specified stream. + * + * @param stream the stream to dump to + * @param indent the indentation level + * @param element the element to be dumped + */ + private void dumpElement(PrintStream stream, String indent, + Element element) { + // FIXME: Should the method be removed? System.out.println(indent + "<" + element.getName() +">"); if (element.isLeaf()) @@ -629,7 +1390,13 @@ public abstract class AbstractDocument dumpElement(stream, indent + " ", element.getElement(i)); } } - + + /** + * Prints diagnostic output to the specified stream. + * + * @param stream the stream to write to + * @param indent the indentation level + */ public void dump(PrintStream stream, int indent) { String indentStr = ""; @@ -639,17 +1406,36 @@ public abstract class AbstractDocument } } + /** + * An implementation of {@link Element} to represent composite + * <code>Element</code>s that contain other <code>Element</code>s. + */ public class BranchElement extends AbstractElement { + /** The serial version UID for BranchElement. */ private static final long serialVersionUID = -8595176318868717313L; - + + /** The child elements of this BranchElement. */ private Element[] children = new Element[0]; + /** + * Creates a new <code>BranchElement</code> with the specified + * parent and attributes. + * + * @param parent the parent element of this <code>BranchElement</code> + * @param attributes the attributes to set on this + * <code>BranchElement</code> + */ public BranchElement(Element parent, AttributeSet attributes) { super(parent, attributes); } + /** + * Returns the children of this <code>BranchElement</code>. + * + * @return the children of this <code>BranchElement</code> + */ public Enumeration children() { if (children.length == 0) @@ -663,11 +1449,25 @@ public abstract class AbstractDocument return tmp.elements(); } + /** + * Returns <code>true</code> since <code>BranchElements</code> allow + * child elements. + * + * @return <code>true</code> since <code>BranchElements</code> allow + * child elements + */ public boolean getAllowsChildren() { return true; } + /** + * Returns the child element at the specified <code>index</code>. + * + * @param index the index of the requested child element + * + * @return the requested element + */ public Element getElement(int index) { if (index < 0 || index >= children.length) @@ -676,11 +1476,25 @@ public abstract class AbstractDocument return children[index]; } + /** + * Returns the number of child elements of this element. + * + * @return the number of child elements of this element + */ public int getElementCount() { return children.length; } + /** + * Returns the index of the child element that spans the specified + * offset in the document model. + * + * @param offset the offset for which the responsible element is searched + * + * @return the index of the child element that spans the specified + * offset in the document model + */ public int getElementIndex(int offset) { // XXX: There is surely a better algorithm @@ -697,26 +1511,60 @@ public abstract class AbstractDocument return 0; } + /** + * Returns the offset inside the document model that is after the last + * character of this element. + * + * @return the offset inside the document model that is after the last + * character of this element + */ public int getEndOffset() { return children[children.length - 1].getEndOffset(); } + /** + * Returns the name of this element. This is {@link #ParagraphElementName} + * in this case. + * + * @return the name of this element + */ public String getName() { return ParagraphElementName; } + /** + * Returns the start offset if this element inside the document model. + * + * @return the start offset if this element inside the document model + */ public int getStartOffset() { return children[0].getStartOffset(); } + /** + * Returns <code>false</code> since <code>BranchElement</code> are no + * leafes. + * + * @return <code>false</code> since <code>BranchElement</code> are no + * leafes + */ public boolean isLeaf() { return false; } + /** + * Returns the <code>Element</code> at the specified <code>Document</code> + * offset. + * + * @return the <code>Element</code> at the specified <code>Document</code> + * offset + * + * @see {@link #getElementIndex(int)} + */ public Element positionToElement(int position) { // XXX: There is surely a better algorithm @@ -733,6 +1581,13 @@ public abstract class AbstractDocument return null; } + /** + * Replaces a set of child elements with a new set of child elemens. + * + * @param offset the start index of the elements to be removed + * @param length the number of elements to be removed + * @param elements the new elements to be inserted + */ public void replace(int offset, int length, Element[] elements) { Element[] target = new Element[children.length - length @@ -745,6 +1600,11 @@ public abstract class AbstractDocument children = target; } + /** + * Returns a string representation of this element. + * + * @return a string representation of this element + */ public String toString() { return ("BranchElement(" + getName() + ") " @@ -752,15 +1612,31 @@ public abstract class AbstractDocument } } + /** + * Stores the changes when a <code>Document</code> is beeing modified. + */ public class DefaultDocumentEvent extends CompoundEdit implements DocumentEvent { + /** The serial version UID of DefaultDocumentEvent. */ private static final long serialVersionUID = -7406103236022413522L; - + + /** The starting offset of the change. */ private int offset; + + /** The length of the change. */ private int length; + + /** The type of change. */ private DocumentEvent.EventType type; + /** + * Creates a new <code>DefaultDocumentEvent</code>. + * + * @param offset the starting offset of the change + * @param length the length of the change + * @param type the type of change + */ public DefaultDocumentEvent(int offset, int length, DocumentEvent.EventType type) { @@ -769,42 +1645,98 @@ public abstract class AbstractDocument this.type = type; } + /** + * Returns the document that has been modified. + * + * @return the document that has been modified + */ public Document getDocument() { return AbstractDocument.this; } + /** + * Returns the length of the modification. + * + * @return the length of the modification + */ public int getLength() { return length; } + /** + * Returns the start offset of the modification. + * + * @return the start offset of the modification + */ public int getOffset() { return offset; } + /** + * Returns the type of the modification. + * + * @return the type of the modification + */ public DocumentEvent.EventType getType() { return type; } + /** + * Returns the changes for an element. + * + * @param elem the element for which the changes are requested + * + * @return the changes for <code>elem</code> or <code>null</code> if + * <code>elem</code> has not been changed + */ public DocumentEvent.ElementChange getChange(Element elem) { return null; } } + /** + * An implementation of {@link DocumentEvent.ElementChange} to be added + * to {@link DefaultDocumentEvent}s. + */ public static class ElementEdit extends AbstractUndoableEdit implements DocumentEvent.ElementChange { + /** The serial version UID of ElementEdit. */ private static final long serialVersionUID = -1216620962142928304L; + /** + * The changed element. + */ private Element elem; + + /** + * The index of the change. + */ private int index; + + /** + * The removed elements. + */ private Element[] removed; + + /** + * The added elements. + */ private Element[] added; + /** + * Creates a new <code>ElementEdit</code>. + * + * @param elem the changed element + * @param index the index of the change + * @param removed the removed elements + * @param added the added elements + */ public ElementEdit(Element elem, int index, Element[] removed, Element[] added) { @@ -814,29 +1746,54 @@ public abstract class AbstractDocument this.added = added; } + /** + * Returns the added elements. + * + * @return the added elements + */ public Element[] getChildrenAdded() { return added; } - + + /** + * Returns the removed elements. + * + * @return the removed elements + */ public Element[] getChildrenRemoved() { return removed; } + /** + * Returns the changed element. + * + * @return the changed element + */ public Element getElement() { return elem; } + /** + * Returns the index of the change. + * + * @return the index of the change + */ public int getIndex() { return index; } } + /** + * An implementation of {@link Element} that represents a leaf in the + * document structure. This is used to actually store content. + */ public class LeafElement extends AbstractElement { + /** The serial version UID of LeafElement. */ private static final long serialVersionUID = 5115368706941283802L; /** Manages the start offset of this element. */ @@ -845,6 +1802,14 @@ public abstract class AbstractDocument /** Manages the end offset of this element. */ Position endPos; + /** + * Creates a new <code>LeafElement</code>. + * + * @param parent the parent of this <code>LeafElement</code> + * @param attributes the attributes to be set + * @param start the start index of this element inside the document model + * @param end the end index of this element inside the document model + */ public LeafElement(Element parent, AttributeSet attributes, int start, int end) { @@ -862,51 +1827,116 @@ public abstract class AbstractDocument } } + /** + * Returns <code>null</code> since <code>LeafElement</code>s cannot have + * children. + * + * @return <code>null</code> since <code>LeafElement</code>s cannot have + * children + */ public Enumeration children() { return null; } + /** + * Returns <code>false</code> since <code>LeafElement</code>s cannot have + * children. + * + * @return <code>false</code> since <code>LeafElement</code>s cannot have + * children + */ public boolean getAllowsChildren() { return false; } + /** + * Returns <code>null</code> since <code>LeafElement</code>s cannot have + * children. + * + * @return <code>null</code> since <code>LeafElement</code>s cannot have + * children + */ public Element getElement(int index) { return null; } + /** + * Returns <code>0</code> since <code>LeafElement</code>s cannot have + * children. + * + * @return <code>0</code> since <code>LeafElement</code>s cannot have + * children + */ public int getElementCount() { return 0; } + /** + * Returns <code>-1</code> since <code>LeafElement</code>s cannot have + * children. + * + * @return <code>-1</code> since <code>LeafElement</code>s cannot have + * children + */ public int getElementIndex(int offset) { return -1; } + /** + * Returns the end offset of this <code>Element</code> inside the + * document. + * + * @return the end offset of this <code>Element</code> inside the + * document + */ public int getEndOffset() { return endPos.getOffset(); } + /** + * Returns the name of this <code>Element</code>. This is + * {@link #ContentElementName} in this case. + * + * @return the name of this <code>Element</code> + */ public String getName() { return ContentElementName; } + /** + * Returns the start offset of this <code>Element</code> inside the + * document. + * + * @return the start offset of this <code>Element</code> inside the + * document + */ public int getStartOffset() { return startPos.getOffset(); } + /** + * Returns <code>true</code>. + * + * @return <code>true</code> + */ public boolean isLeaf() { return true; } + /** + * Returns a string representation of this <code>Element</code>. + * + * @return a string representation of this <code>Element</code> + */ public String toString() { return ("LeafElement(" + getName() + ") " diff --git a/javax/swing/text/AttributeSet.java b/javax/swing/text/AttributeSet.java index 87e7b98af..2f1f1890b 100644 --- a/javax/swing/text/AttributeSet.java +++ b/javax/swing/text/AttributeSet.java @@ -1,5 +1,5 @@ /* AttributeSet.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. @@ -39,34 +39,153 @@ package javax.swing.text; import java.util.Enumeration; +/** + * A set of attributes. An attribute has a key and a value. They typically + * describe features of a piece of text that make up its graphical + * representation. + * + * An <code>AttributeSet</code> may have a resolving parent, + * that is another <code>AttributeSet</code> that is searched for attribute + * keys that are not stored locally in this <code>AttributeSet</code>. + * + * @author original author unknown + * @author Roman Kennke (roman@kennke.org) + */ public interface AttributeSet { + /** + * Used as keys to identify character-run attributes. + */ static interface CharacterAttribute { } + /** + * Used as keys to identify color attributes. + */ static interface ColorAttribute { } + /** + * Used as keys to identify font attributes. + */ static interface FontAttribute { } + /** + * Used as keys to identify paragraph level attributes. + */ static interface ParagraphAttribute { } + /** + * Key of the attribute that is used to describe the name of an + * <code>AttributeSet</code>. + */ Object NameAttribute = StyleConstants.NameAttribute; + + /** + * Key of the attribute that is used to identify the resolving parent of + * an <code>AttributeSet</code>. + */ Object ResolveAttribute = StyleConstants.ResolveAttribute; + /** + * Returns <code>true</code> if this <code>AttributeSet</code> contains + * an attribute with the specified <code>name</code> and <code>value</code>, + * <code>false</code> otherwise. + * + * @param name the name of the requested attribute + * @param 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 + * <code>value</code>, <code>false</code> otherwise + */ boolean containsAttribute(Object name, Object value); + + /** + * Returns <code>true</code> of this <code>AttributeSet</code> contains all + * of the specified <code>attributes</code>. + * + * @param attributes the requested attributes + * + * @return <code>true</code> of this <code>AttributeSet</code> contains all + * of the specified <code>attributes</code> + */ boolean containsAttributes(AttributeSet attributes); + + /** + * Creates and returns a copy of this <code>AttributeSet</code>. + * + * @return a copy of this <code>AttributeSet</code> + */ AttributeSet copyAttributes(); + + /** + * Returns the attribute with the specified <code>key</code> or + * <code>null</code> if no such attribute is defined in this + * <code>AttributeSet</code> and its resolving parents. + * + * @param key the key of the attribute that is looked up + * + * @return the attribute with the specified <code>key</code> or + * <code>null</code> if no such attribute is defined in this + * <code>AttributeSet</code> and its resolving parents + */ Object getAttribute(Object key); + + /** + * Returns the number of attributes that are stored locally in this + * <code>AttributeSet</code>. + * + * @return the number of attributes that are stored locally in this + * <code>AttributeSet</code> + */ int getAttributeCount(); + + /** + * Returns the names of the attributes that are stored in this + * <code>AttributeSet</code>. + * + * @return the names of the attributes that are stored in this + * <code>AttributeSet</code> + */ Enumeration getAttributeNames(); + + /** + * Returns the resolving parent of this <code>AttributeSet</code>. + * If a key is not stored locally, then a {@link #getAttribute(Object)} + * request is resolved up in the resolving parent of this + * <code>AttributeSet</code>. + * + * @return the resolving parent of this <code>AttributeSet</code> + */ AttributeSet getResolveParent(); + + /** + * Returns <code>true</code> if an attribute with the specified name is + * defined locally in this <code>AttributeSet</code>, without resolving + * through the resolving parents. + * + * @return <code>true</code> if an attribute with the specified name is + * defined locally in this <code>AttributeSet</code> + */ boolean isDefined(Object attrName); + + /** + * Returns <code>true</code> if all of the attributes in <code>attr</code> + * are equal to the attributes in this <code>AttributeSet</code>, + * <code>false</code> otherwise. + * + * @param attr the attributes to be compared to <code>this</code> + * + * @return <code>true</code> if all of the attributes in <code>attr</code> + * are equal to the attributes in this <code>AttributeSet</code>, + * <code>false</code> otherwise + */ boolean isEqual(AttributeSet attr); } diff --git a/javax/swing/text/BadLocationException.java b/javax/swing/text/BadLocationException.java index e1a2ebcc6..70591402c 100644 --- a/javax/swing/text/BadLocationException.java +++ b/javax/swing/text/BadLocationException.java @@ -1,5 +1,5 @@ /* BadLocationException.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. @@ -37,17 +37,28 @@ exception statement from your version. */ package javax.swing.text; +/** + * Indicates that an invalid location within a <code>Document</code> has been + * accessed. + * + * @author original author unknown + * @author Roman Kennke (roman@kennke.org) + */ public class BadLocationException extends Exception { + /** The serial version UID for BadLocationException. */ private static final long serialVersionUID = -7712259886815656766L; - + + /** + * The invalid location. + */ int offset; /** * Constructs a <code>BadLocationException</code> * - * @param str A string indicating what was wrong with the arguments - * @param offset Offset within the document that was requested >= 0 + * @param str a string indicating what was wrong with the arguments + * @param offset offset within the document that was requested >= 0 */ public BadLocationException(String str, int offset) { @@ -56,7 +67,9 @@ public class BadLocationException extends Exception } /** - * Returns the offset into the document that was not legal + * Returns the offset into the document that was not legal. + * + * @return the offset into the document that was not legal */ public int offsetRequested() { diff --git a/javax/swing/text/BoxView.java b/javax/swing/text/BoxView.java index 79a3123bf..3088515ed 100644 --- a/javax/swing/text/BoxView.java +++ b/javax/swing/text/BoxView.java @@ -39,6 +39,7 @@ exception statement from your version. */ package javax.swing.text; import java.awt.Graphics; +import java.awt.Rectangle; import java.awt.Shape; // TODO: Implement this class. @@ -84,4 +85,71 @@ public class BoxView // TODO: Implement me. return 0F; } + + /** + * Returns <code>true</code> if the specified point lies before the + * given <code>Rectangle</code>, <code>false</code> otherwise. + * + * "Before" is typically defined as being to the left or above. + * + * @param x the X coordinate of the point + * @param y the Y coordinate of the point + * @param r the rectangle to test the point against + * + * @return <code>true</code> if the specified point lies before the + * given <code>Rectangle</code>, <code>false</code> otherwise + */ + protected boolean isBefore(int x, int y, Rectangle r) + { + // TODO: Implement this properly. + return false; + } + + /** + * Returns <code>true</code> if the specified point lies after the + * given <code>Rectangle</code>, <code>false</code> otherwise. + * + * "After" is typically defined as being to the right or below. + * + * @param x the X coordinate of the point + * @param y the Y coordinate of the point + * @param r the rectangle to test the point against + * + * @return <code>true</code> if the specified point lies after the + * given <code>Rectangle</code>, <code>false</code> otherwise + */ + protected boolean isAfter(int x, int y, Rectangle r) + { + // TODO: Implement this properly. + return false; + } + + /** + * Returns the child <code>View</code> at the specified location. + * + * @param x the X coordinate + * @param y the Y coordinate + * @param r the allocation of this <code>CompositeView</code> + * + * @return the child <code>View</code> at the specified location + */ + protected View getViewAtPoint(int x, int y, Rectangle r) + { + // TODO: Implement this properly. + return null; + } + + /** + * Computes the allocation for a child <code>View</code>. The parameter + * <code>a</code> stores the allocation of this <code>CompositeView</code> + * and is then adjusted to hold the allocation of the child view. + * + * @param index the index of the child <code>View</code> + * @param a the allocation of this <code>CompositeView</code> before the + * call, the allocation of the child on exit + */ + protected void childAllocation(int index, Rectangle a) + { + // TODO: Implement this properly. + } } diff --git a/javax/swing/text/Caret.java b/javax/swing/text/Caret.java index 46072ef19..f60293138 100644 --- a/javax/swing/text/Caret.java +++ b/javax/swing/text/Caret.java @@ -1,5 +1,5 @@ /* Caret.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,39 +43,165 @@ import java.awt.Point; import javax.swing.event.ChangeListener; +/** + * Defines the method to be implemented by a caret that can be used in Swing + * text components. + * + * @author original author unknown + * @author Roman Kennke (roman@kennke.org) + */ public interface Caret { + /** + * Registers a {@link ChangeListener} that is notified whenever that state + * of this <code>Caret</code> changes. + * + * @param l the listener to register to this caret + */ void addChangeListener(ChangeListener l); + + /** + * Removes a {@link ChangeListener} from the list of registered listeners. + * + * @param l the listener to remove + */ + void removeChangeListener(ChangeListener l); + + /** + * Installs this <code>Caret</code> on the specified text component. This + * usually involves setting up listeners. + * + * This method is called by {@link JTextComponent#setCaret(Caret)} after + * this caret has been set on the text component. + * + * @param c the text component to install this caret to + */ + void install(JTextComponent c); + /** + * Deinstalls this <code>Caret</code> from the specified text component. + * This usually involves removing listeners from the text component. + * + * This method is called by {@link JTextComponent#setCaret(Caret)} before + * this caret is removed from the text component. + * + * @param c the text component to deinstall this caret from + */ void deinstall(JTextComponent c); - + + /** + * Returns the blink rate of this <code>Caret</code> in milliseconds. + * A value of <code>0</code> means that the caret does not blink. + * + * @return the blink rate of this <code>Caret</code> or <code>0</code> if + * this caret does not blink + */ int getBlinkRate(); + + /** + * Sets the blink rate of this <code>Caret</code> in milliseconds. + * A value of <code>0</code> means that the caret does not blink. + * + * @param rate the new blink rate to set + */ + void setBlinkRate(int rate); + /** + * Returns the current position of this <code>Caret</code> within the + * <code>Document</code>. + * + * @return the current position of this <code>Caret</code> within the + * <code>Document</code> + */ int getDot(); + + /** + * Sets the current position of this <code>Caret</code> within the + * <code>Document</code>. This also sets the <code>mark</code> to the + * new location. + * + * @param dot the new position to be set + * + * @see {@link #moveDot(int)} + */ + void setDot(int dot); - Point getMagicCaretPosition(); - - int getMark(); - - void install(JTextComponent c); - - boolean isSelectionVisible(); - - boolean isVisible(); - + /** + * Moves the <code>dot</code> location without touching the + * <code>mark</code>. This is used when making a selection. + * + * @param dot the location where to move the dot + * + * @see {@link #setDot(int)} + */ void moveDot(int dot); - void paint(Graphics g); - - void removeChangeListener(ChangeListener l); - - void setBlinkRate(int rate); - - void setDot(int dot); + /** + * Returns the current position of the <code>mark</code>. The + * <code>mark</code> marks the location in the <code>Document</code> that + * is the end of a selection. If there is no selection, the <code>mark</code> + * is the same as the <code>dot</code>. + * + * @return the current position of the mark + */ + int getMark(); + /** + * Returns the current visual position of this <code>Caret</code>. + * + * @return the current visual position of this <code>Caret</code> + * + * @see {@link #setMagicCaretPosition} + */ + Point getMagicCaretPosition(); + + /** + * Sets the current visual position of this <code>Caret</code>. + * + * @param p the Point to use for the saved location. May be <code>null</code> + * to indicate that there is no visual location + */ void setMagicCaretPosition(Point p); - + + /** + * Returns <code>true</code> if the selection is currently visible, + * <code>false</code> otherwise. + * + * @return <code>true</code> if the selection is currently visible, + * <code>false</code> otherwise + */ + boolean isSelectionVisible(); + + /** + * Sets the visiblity state of the selection. + * + * @param v <code>true</code> if the selection should be visible, + * <code>false</code> otherwise + */ void setSelectionVisible(boolean v); - + + /** + * Returns <code>true</code> if this <code>Caret</code> is currently visible, + * and <code>false</code> if it is not. + * + * @return <code>true</code> if this <code>Caret</code> is currently visible, + * and <code>false</code> if it is not + */ + boolean isVisible(); + + /** + * Sets the visibility state of the caret. <code>true</code> shows the + * <code>Caret</code>, <code>false</code> hides it. + * + * @param v the visibility to set + */ void setVisible(boolean v); + + /** + * Paints this <code>Caret</code> to the specified <code>Graphics</code> + * context. + * + * @param g the graphics context to render to + */ + void paint(Graphics g); } diff --git a/javax/swing/text/ComponentView.java b/javax/swing/text/ComponentView.java index 744d537ae..f6feda215 100644 --- a/javax/swing/text/ComponentView.java +++ b/javax/swing/text/ComponentView.java @@ -100,4 +100,22 @@ public class ComponentView extends View { return 0; } + + /** + * Maps coordinates from the <code>View</code>'s space into a position + * in the document model. + * + * @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> + * @param b the bias to use + * + * @return the position in the document that corresponds to the screen + * coordinates <code>x, y</code> + */ + public int viewToModel(float x, float y, Shape a, Position.Bias b) + { + // FIXME: Implement this properly. + return 0; + } } diff --git a/javax/swing/text/CompositeView.java b/javax/swing/text/CompositeView.java index 3dc46fc8e..60d453b9e 100644 --- a/javax/swing/text/CompositeView.java +++ b/javax/swing/text/CompositeView.java @@ -38,14 +38,41 @@ exception statement from your version. */ package javax.swing.text; +import java.awt.Insets; +import java.awt.Rectangle; import java.awt.Shape; -// TODO: Implement this class. +import javax.swing.SwingConstants; + +/** + * An abstract base implementation of {@link View} that manages child + * <code>View</code>s. + * + * @author Roman Kennke (roman@kennke.org) + */ public abstract class CompositeView extends View { /** + * The child views of this <code>CompositeView</code>. + */ + View[] children; + + /** + * The allocation of this <code>View</code> minus its insets. This is + * initialized in {@link #getInsideAllocation} and reused and modified in + * {@link childAllocation}. + */ + Rectangle insideAllocation; + + /** + * The insets of this <code>CompositeView</code>. This is initialized + * in {@link #setInsets}. + */ + Insets insets; + + /** * Creates a new <code>CompositeView</code> for the given * <code>Element</code>. * @@ -54,6 +81,102 @@ public abstract class CompositeView public CompositeView(Element element) { super(element); + children = new View[0]; + insets = new Insets(0, 0, 0, 0); + } + + /** + * Loads the child views of this <code>CompositeView</code>. This method + * is called from {@link #setParent} to initialize the child views of + * this composite view. + * + * @param f the view factory to use for creating new child views + * + * @see {@link #setParent} + */ + protected void loadChildren(ViewFactory f) + { + Element el = getElement(); + int count = el.getElementCount(); + children = new View[count]; + for (int i = 0; i < count; ++i) + { + Element child = el.getElement(i); + View view = f.create(child); + children[i] = view; + } + } + + /** + * Sets the parent of this <code>View</code>. + * In addition to setting the parent, this calls {@link #loadChildren}, if + * this <code>View</code> does not already have its children initialized. + * + * @param p the parent to set + */ + public void setParent(View parent) + { + super.setParent(parent); + if ((children == null) || children.length == 0) + loadChildren(getViewFactory()); + } + + /** + * Returns the number of child views. + * + * @return the number of child views + */ + public int getViewCount() + { + return children.length; + } + + /** + * Returns the child view at index <code>n</code>. + * + * @param n the index of the requested child view + * + * @return the child view at index <code>n</code> + */ + public View getView(int n) + { + return children[n]; + } + + /** + * Replaces child views by some other child views. If there are no views to + * remove (<code>length == 0</code>), the result is a simple insert, if + * there are no children to add (<code>view == null</code>) the result + * is a simple removal. + * + * @param offset the start offset from where to remove children + * @param length the number of children to remove + * @param views the views that replace the removed children + */ + public void replace(int offset, int length, View[] views) + { + View[] newChildren = new View[children.length - length + views.length]; + System.arraycopy(children, 0, newChildren, 0, offset); + System.arraycopy(views, 0, newChildren, offset, views.length); + System.arraycopy(children, offset + length, newChildren, + offset + views.length, + children.length - (offset + length)); + children = newChildren; + } + + /** + * Returns the allocation for the specified child <code>View</code>. + * + * @param index the index of the child view + * @param a the allocation for this view + * + * @return the allocation for the specified child <code>View</code> + */ + public Shape getChildAllocation(int index, Shape a) + { + Rectangle r = getInsideAllocation(a); + childAllocation(index, r); + return r; } /** @@ -75,10 +198,423 @@ public abstract class CompositeView * @throws IllegalArgumentException if b is not one of the above listed * valid values */ - public Shape modelToView(int pos, Shape a, Position.Bias b) + public Shape modelToView(int pos, Shape a, Position.Bias bias) throws BadLocationException { - // Implement me. - return null; + int childIndex = getViewIndex(pos, bias); + View child = children[childIndex]; + return child.modelToView(pos, a, bias); + } + + /** + * Maps a region in the document into the coordinate space of the View. + * + * @param p1 the beginning position inside the document + * @param b1 the direction bias for the beginning position + * @param p2 the end position inside the document + * @param b2 the direction bias for the end position + * @param a the area that is occupied by the view + * + * @return a rectangle that gives the span of the document region + * inside the view coordinate space + * + * @throws BadLocationException if <code>p1</code> or <code>p2</code> are + * invalid + * @throws IllegalArgumentException if b1 or b2 is not one of the above + * listed valid values + */ + public Shape modelToView(int p1, Position.Bias b1, + int p2, Position.Bias b2, Shape a) + throws BadLocationException + { + // TODO: This is most likely not 100% ok, figure out what else is to + // do here. + return super.modelToView(p1, b1, p2, b2, a); + } + + /** + * Maps coordinates from the <code>View</code>'s space into a position + * in the document model. + * + * @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> + * @param b the bias to use + * + * @return the position in the document that corresponds to the screen + * coordinates <code>x, y</code> + */ + public int viewToModel(float x, float y, Shape a, Position.Bias b) + { + Rectangle r = getInsideAllocation(a); + View view = getViewAtPoint((int) x, (int) y, r); + return view.viewToModel(x, y, a, b); + } + + /** + * Returns the next model location that is visible in eiter north / south + * direction or east / west direction. This is used to determine the + * placement of the caret when navigating around the document with + * the arrow keys. + * + * This is a convenience method for + * {@link #getNextNorthSouthVisualPositionFrom} and + * {@link #getNextEastWestVisualPositionFrom}. + * + * @param pos the model position to start search from + * @param the bias for <code>pos</code> + * @param a the allocated region for this view + * @param direction the direction from the current position, can be one of + * the following: + * <ul> + * <li>{@link SwingConstants#WEST}</li> + * <li>{@link SwingConstants#EAST}</li> + * <li>{@link SwingConstants#NORTH}</li> + * <li>{@link SwingConstants#SOUTH}</li> + * </ul> + * @param biasRet the bias of the return value gets stored here + * + * @return the position inside the model that represents the next visual + * location + * + * @throws BadLocationException if <code>pos</code> is not a valid location + * inside the document model + * @throws IllegalArgumentException if <code>direction</code> is invalid + */ + public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, + int direction, Position.Bias[] biasRet) + { + int retVal = -1; + switch (direction) + { + case SwingConstants.WEST: + case SwingConstants.EAST: + retVal = getNextEastWestVisualPositionFrom(pos, b, a, direction, + biasRet); + break; + case SwingConstants.NORTH: + case SwingConstants.SOUTH: + retVal = getNextNorthSouthVisualPositionFrom(pos, b, a, direction, + biasRet); + break; + default: + throw new IllegalArgumentException("Illegal value for direction."); + } + return retVal; + } + + /** + * Returns the index of the child view that represents the specified + * model location. + * + * @param pos the model location for which to determine the child view index + * @param b the bias to be applied to <code>pos</code> + * + * @return the index of the child view that represents the specified + * model location + */ + public int getViewIndex(int pos, Position.Bias b) + { + // FIXME: Handle bias somehow. + return getViewIndexAtPosition(pos); + } + + /** + * Returns <code>true</code> if the specified point lies before the + * given <code>Rectangle</code>, <code>false</code> otherwise. + * + * "Before" is typically defined as being to the left or above. + * + * @param x the X coordinate of the point + * @param y the Y coordinate of the point + * @param r the rectangle to test the point against + * + * @return <code>true</code> if the specified point lies before the + * given <code>Rectangle</code>, <code>false</code> otherwise + */ + protected abstract boolean isBefore(int x, int y, Rectangle r); + + /** + * Returns <code>true</code> if the specified point lies after the + * given <code>Rectangle</code>, <code>false</code> otherwise. + * + * "After" is typically defined as being to the right or below. + * + * @param x the X coordinate of the point + * @param y the Y coordinate of the point + * @param r the rectangle to test the point against + * + * @return <code>true</code> if the specified point lies after the + * given <code>Rectangle</code>, <code>false</code> otherwise + */ + protected abstract boolean isAfter(int x, int y, Rectangle r); + + /** + * Returns the child <code>View</code> at the specified location. + * + * @param x the X coordinate + * @param y the Y coordinate + * @param r the allocation of this <code>CompositeView</code> + * + * @return the child <code>View</code> at the specified location + */ + protected abstract View getViewAtPoint(int x, int y, Rectangle r); + + /** + * Computes the allocation for a child <code>View</code>. The parameter + * <code>a</code> stores the allocation of this <code>CompositeView</code> + * and is then adjusted to hold the allocation of the child view. + * + * @param index the index of the child <code>View</code> + * @param a the allocation of this <code>CompositeView</code> before the + * call, the allocation of the child on exit + */ + protected abstract void childAllocation(int index, Rectangle a); + + /** + * Returns the child <code>View</code> that contains the given model + * position. The given <code>Rectangle</code> gives the parent's allocation + * and is changed to the child's allocation on exit. + * + * @param pos the model position to query the child <code>View</code> for + * @param a the parent allocation on entry and the child allocation on exit + * + * @return the child view at the given model position + */ + protected View getViewAtPosition(int pos, Rectangle a) + { + int i = getViewIndexAtPosition(pos); + View view = children[i]; + childAllocation(i, a); + return view; + } + + /** + * Returns the index of the child <code>View</code> for the given model + * position. + * + * @param pos the model position for whicht the child <code>View</code> is + * queried + * + * @return the index of the child <code>View</code> for the given model + * position + */ + 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); + return index; + } + + /** + * Returns the allocation that is given to this <code>CompositeView</code> + * minus this <code>CompositeView</code>'s insets. + * + * Also this translates from an immutable allocation to a mutable allocation + * that is typically reused and further narrowed, like in + * {@link childAllocation}. + * + * @param a the allocation given to this <code>CompositeView</code> + * + * @return the allocation that is given to this <code>CompositeView</code> + * minus this <code>CompositeView</code>'s insets or + * <code>null</code> if a was <code>null</code> + */ + protected Rectangle getInsideAllocation(Shape a) + { + if (a == null) + return null; + + Rectangle alloc = a.getBounds(); + // Initialize the inside allocation rectangle. This is done inside + // a synchronized block in order to avoid multiple threads creating + // this instance simultanously. + Rectangle inside; + synchronized(this) + { + inside = insideAllocation; + if (inside == null) + { + inside = new Rectangle(); + insideAllocation = inside; + } + } + 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; + } + + /** + * Sets the insets defined by attributes in <code>attributes</code>. This + * queries the attribute keys {@link StyleConstants#SpaveAbove}, + * {@link StyleConstants#SpaveBelow}, {@link StyleConstants#LeftIndent} and + * {@link StyleConstants#RightIndent} and calls {@link #setInsets} to + * actually set the insets on this <code>CompositeView</code>. + * + * @param attributes the attributes from which to query the insets + */ + protected void setParagraphInsets(AttributeSet attributes) + { + Float l = (Float) attributes.getAttribute(StyleConstants.LeftIndent); + short left = 0; + if (l != null) + left = l.shortValue(); + Float r = (Float) attributes.getAttribute(StyleConstants.RightIndent); + short right = 0; + if (r != null) + right = r.shortValue(); + Float t = (Float) attributes.getAttribute(StyleConstants.SpaceAbove); + short top = 0; + if (t != null) + top = t.shortValue(); + Float b = (Float) attributes.getAttribute(StyleConstants.SpaceBelow); + short bottom = 0; + if (b != null) + bottom = b.shortValue(); + setInsets(top, left, bottom, right); + } + + /** + * Sets the insets of this <code>CompositeView</code>. + * + * @param top the top inset + * @param left the left inset + * @param bottom the bottom inset + * @param right the right inset + */ + protected void setInsets(short top, short left, short bottom, short right) + { + insets.top = top; + insets.left = left; + insets.bottom = bottom; + insets.right = right; + } + + /** + * Returns the left inset of this <code>CompositeView</code>. + * + * @return the left inset of this <code>CompositeView</code> + */ + protected short getLeftInset() + { + return (short) insets.left; + } + + /** + * Returns the right inset of this <code>CompositeView</code>. + * + * @return the right inset of this <code>CompositeView</code> + */ + protected short getRightInset() + { + return (short) insets.right; + } + + /** + * Returns the top inset of this <code>CompositeView</code>. + * + * @return the top inset of this <code>CompositeView</code> + */ + protected short getTopInset() + { + return (short) insets.top; + } + + /** + * Returns the bottom inset of this <code>CompositeView</code>. + * + * @return the bottom inset of this <code>CompositeView</code> + */ + protected short getBottomInset() + { + return (short) insets.bottom; + } + + /** + * Returns the next model location that is visible in north or south + * direction. + * This is used to determine the + * placement of the caret when navigating around the document with + * the arrow keys. + * + * @param pos the model position to start search from + * @param the bias for <code>pos</code> + * @param a the allocated region for this view + * @param direction the direction from the current position, can be one of + * the following: + * <ul> + * <li>{@link SwingConstants#NORTH}</li> + * <li>{@link SwingConstants#SOUTH}</li> + * </ul> + * @param biasRet the bias of the return value gets stored here + * + * @return the position inside the model that represents the next visual + * location + * + * @throws BadLocationException if <code>pos</code> is not a valid location + * inside the document model + * @throws IllegalArgumentException if <code>direction</code> is invalid + */ + protected int getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b, + Shape a, int direction, + Position.Bias[] biasRet) + { + // FIXME: Implement this correctly. + return pos; + } + + /** + * Returns the next model location that is visible in east or west + * direction. + * This is used to determine the + * placement of the caret when navigating around the document with + * the arrow keys. + * + * @param pos the model position to start search from + * @param the bias for <code>pos</code> + * @param a the allocated region for this view + * @param direction the direction from the current position, can be one of + * the following: + * <ul> + * <li>{@link SwingConstants#EAST}</li> + * <li>{@link SwingConstants#WEST}</li> + * </ul> + * @param biasRet the bias of the return value gets stored here + * + * @return the position inside the model that represents the next visual + * location + * + * @throws BadLocationException if <code>pos</code> is not a valid location + * inside the document model + * @throws IllegalArgumentException if <code>direction</code> is invalid + */ + protected int getNextEastWestVisualPositionFrom(int pos, Position.Bias b, + Shape a, int direction, + Position.Bias[] biasRet) + { + // FIXME: Implement this correctly. + return pos; + } + + /** + * Determines if the next view in horinzontal direction is located to + * the east or west of the view at position <code>pos</code>. Usually + * the <code>View</code>s are laid out from the east to the west, so + * we unconditionally return <code>false</code> here. Subclasses that + * support bidirectional text may wish to override this method. + * + * @param pos the position in the document + * @param bias the bias to be applied to <code>pos</code> + * + * @return <code>true</code> if the next <code>View</code> is located + * to the EAST, <code>false</code> otherwise + */ + protected boolean flipEastAndWestAtEnds(int pos, Position.Bias bias) + { + return false; } } diff --git a/javax/swing/text/DefaultCaret.java b/javax/swing/text/DefaultCaret.java index b57b36563..0d949c3d8 100644 --- a/javax/swing/text/DefaultCaret.java +++ b/javax/swing/text/DefaultCaret.java @@ -1,5 +1,5 @@ /* DefaultCaret.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. @@ -51,69 +51,203 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; - +/** + * The default implementation of the {@link Caret} interface. + * + * @author orgininal author unknown + * @author Roman Kennke (roman@kennke.org) + */ public class DefaultCaret extends Rectangle implements Caret, FocusListener, MouseListener, MouseMotionListener { + /** + * The serial version UID for DefaultCaret. + */ private static final long serialVersionUID = 228155774675466193L; - + + /** + * The <code>ChangeEvent</code> that is fired by {@link #fireStateChanged()}. + */ protected ChangeEvent changeEvent = new ChangeEvent(this); + + /** + * Stores all registered event listeners. + */ protected EventListenerList listenerList = new EventListenerList(); - + + /** + * The text component in which this caret is installed. + */ private JTextComponent textComponent; - + + /** + * Indicates if the selection should be visible or not. + */ private boolean selectionVisible = true; + + /** + * The blink rate of this <code>Caret</code>. + */ private int blinkRate = 500; + + /** + * The current dot position. + */ private int dot = 0; + + /** + * The current mark position. + */ private int mark = 0; + + /** + * The current visual caret position. + */ private Point magicCaretPosition = null; + + /** + * Indicates if this <code>Caret</code> is currently visible or not. + */ private boolean visible = true; + + /** + * The current highlight entry. + */ private Object highlightEntry; + /** + * Moves the caret position when the mouse is dragged over the text + * component, modifying the selection accordingly. + * + * @param event the <code>MouseEvent</code> describing the drag operation + */ public void mouseDragged(MouseEvent event) { + // FIXME: Implement this properly. } + /** + * Indicates a mouse movement over the text component. Does nothing here. + * + * @param event the <code>MouseEvent</code> describing the mouse operation + */ public void mouseMoved(MouseEvent event) { - } - + // Nothing to do here. + } + + /** + * When the click is received from Button 1 then the following actions + * are performed here: + * + * <ul> + * <li>If we receive a double click, the caret position (dot) is set + * to the position associated to the mouse click and the word at + * this location is selected.</li> + * <li>If we receive a triple click, the caret position (dot) is set + * to the position associated to the mouse click and the line at + * this location is selected.</li> + * </ul> + * + * @param event the <code>MouseEvent</code> describing the click operation + */ public void mouseClicked(MouseEvent event) { + // FIXME: Implement this properly. } + /** + * Indicates that the mouse has entered the text component. Nothing is done + * here. + * + * @param event the <code>MouseEvent</code> describing the mouse operation + */ public void mouseEntered(MouseEvent event) { + // Nothing to do here. } + /** + * Indicates that the mouse has exited the text component. Nothing is done + * here. + * + * @param event the <code>MouseEvent</code> describing the mouse operation + */ public void mouseExited(MouseEvent event) { } + /** + * If the button 1 is pressed, the caret position is updated to the + * position of the mouse click and the text component requests the input + * focus if it is enabled. If the SHIFT key is held down, the caret will + * be moved, which might select the text between the old and new location. + * + * @param event the <code>MouseEvent</code> describing the press operation + */ public void mousePressed(MouseEvent event) { + // FIXME: Implement this properly. } + /** + * Indicates that a mouse button has been released on the text component. + * Nothing is done here. + * + * @param event the <code>MouseEvent</code> describing the mouse operation + */ public void mouseReleased(MouseEvent event) { + // Nothing to do here. } + /** + * Sets the caret to <code>visible</code> if the text component is editable. + * + * @param event the <code>FocusEvent</code> + */ public void focusGained(FocusEvent event) { } + /** + * Sets the caret to <code>invisible</code>. + * + * @param event the <code>FocusEvent</code> + */ public void focusLost(FocusEvent event) { } + /** + * Moves the caret to the position specified in the <code>MouseEvent</code>. + * This will cause a selection if the dot and mark are different. + * + * @param event the <code>MouseEvent</code> from which to fetch the position + */ protected void moveCaret(MouseEvent event) { + // FIXME: Implement this properly. } + /** + * Repositions the caret to the position specified in the + * <code>MouseEvent</code>. + * + * @param event the <code>MouseEvent</code> from which to fetch the position + */ protected void positionCaret(MouseEvent event) { + // FIXME: Implement this properly. } + /** + * Deinstalls this <code>Caret</code> from the specified + * <code>JTextComponent</code>. This removes any listeners that have been + * registered by this <code>Caret</code>. + * + * @param c the text component from which to install this caret + */ public void deinstall(JTextComponent c) { textComponent.removeFocusListener(this); @@ -122,6 +256,13 @@ public class DefaultCaret extends Rectangle textComponent = null; } + /** + * Installs this <code>Caret</code> on the specified + * <code>JTextComponent</code>. This registers a couple of listeners + * on the text component. + * + * @param c the text component on which to install this caret + */ public void install(JTextComponent c) { textComponent = c; @@ -131,16 +272,37 @@ public class DefaultCaret extends Rectangle repaint(); } + /** + * Sets the current visual position of this <code>Caret</code>. + * + * @param p the Point to use for the saved location. May be <code>null</code> + * to indicate that there is no visual location + */ public void setMagicCaretPosition(Point p) { magicCaretPosition = p; } + /** + * Returns the current visual position of this <code>Caret</code>. + * + * @return the current visual position of this <code>Caret</code> + * + * @see {@link #setMagicCaretPosition} + */ public Point getMagicCaretPosition() { return magicCaretPosition; } + /** + * Returns the current position of the <code>mark</code>. The + * <code>mark</code> marks the location in the <code>Document</code> that + * is the end of a selection. If there is no selection, the <code>mark</code> + * is the same as the <code>dot</code>. + * + * @return the current position of the mark + */ public int getMark() { return mark; @@ -181,6 +343,12 @@ public class DefaultCaret extends Rectangle } } + /** + * Sets the visiblity state of the selection. + * + * @param v <code>true</code> if the selection should be visible, + * <code>false</code> otherwise + */ public void setSelectionVisible(boolean v) { if (selectionVisible == v) @@ -191,17 +359,35 @@ public class DefaultCaret extends Rectangle repaint(); } + /** + * Returns <code>true</code> if the selection is currently visible, + * <code>false</code> otherwise. + * + * @return <code>true</code> if the selection is currently visible, + * <code>false</code> otherwise + */ public boolean isSelectionVisible() { return selectionVisible; } + /** + * Causes the <code>Caret</code> to repaint itself. + */ 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(); } + /** + * Paints this <code>Caret</code> using the specified <code>Graphics</code> + * context. + * + * @param g the graphics context to use + */ public void paint(Graphics g) { if (textComponent == null) @@ -234,26 +420,53 @@ public class DefaultCaret extends Rectangle } } + /** + * Returns all registered event listeners of the specified type. + * + * @param listenerType the type of listener to return + * + * @return all registered event listeners of the specified type + */ public EventListener[] getListeners(Class listenerType) { return listenerList.getListeners(listenerType); } + /** + * Registers a {@link ChangeListener} that is notified whenever that state + * of this <code>Caret</code> changes. + * + * @param l the listener to register to this caret + */ public void addChangeListener(ChangeListener listener) { listenerList.add(ChangeListener.class, listener); } + /** + * Removes a {@link ChangeListener} from the list of registered listeners. + * + * @param l the listener to remove + */ public void removeChangeListener(ChangeListener listener) { listenerList.remove(ChangeListener.class, listener); } + /** + * Returns all registered {@link ChangeListener}s of this <code>Caret</code>. + * + * @return all registered {@link ChangeListener}s of this <code>Caret</code> + */ public ChangeListener[] getChangeListeners() { return (ChangeListener[]) getListeners(ChangeListener.class); } + /** + * Notifies all registered {@link ChangeListener}s that the state + * of this <code>Caret</code> has changed. + */ protected void fireStateChanged() { ChangeListener[] listeners = getChangeListeners(); @@ -262,26 +475,61 @@ public class DefaultCaret extends Rectangle listeners[index].stateChanged(changeEvent); } + /** + * Returns the <code>JTextComponent</code> on which this <code>Caret</code> + * is installed. + * + * @return the <code>JTextComponent</code> on which this <code>Caret</code> + * is installed + */ protected final JTextComponent getComponent() { return textComponent; } - + + /** + * Returns the blink rate of this <code>Caret</code> in milliseconds. + * A value of <code>0</code> means that the caret does not blink. + * + * @return the blink rate of this <code>Caret</code> or <code>0</code> if + * this caret does not blink + */ public int getBlinkRate() { return blinkRate; } + /** + * Sets the blink rate of this <code>Caret</code> in milliseconds. + * A value of <code>0</code> means that the caret does not blink. + * + * @param rate the new blink rate to set + */ public void setBlinkRate(int rate) { blinkRate = rate; } + /** + * Returns the current position of this <code>Caret</code> within the + * <code>Document</code>. + * + * @return the current position of this <code>Caret</code> within the + * <code>Document</code> + */ public int getDot() { return dot; } + /** + * Moves the <code>dot</code> location without touching the + * <code>mark</code>. This is used when making a selection. + * + * @param dot the location where to move the dot + * + * @see {@link #setDot(int)} + */ public void moveDot(int dot) { this.dot = dot; @@ -289,6 +537,15 @@ public class DefaultCaret extends Rectangle repaint(); } + /** + * Sets the current position of this <code>Caret</code> within the + * <code>Document</code>. This also sets the <code>mark</code> to the + * new location. + * + * @param dot the new position to be set + * + * @see {@link #moveDot(int)} + */ public void setDot(int dot) { this.dot = dot; @@ -297,17 +554,37 @@ public class DefaultCaret extends Rectangle repaint(); } + /** + * Returns <code>true</code> if this <code>Caret</code> is currently visible, + * and <code>false</code> if it is not. + * + * @return <code>true</code> if this <code>Caret</code> is currently visible, + * and <code>false</code> if it is not + */ public boolean isVisible() { return visible; } + /** + * Sets the visibility state of the caret. <code>true</code> shows the + * <code>Caret</code>, <code>false</code> hides it. + * + * @param v the visibility to set + */ public void setVisible(boolean v) { visible = v; repaint(); } + /** + * Returns the {@link Highlighter.HighlightPainter} that should be used + * to paint the selection. + * + * @return the {@link Highlighter.HighlightPainter} that should be used + * to paint the selection + */ protected Highlighter.HighlightPainter getSelectionPainter() { return DefaultHighlighter.DefaultPainter; diff --git a/javax/swing/text/DefaultEditorKit.java b/javax/swing/text/DefaultEditorKit.java index aa2fbe850..9d8072947 100644 --- a/javax/swing/text/DefaultEditorKit.java +++ b/javax/swing/text/DefaultEditorKit.java @@ -51,44 +51,135 @@ import java.io.Writer; import javax.swing.Action; +/** + * The default implementation of {@link EditorKit}. This <code>EditorKit</code> + * a plain text <code>Document</code> and several commands that together + * make up a basic editor, like cut / copy + paste. + * + * @author original author unknown + * @author Roman Kennke (roman@kennke.org) + */ public class DefaultEditorKit extends EditorKit { + /** + * Creates a beep on the PC speaker. + * + * @see {@link Toolkit#beep()} + */ public static class BeepAction extends TextAction { + /** + * Creates a new <code>BeepAction</code>. + */ public BeepAction() { super(beepAction); } + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ public void actionPerformed(ActionEvent event) { Toolkit.getDefaultToolkit().beep(); } } + /** + * Copies the selected content into the system clipboard. + * + * @see {@link Toolkit#getSystemClipboard()} + * @see {@link CutAction} + * @see {@link PasteAction} + */ public static class CopyAction extends TextAction { + + /** + * Create a new <code>CopyAction</code>. + */ public CopyAction() { super(copyAction); } + + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ public void actionPerformed(ActionEvent event) { + // FIXME: Implement me. Tookit.getSystemClipboard should be used + // for that. } } + + /** + * Copies the selected content into the system clipboard and deletes the + * selection. + * + * @see {@link Toolkit#getSystemClipboard()} + * @see {@link CopyAction} + * @see {@link PasteAction} + */ public static class CutAction extends TextAction { + + /** + * Create a new <code>CutAction</code>. + */ public CutAction() { super(cutAction); } + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ public void actionPerformed(ActionEvent event) { + // FIXME: Implement me. Tookit.getSystemClipboard should be used + // for that. + } + } + + /** + * Copies content from the system clipboard into the editor. + * + * @see {@link Toolkit#getSystemClipboard()} + * @see {@link CopyAction} + * @see {@link CutAction} + */ + public static class PasteAction + extends TextAction + { + + /** + * Create a new <code>PasteAction</code>. + */ + public PasteAction() + { + super(pasteAction); + } + + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ + public void actionPerformed(ActionEvent event) + { + // FIXME: Implement me. Tookit.getSystemClipboard should be used + // for that. } } @@ -99,17 +190,26 @@ public class DefaultEditorKit extends EditorKit * the control characters and characters with the ALT-modifier. * * If an event does not get filtered, it is inserted into the document - * of the text component. If there is some text selected in the text component, - * this text will be replaced. + * of the text component. If there is some text selected in the text + * component, this text will be replaced. */ public static class DefaultKeyTypedAction extends TextAction { + + /** + * Creates a new <code>DefaultKeyTypedAction</code>. + */ public DefaultKeyTypedAction() { super(defaultKeyTypedAction); } + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ public void actionPerformed(ActionEvent event) { // first we filter the following events: @@ -124,9 +224,11 @@ public class DefaultEditorKit extends EditorKit { try { - t.getDocument().insertString(t.getCaret().getDot(), event.getActionCommand(), null); + t.getDocument().insertString(t.getCaret().getDot(), + event.getActionCommand(), null); t.getCaret().setDot(Math.min(t.getCaret().getDot() + 1, - t.getDocument().getEndPosition().getOffset())); + t.getDocument().getEndPosition() + .getOffset())); } catch (BadLocationException be) { @@ -144,11 +246,20 @@ public class DefaultEditorKit extends EditorKit public static class InsertBreakAction extends TextAction { + + /** + * Creates a new <code>InsertBreakAction</code>. + */ public InsertBreakAction() { super(insertBreakAction); } + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ public void actionPerformed(ActionEvent event) { JTextComponent t = getTextComponent(event); @@ -156,101 +267,446 @@ public class DefaultEditorKit extends EditorKit } } + /** + * Places content into the associated editor. If there currently is a + * selection, this selection is replaced. + */ + // FIXME: Figure out what this Action is supposed to do. Obviously text + // that is entered by the user is inserted through DefaultKeyTypedAction. public static class InsertContentAction extends TextAction { + + /** + * Creates a new <code>InsertContentAction</code>. + */ public InsertContentAction() { super(insertContentAction); } + + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ public void actionPerformed(ActionEvent event) { } } + /** + * Inserts a TAB character into the text editor. + */ public static class InsertTabAction extends TextAction { + + /** + * Creates a new <code>TabAction</code>. + */ public InsertTabAction() { super(insertTabAction); } + /** + * Performs the <code>Action</code>. + * + * @param event the action event describing the user action + */ public void actionPerformed(ActionEvent event) { + // FIXME: Implement this. } } - public static class PasteAction - extends TextAction - { - public PasteAction() - { - super(pasteAction); - } - - public void actionPerformed(ActionEvent event) - { - } - } - + /** + * The serial version of DefaultEditorKit. + */ private static final long serialVersionUID = 9017245433028523428L; - + + /** + * The name of the <code>Action</code> that moves the caret one character + * backwards. + * + * @see {@link #getActions()} + */ public static final String backwardAction = "caret-backward"; + + /** + * The name of the <code>Action</code> that creates a beep in the speaker. + * + * @see {@link #getActions()} + */ public static final String beepAction = "beep"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the <code>Document</code>. + * + * @see {@link #getActions()} + */ public static final String beginAction = "caret-begin"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the current line. + * + * @see {@link #getActions()} + */ public static final String beginLineAction = "caret-begin-line"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the current paragraph. + * + * @see {@link #getActions()} + */ public static final String beginParagraphAction = "caret-begin-paragraph"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the current word. + * + * @see {@link #getActions()} + */ public static final String beginWordAction = "caret-begin-word"; + + /** + * The name of the <code>Action</code> that copies the selected content + * into the system clipboard. + * + * @see {@link #getActions()} + */ public static final String copyAction = "copy-to-clipboard"; + + /** + * The name of the <code>Action</code> that copies the selected content + * into the system clipboard and removes the selection. + * + * @see {@link #getActions()} + */ public static final String cutAction = "cut-to-clipboard"; + + /** + * The name of the <code>Action</code> that is performed by default if + * a key is typed and there is no keymap entry. + * + * @see {@link #getActions()} + */ public static final String defaultKeyTypedAction = "default-typed"; + + /** + * The name of the <code>Action</code> that deletes the character that + * follows the current caret position. + * + * @see {@link #getActions()} + */ public static final String deleteNextCharAction = "delete-next"; + + /** + * The name of the <code>Action</code> that deletes the character that + * precedes the current caret position. + * + * @see {@link #getActions()} + */ public static final String deletePrevCharAction = "delete-previous"; + + /** + * The name of the <code>Action</code> that moves the caret one line down. + * + * @see {@link #getActions()} + */ public static final String downAction = "caret-down"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the <code>Document</code>. + * + * @see {@link #getActions()} + */ public static final String endAction = "caret-end"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the current line. + * + * @see {@link #getActions()} + */ public static final String endLineAction = "caret-end-line"; + + /** + * When a document is read and an CRLF is encountered, then we add a property + * with this name and a value of "\r\n". + */ public static final String EndOfLineStringProperty = "__EndOfLine__"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the current paragraph. + * + * @see {@link #getActions()} + */ public static final String endParagraphAction = "caret-end-paragraph"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the current word. + * + * @see {@link #getActions()} + */ public static final String endWordAction = "caret-end-word"; + + /** + * The name of the <code>Action</code> that moves the caret one character + * forward. + * + * @see {@link #getActions()} + */ public static final String forwardAction = "caret-forward"; + + /** + * The name of the <code>Action</code> that inserts a line break. + * + * @see {@link #getActions()} + */ public static final String insertBreakAction = "insert-break"; + + /** + * The name of the <code>Action</code> that inserts some content. + * + * @see {@link #getActions()} + */ public static final String insertContentAction = "insert-content"; + + /** + * The name of the <code>Action</code> that inserts a TAB. + * + * @see {@link #getActions()} + */ public static final String insertTabAction = "insert-tab"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the next word. + * + * @see {@link #getActions()} + */ public static final String nextWordAction = "caret-next-word"; + + /** + * The name of the <code>Action</code> that moves the caret one page down. + * + * @see {@link #getActions()} + */ public static final String pageDownAction = "page-down"; + + /** + * The name of the <code>Action</code> that moves the caret one page up. + * + * @see {@link #getActions()} + */ public static final String pageUpAction = "page-up"; + + /** + * The name of the <code>Action</code> that copies content from the system + * clipboard into the document. + * + * @see {@link #getActions()} + */ public static final String pasteAction = "paste-from-clipboard"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the previous word. + * + * @see {@link #getActions()} + */ public static final String previousWordAction = "caret-previous-word"; + + /** + * The name of the <code>Action</code> that sets the editor in read only + * mode. + * + * @see {@link #getActions()} + */ public static final String readOnlyAction = "set-read-only"; + + /** + * The name of the <code>Action</code> that selects the whole document. + * + * @see {@link #getActions()} + */ public static final String selectAllAction = "select-all"; + + /** + * The name of the <code>Action</code> that moves the caret one character + * backwards, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionBackwardAction = "selection-backward"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the document, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionBeginAction = "selection-begin"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the current line, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionBeginLineAction = "selection-begin-line"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the current paragraph, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionBeginParagraphAction = "selection-begin-paragraph"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the current word, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionBeginWordAction = "selection-begin-word"; + + /** + * The name of the <code>Action</code> that moves the caret one line down, + * possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionDownAction = "selection-down"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the document, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionEndAction = "selection-end"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the current line, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionEndLineAction = "selection-end-line"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the current paragraph, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionEndParagraphAction = "selection-end-paragraph"; + + /** + * The name of the <code>Action</code> that moves the caret to the end + * of the current word, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionEndWordAction = "selection-end-word"; + + /** + * The name of the <code>Action</code> that moves the caret one character + * forwards, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionForwardAction = "selection-forward"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the next word, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionNextWordAction = "selection-next-word"; + + /** + * The name of the <code>Action</code> that moves the caret to the beginning + * of the previous word, possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionPreviousWordAction = "selection-previous-word"; + + /** + * The name of the <code>Action</code> that moves the caret one line up, + * possibly extending the current selection. + * + * @see {@link #getActions()} + */ public static final String selectionUpAction = "selection-up"; + + /** + * The name of the <code>Action</code> that selects the line around the + * caret. + * + * @see {@link #getActions()} + */ public static final String selectLineAction = "select-line"; + + /** + * The name of the <code>Action</code> that selects the paragraph around the + * caret. + * + * @see {@link #getActions()} + */ public static final String selectParagraphAction = "select-paragraph"; + + /** + * The name of the <code>Action</code> that selects the word around the + * caret. + * + * @see {@link #getActions()} + */ public static final String selectWordAction = "select-word"; + + /** + * The name of the <code>Action</code> that moves the caret one line up. + * + * @see {@link #getActions()} + */ public static final String upAction = "caret-up"; + + /** + * The name of the <code>Action</code> that sets the editor in read-write + * mode. + * + * @see {@link #getActions()} + */ public static final String writableAction = "set-writable"; + /** + * Creates a new <code>DefaultEditorKit</code>. + */ public DefaultEditorKit() { } + /** + * The <code>Action</code>s that are supported by the + * <code>DefaultEditorKit</code>. + */ + // TODO: All these inner classes look ugly. Maybe work out a better way + // to handle this. private static Action[] defaultActions = new Action[] { new BeepAction(), @@ -356,37 +812,98 @@ public class DefaultEditorKit extends EditorKit }, }; + /** + * Creates the <code>Caret</code> for this <code>EditorKit</code>. This + * returns a {@link DefaultCaret} in this case. + * + * @return the <code>Caret</code> for this <code>EditorKit</code> + */ public Caret createCaret() { return new DefaultCaret(); } + /** + * Creates the default {@link Document} that this <code>EditorKit</code> + * supports. This is a {@link DefaultDocument} in this case. + * + * @return the default {@link Document} that this <code>EditorKit</code> + * supports + */ public Document createDefaultDocument() { return new PlainDocument(); } - + + /** + * Returns the <code>Action</code>s supported by this <code>EditorKit</code>. + * + * @return the <code>Action</code>s supported by this <code>EditorKit</code> + */ public Action[] getActions() { return defaultActions; } + /** + * Returns the content type that this <code>EditorKit</code> supports. + * The <code>DefaultEditorKit</code> supports the content type + * <code>text/plain</code>. + * + * @return the content type that this <code>EditorKit</code> supports + */ public String getContentType() { return "text/plain"; } - + + /** + * Returns a {@link ViewFactory} that is able to create {@link View}s for + * the <code>Element</code>s that are used in this <code>EditorKit</code>'s + * model. This returns null which lets the UI of the text component supply + * <code>View</code>s. + * + * @return a {@link ViewFactory} that is able to create {@link View}s for + * the <code>Element</code>s that are used in this + * <code>EditorKit</code>'s model + */ public ViewFactory getViewFactory() { return null; } + /** + * Reads a document of the supported content type from an {@link InputStream} + * into the actual {@link Document} object. + * + * @param in the stream from which to read the document + * @param document the document model into which the content is read + * @param offset the offset inside to document where the content is inserted + * + * @throws BadLocationException if <code>offset</code> is an invalid location + * inside <code>document</code> + * @throws IOException if something goes wrong while reading from + * <code>in</code> + */ public void read(InputStream in, Document document, int offset) throws BadLocationException, IOException { read(new InputStreamReader(in), document, offset); } + /** + * Reads a document of the supported content type from a {@link Reader} + * into the actual {@link Document} object. + * + * @param in the reader from which to read the document + * @param document the document model into which the content is read + * @param offset the offset inside to document where the content is inserted + * + * @throws BadLocationException if <code>offset</code> is an invalid location + * inside <code>document</code> + * @throws IOException if something goes wrong while reading from + * <code>in</code> + */ public void read(Reader in, Document document, int offset) throws BadLocationException, IOException { @@ -405,14 +922,47 @@ public class DefaultEditorKit extends EditorKit SimpleAttributeSet.EMPTY); } + /** + * Writes the <code>Document</code> (or a fragment of the + * <code>Document</code>) to an {@link OutputStream} in the + * supported content type format. + * + * @param out the stream to write to + * @param document the document that should be written out + * @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 IOException if something goes wrong while writing to + * <code>out</code> + */ public void write(OutputStream out, Document document, int offset, int len) throws BadLocationException, IOException { write(new OutputStreamWriter(out), document, offset, len); } + /** + * Writes the <code>Document</code> (or a fragment of the + * <code>Document</code>) to a {@link Writer} in the + * supported content type format. + * + * @param out the writer to write to + * @param document the document that should be written out + * @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 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 { + // TODO: Implement this properly. } } diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java index 94084800c..d7bad0a08 100644 --- a/javax/swing/text/GapContent.java +++ b/javax/swing/text/GapContent.java @@ -46,25 +46,25 @@ import java.util.ListIterator; import javax.swing.undo.UndoableEdit; /** - * This implementation of {@link AbstractDocument.Content} uses a gapped - * buffer. This takes advantage of the fact that text area content is - * mostly inserted sequentially. The buffer is a char array that maintains - * a gap at the current insertion point. If characters a inserted at - * gap boundaries, the cost is minimal (simple array access). The array only - * has to be shifted around when the insertion point moves (then the gap also - * moves and one array copy is necessary) or when the gap is filled up and - * the buffer has to be enlarged. - * + * This implementation of {@link AbstractDocument.Content} uses a gapped buffer. + * This takes advantage of the fact that text area content is mostly inserted + * sequentially. The buffer is a char array that maintains a gap at the current + * insertion point. If characters a inserted at gap boundaries, the cost is + * minimal (simple array access). The array only has to be shifted around when + * the insertion point moves (then the gap also moves and one array copy is + * necessary) or when the gap is filled up and the buffer has to be enlarged. + * * TODO: Implement UndoableEdit support stuff */ public class GapContent - implements AbstractDocument.Content, Serializable + implements AbstractDocument.Content, Serializable { /** * A {@link Position} implementation for <code>GapContent</code>. */ - class GapContentPosition implements Position, Comparable + class GapContentPosition + implements Position, Comparable { /** The index within the buffer array. */ @@ -72,7 +72,7 @@ public class GapContent /** * Creates a new GapContentPosition object. - * + * * @param mark the mark of this Position */ GapContentPosition(int mark) @@ -83,49 +83,49 @@ public class GapContent /** * Comparable interface implementation. This is used to store all * positions in an ordered fashion. - * + * * @param o the object to be compared to this - * + * * @return a negative integer if this is less than <code>o</code>, zero - * if both are equal or a positive integer if this is greater - * than <code>o</code> - * - * @throws ClassCastException if <code>o</code> is not a GapContentPosition - * or Integer object + * if both are equal or a positive integer if this is greater than + * <code>o</code> + * + * @throws ClassCastException if <code>o</code> is not a + * GapContentPosition or Integer object */ public int compareTo(Object o) { if (o instanceof Integer) - { - int otherMark = ((Integer) o).intValue(); - return mark - otherMark; - } + { + int otherMark = ((Integer) o).intValue(); + return mark - otherMark; + } else - { - GapContentPosition other = (GapContentPosition) o; - return mark - other.mark; - } + { + GapContentPosition other = (GapContentPosition) o; + return mark - other.mark; + } } /** * Returns the current offset of this Position within the content. - * + * * @return the current offset of this Position within the content. */ public int getOffset() { if (mark <= gapStart) - return mark; + return mark; else - return mark - (gapEnd - gapStart); + return mark - (gapEnd - gapStart); } } - + private static final long serialVersionUID = 8374645204155842629L; /** - * This is the default buffer size and the amount of bytes that - * a buffer is extended if it is full. + * This is the default buffer size and the amount of bytes that a buffer is + * extended if it is full. */ static final int DEFAULT_BUFSIZE = 64; @@ -145,8 +145,8 @@ public class GapContent int gapEnd; /** - * The positions generated by this GapContent. They are kept in an - * ordered fashion, so they can be looked up easily. + * The positions generated by this GapContent. They are kept in an ordered + * fashion, so they can be looked up easily. */ LinkedList positions; @@ -160,7 +160,7 @@ public class GapContent /** * Creates a new GapContent object with a specified initial size. - * + * * @param size the initial size of the buffer */ public GapContent(int size) @@ -175,9 +175,9 @@ public class GapContent /** * Allocates an array of the specified length that can then be used as * buffer. - * + * * @param size the size of the array to be allocated - * + * * @return the allocated array */ protected Object allocateArray(int size) @@ -187,7 +187,7 @@ public class GapContent /** * Returns the length of the allocated buffer array. - * + * * @return the length of the allocated buffer array */ protected int getArrayLength() @@ -197,7 +197,7 @@ public class GapContent /** * Returns the length of the content. - * + * * @return the length of the content */ public int length() @@ -207,18 +207,18 @@ public class GapContent /** * Inserts a string at the specified position. - * + * * @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) - * - * @throws BadLocationException if <code>where</code> is not a valid location - * in the buffer + * + * @throws BadLocationException if <code>where</code> is not a valid + * location in the buffer */ public UndoableEdit insertString(int where, String str) - throws BadLocationException + throws BadLocationException { // check arguments int length = length(); @@ -226,7 +226,7 @@ public class GapContent if (where >= length) throw new BadLocationException("the where argument cannot be greater" - + " than the content length", where); + + " than the content length", where); // check if the gap is big enough to hold the string if ((gapEnd - gapStart) < strLen) @@ -246,29 +246,27 @@ public class GapContent /** * Removes a piece of content at th specified position. - * + * * @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) - * - * @throws BadLocationException if <code>where</code> is not a valid location - * in the buffer + * + * @throws BadLocationException if <code>where</code> is not a valid + * location in the buffer */ - public UndoableEdit remove(int where, int nitems) - throws BadLocationException + public UndoableEdit remove(int where, int nitems) throws BadLocationException { // check arguments int length = length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" - + " than the content length", where); + + " than the content length", where); if ((where + nitems) > length) throw new BadLocationException("where + nitems cannot be greater" - + " than the content length", - where + nitems); + + " than the content length", where + nitems); // check if we are at the gap boundary if (where != gapStart) @@ -281,10 +279,10 @@ public class GapContent /** * Returns a piece of content as String. - * + * * @param where the start location of the fragment * @param len the length of the fragment - * + * * @throws BadLocationException if <code>where</code> or * <code>where + len</code> are no valid locations in the buffer */ @@ -297,71 +295,70 @@ public class GapContent /** * Fetches a piece of content and stores it in a {@link Segment} object. - * - * If the requested piece of text spans the gap, the content is copied - * into a new array. If it doesn't then it is contiguous and the - * actual content store is returned. - * + * + * If the requested piece of text spans the gap, the content is copied into a + * new array. If it doesn't then it is contiguous and the actual content + * store is returned. + * * @param where the start location of the fragment * @param len the length of the fragment * @param txt the Segment object to store the fragment in - * + * * @throws BadLocationException if <code>where</code> or * <code>where + len</code> are no valid locations in the buffer */ public void getChars(int where, int len, Segment txt) - throws BadLocationException + throws BadLocationException { // check arguments int length = length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" - + " than the content length", where); + + " than the content length", where); if ((where + len) > length) throw new BadLocationException("len plus where cannot be greater" - + " than the content length", - len + where); + + " than the content length", len + where); // check if requested segment is contiguous if ((where < gapStart) && ((gapStart - where) < len)) - { - // requested segment is not contiguous -> copy the pieces together - char[] copy = new char[len]; - int lenFirst = gapStart - where; // the length of the first segment - System.arraycopy(buffer, where, copy, 0, lenFirst); - System.arraycopy(buffer, gapEnd, copy, lenFirst, len - lenFirst); - txt.array = copy; - txt.offset = 0; - txt.count = len; - } + { + // requested segment is not contiguous -> copy the pieces together + char[] copy = new char[len]; + int lenFirst = gapStart - where; // the length of the first segment + System.arraycopy(buffer, where, copy, 0, lenFirst); + System.arraycopy(buffer, gapEnd, copy, lenFirst, len - lenFirst); + txt.array = copy; + txt.offset = 0; + txt.count = len; + } else - { - // requested segment is contiguous -> we can simply return the - // actual content - txt.array = buffer; - if (where < gapStart) - txt.offset = where; - else - txt.offset = where + (gapEnd - gapStart); - txt.count = len; - } + { + // requested segment is contiguous -> we can simply return the + // actual content + txt.array = buffer; + if (where < gapStart) + txt.offset = where; + else + txt.offset = where + (gapEnd - gapStart); + txt.count = len; + } } /** * Creates and returns a mark at the specified position. - * + * * @param offset the position at which to create the mark - * + * * @return the create Position object for the mark - * - * @throws BadLocationException if the offset is not a valid position in - * the buffer + * + * @throws BadLocationException if the offset is not a valid position in the + * buffer */ public Position createPosition(final int offset) throws BadLocationException { if (offset < 0 || offset > length()) throw new BadLocationException("The offset was out of the bounds of this" - + " buffer", offset); + + " buffer", offset); // We store the actual array index in the GapContentPosition. The real // offset is then calculated in the GapContentPosition. @@ -375,16 +372,16 @@ public class GapContent if (index < 0) index = -(index + 1); positions.add(index, pos); - + return pos; } /** * Enlarges the gap. This allocates a new bigger buffer array, copy the - * segment before the gap as it is and the segment after the gap at - * the end of the new buffer array. This does change the gapEnd mark - * but not the gapStart mark. - * + * segment before the gap as it is and the segment after the gap at the end + * of the new buffer array. This does change the gapEnd mark but not the + * gapStart mark. + * * @param newSize the new size of the gap */ protected void shiftEnd(int newSize) @@ -392,70 +389,75 @@ public class GapContent int delta = (gapEnd - gapStart) - newSize; char[] newBuf = (char[]) allocateArray(length() + newSize); System.arraycopy(buffer, 0, newBuf, 0, gapStart); - System.arraycopy(buffer, gapEnd, newBuf, gapStart + newSize, - buffer.length - gapEnd); + System.arraycopy(buffer, gapEnd, newBuf, gapStart + newSize, buffer.length + - gapEnd); gapEnd = gapStart + newSize; buffer = newBuf; // Update the marks after the gapEnd. - int index = Collections.binarySearch(positions, new Integer(gapEnd)); + int index = Collections.binarySearch(positions, new GapContentPosition( + gapEnd)); if (index < 0) - { - index = -(index + 1); - } + { + index = -(index + 1); + } for (ListIterator i = positions.listIterator(index); i.hasNext();) - { - GapContentPosition p = (GapContentPosition) i.next(); - p.mark += delta; - } + { + GapContentPosition p = (GapContentPosition) i.next(); + p.mark += delta; + } } /** * Shifts the gap to the specified position. - * + * * @param newGapStart the new start position of the gap */ protected void shiftGap(int newGapStart) { int newGapEnd = newGapStart + (gapEnd - gapStart); - // Update the positions between newGapEnd and (old) gapEnd. The marks // must be shifted by (gapEnd - newGapEnd). - int index1 = Collections.binarySearch(positions, new Integer(gapEnd)); - int index2 = Collections.binarySearch(positions, new Integer(newGapEnd)); - int i1 = Math.min(index1, index2); - int i2 = Math.max(index1, index2); - for (ListIterator i = positions.listIterator(i1); i.hasNext();) + int index1 = Collections.binarySearch(positions, new GapContentPosition( + gapEnd)); + int index2 = Collections.binarySearch(positions, new GapContentPosition( + newGapEnd)); + if (index1 > 0 && index2 > 0) + { + int i1 = Math.min(index1, index2); + int i2 = Math.max(index1, index2); + for (ListIterator i = positions.listIterator(i1); i.hasNext();) { - if (i.nextIndex() > i2) - break; + if (i.nextIndex() > i2) + break; - GapContentPosition p = (GapContentPosition) i.next(); - p.mark += gapEnd - newGapEnd; + GapContentPosition p = (GapContentPosition) i.next(); + p.mark += gapEnd - newGapEnd; } - if (newGapStart == gapStart) - return; - else if (newGapStart < gapStart) + if (newGapStart == gapStart) + return; + else if (newGapStart < gapStart) { - System.arraycopy(buffer, newGapStart, buffer, newGapEnd, - gapStart - newGapStart); + System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart + - newGapStart); gapStart = newGapStart; gapEnd = newGapEnd; } - else + else { - System.arraycopy(buffer, gapEnd, buffer, gapStart, - newGapStart - gapStart); + System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart + - gapStart); gapStart = newGapStart; gapEnd = newGapEnd; } + } } /** * Returns the allocated buffer array. - * + * * @return the allocated buffer array */ protected Object getArray() @@ -465,14 +467,13 @@ public class GapContent /** * Replaces a portion of the storage with the specified items. - * + * * @param position the position at which to remove items * @param rmSize the number of items to remove * @param addItems the items to add at location * @param addSize the number of items to add */ - protected void replace(int position, int rmSize, Object addItems, - int addSize) + protected void replace(int position, int rmSize, Object addItems, int addSize) { // Remove content shiftGap(position); diff --git a/javax/swing/text/GlyphView.java b/javax/swing/text/GlyphView.java index f96a918ca..c5a89d2f0 100644 --- a/javax/swing/text/GlyphView.java +++ b/javax/swing/text/GlyphView.java @@ -108,4 +108,22 @@ public class GlyphView // Implement me. return null; } + + /** + * Maps coordinates from the <code>View</code>'s space into a position + * in the document model. + * + * @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> + * @param b the bias to use + * + * @return the position in the document that corresponds to the screen + * coordinates <code>x, y</code> + */ + public int viewToModel(float x, float y, Shape a, Position.Bias b) + { + // FIXME: Implement this properly. + return 0; + } } diff --git a/javax/swing/text/IconView.java b/javax/swing/text/IconView.java index 4bbebdb52..78d91be12 100644 --- a/javax/swing/text/IconView.java +++ b/javax/swing/text/IconView.java @@ -107,4 +107,22 @@ public class IconView // Implement me. return null; } + + /** + * Maps coordinates from the <code>View</code>'s space into a position + * in the document model. + * + * @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> + * @param b the bias to use + * + * @return the position in the document that corresponds to the screen + * coordinates <code>x, y</code> + */ + public int viewToModel(float x, float y, Shape a, Position.Bias b) + { + // FIXME: Implement this properly. + return 0; + } } diff --git a/javax/swing/text/PlainView.java b/javax/swing/text/PlainView.java index 5d1fab000..35909593c 100644 --- a/javax/swing/text/PlainView.java +++ b/javax/swing/text/PlainView.java @@ -237,5 +237,23 @@ public class PlainView extends View return span; } + + /** + * Maps coordinates from the <code>View</code>'s space into a position + * in the document model. + * + * @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> + * @param b the bias to use + * + * @return the position in the document that corresponds to the screen + * coordinates <code>x, y</code> + */ + public int viewToModel(float x, float y, Shape a, Position.Bias b) + { + // FIXME: Implement this properly. + return 0; + } } diff --git a/javax/swing/text/View.java b/javax/swing/text/View.java index 7b6ce24b4..fba4e7015 100644 --- a/javax/swing/text/View.java +++ b/javax/swing/text/View.java @@ -513,4 +513,18 @@ public abstract class View implements SwingConstants Shape s2 = modelToView(p2, a, b2); return s1.getBounds().union(s2.getBounds()); } + + /** + * Maps coordinates from the <code>View</code>'s space into a position + * in the document model. + * + * @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> + * @param b the bias to use + * + * @return the position in the document that corresponds to the screen + * coordinates <code>x, y</code> + */ + public abstract int viewToModel(float x, float y, Shape a, Position.Bias b); } diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c index ab66a2e71..4821770ed 100644 --- a/native/jni/classpath/jcl.c +++ b/native/jni/classpath/jcl.c @@ -181,7 +181,7 @@ JCL_FindClass (JNIEnv * env, const char *className) /* - * Build a RawData object. The function caches the class type + * Build a Pointer object. The function caches the class type */ static jclass rawDataClass; @@ -194,16 +194,63 @@ JCL_NewRawDataObject (JNIEnv * env, void *data) if (rawDataClass == NULL) { #ifdef POINTERS_ARE_64BIT - rawDataClass = (*env)->FindClass (env, "gnu/classpath/RawData64"); + rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer64"); + if (rawDataClass == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal class"); + return NULL; + } + rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(J)V"); + if (rawData_mid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal constructor"); + return NULL; + } + rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "J"); + if (rawData_fid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal field"); + return NULL; + } #else - rawDataClass = (*env)->FindClass (env, "gnu/classpath/RawData32"); + rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer32"); + if (rawDataClass == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal class"); + return NULL; + } + rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(I)V"); + if (rawData_mid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal constructor"); + return NULL; + } + rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "I"); + if (rawData_fid == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to find internal field"); + return NULL; + } + #endif (*env)->DeleteLocalRef(env, rawDataClass); rawDataClass = (*env)->NewGlobalRef (env, rawDataClass); + if (rawDataClass == NULL) + { + JCL_ThrowException (env, "java/lang/InternalError", + "unable to create an internal global ref"); + return NULL; + } } #ifdef POINTERS_ARE_64BIT diff --git a/native/jni/classpath/jcl.h b/native/jni/classpath/jcl.h index c4b2c44a6..25662c06b 100644 --- a/native/jni/classpath/jcl.h +++ b/native/jni/classpath/jcl.h @@ -42,6 +42,14 @@ exception statement from your version. */ #include <jni.h> #include <config.h> +#if SIZEOF_VOID_P == 4 +typedef jint jpointer; +#elif SIZEOF_VOID_P == 8 +typedef jlong jpointer; +#else +#error "Unknown pointer size" +#endif + JNIEXPORT jclass JNICALL JCL_FindClass (JNIEnv * env, const char *className); JNIEXPORT void JNICALL JCL_ThrowException (JNIEnv * env, const char *className, 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 31b9f08d4..b64862c65 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 @@ -35,6 +35,7 @@ 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 "jcl.h" #include "gtkpeer.h" #include "gnu_java_awt_peer_gtk_GtkImage.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -573,24 +574,15 @@ static void createRawData (JNIEnv * env, jobject obj, void *ptr) { jclass cls; - jmethodID method; jobject data; jfieldID data_fid; cls = (*env)->GetObjectClass (env, obj); data_fid = (*env)->GetFieldID (env, cls, "pixmap", - "Lgnu/classpath/RawData;"); + "Lgnu/classpath/Pointer;"); g_assert (data_fid != 0); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - data = (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - data = (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + data = JCL_NewRawDataObject (env, ptr); (*env)->SetObjectField (env, obj, data_fid, data); } @@ -599,23 +591,14 @@ static void * getData (JNIEnv * env, jobject obj) { jclass cls; - jfieldID field; jfieldID data_fid; jobject data; cls = (*env)->GetObjectClass (env, obj); data_fid = (*env)->GetFieldID (env, cls, "pixmap", - "Lgnu/classpath/RawData;"); + "Lgnu/classpath/Pointer;"); g_assert (data_fid != 0); data = (*env)->GetObjectField (env, obj, data_fid); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, data, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, data, field); -#endif + return JCL_GetRawData (env, data); } diff --git a/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c b/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c index 9232ea49c..a9894994b 100644 --- a/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c +++ b/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c @@ -512,10 +512,8 @@ Java_gnu_java_nio_channels_FileChannelImpl_mapImpl (JNIEnv *env, jobject obj, { #ifdef HAVE_MMAP jclass MappedByteBufferImpl_class; - jclass RawData_class; jmethodID MappedByteBufferImpl_init = NULL; - jmethodID RawData_init = NULL; - jobject RawData_instance; + jobject Pointer_instance; volatile jobject buffer; long pagesize; int prot, flags; @@ -535,36 +533,10 @@ Java_gnu_java_nio_channels_FileChannelImpl_mapImpl (JNIEnv *env, jobject obj, return NULL; #endif /* HAVE_GETPAGESIZE/HAVE_SYSCONF */ -#if (SIZEOF_VOID_P == 4) - RawData_class = (*env)->FindClass (env, "gnu/classpath/RawData32"); - if (RawData_class != NULL) - { - RawData_init = (*env)->GetMethodID (env, RawData_class, - "<init>", "(I)V"); - } -#elif (SIZEOF_VOID_P == 8) - RawData_class = (*env)->FindClass (env, "gnu/classpath/RawData64"); - if (RawData_class != NULL) - { - RawData_init = (*env)->GetMethodID (env, RawData_class, - "<init>", "(J)V"); - } -#else - JCL_ThrowException (env, IO_EXCEPTION, - "pointer size not supported"); - return NULL; -#endif /* SIZEOF_VOID_P */ - if ((*env)->ExceptionOccurred (env)) { return NULL; } - if (RawData_init == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "could not get RawData constructor"); - return NULL; - } prot = PROT_READ; if (mode == '+') @@ -583,13 +555,7 @@ Java_gnu_java_nio_channels_FileChannelImpl_mapImpl (JNIEnv *env, jobject obj, down to a multiple of the page size. */ address = (void *) ((char *) p + (position % pagesize)); -#if (SIZEOF_VOID_P == 4) - RawData_instance = (*env)->NewObject (env, RawData_class, - RawData_init, (jint) address); -#elif (SIZEOF_VOID_P == 8) - RawData_instance = (*env)->NewObject (env, RawData_class, - RawData_init, (jlong) address); -#endif /* SIZEOF_VOID_P */ + Pointer_instance = JCL_NewRawDataObject(env, address); MappedByteBufferImpl_class = (*env)->FindClass (env, "java/nio/MappedByteBufferImpl"); @@ -597,7 +563,7 @@ Java_gnu_java_nio_channels_FileChannelImpl_mapImpl (JNIEnv *env, jobject obj, { MappedByteBufferImpl_init = (*env)->GetMethodID (env, MappedByteBufferImpl_class, - "<init>", "(Lgnu/classpath/RawData;IZ)V"); + "<init>", "(Lgnu/classpath/Pointer;IZ)V"); } if ((*env)->ExceptionOccurred (env)) @@ -614,7 +580,7 @@ Java_gnu_java_nio_channels_FileChannelImpl_mapImpl (JNIEnv *env, jobject obj, } buffer = (*env)->NewObject (env, MappedByteBufferImpl_class, - MappedByteBufferImpl_init, RawData_instance, + MappedByteBufferImpl_init, Pointer_instance, (jint) size, mode == 'r'); return buffer; #else @@ -851,17 +817,23 @@ Java_gnu_java_nio_channels_FileChannelImpl_lock (JNIEnv *env, jobject obj, flock.l_type = shared ? F_RDLCK : F_WRLCK; flock.l_whence = SEEK_SET; flock.l_start = (off_t) position; - flock.l_len = (off_t) size; + /* Long.MAX_VALUE means lock everything possible starting at pos. */ + if (size == 9223372036854775807LL) + flock.l_len = 0; + else + flock.l_len = (off_t) size; ret = fcntl (fd, cmd, &flock); + /* fprintf(stderr, "fd %d, wait %d, shared %d, ret %d, position %lld, size %lld, l_start %ld, l_len %ld\n", fd, wait, shared,ret, position, size, (long) flock.l_start, (long) flock.l_len); */ if (ret) { /* Linux man pages for fcntl state that errno might be either EACCES or EAGAIN if we try F_SETLK, and another process has - an overlapping lock. */ + an overlapping lock. We should not get an unexpected errno. */ if (errno != EACCES && errno != EAGAIN) { - JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + JCL_ThrowException (env, "java/lang/InternalError", + strerror (errno)); } return JNI_FALSE; } @@ -892,12 +864,17 @@ Java_gnu_java_nio_channels_FileChannelImpl_unlock (JNIEnv *env, flock.l_type = F_UNLCK; flock.l_whence = SEEK_SET; flock.l_start = (off_t) position; - flock.l_len = (off_t) length; + /* Long.MAX_VALUE means unlock everything possible starting at pos. */ + if (length == 9223372036854775807LL) + flock.l_len = 0; + else + flock.l_len = (off_t) length; ret = fcntl (fd, F_SETLK, &flock); if (ret) { - JCL_ThrowException (env, IO_EXCEPTION, strerror (errno)); + JCL_ThrowException (env, "java/lang/InternalError", + strerror (errno)); } #else (void) obj; diff --git a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c index 8c3f83acc..2541e81ea 100644 --- a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c +++ b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvDecoder.c @@ -173,23 +173,14 @@ static void createRawData (JNIEnv * env, jobject obj, void *ptr) { jclass cls; - jmethodID method; jobject data; jfieldID data_fid; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); -#ifdef POINTERS_ARE_64BIT - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - data = (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - data = (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + data = JCL_NewRawDataObject(env, ptr); (*env)->SetObjectField (env, obj, data_fid, data); } @@ -198,22 +189,13 @@ static void * getData (JNIEnv * env, jobject obj) { jclass cls; - jfieldID field; jfieldID data_fid; jobject data; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); data = (*env)->GetObjectField (env, obj, data_fid); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, data, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, data, field); -#endif + return JCL_GetRawData(env, data); } diff --git a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c index cd5d48656..7a98e7eee 100644 --- a/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c +++ b/native/jni/java-nio/gnu_java_nio_charset_iconv_IconvEncoder.c @@ -173,23 +173,14 @@ static void createRawData (JNIEnv * env, jobject obj, void *ptr) { jclass cls; - jmethodID method; jobject data; jfieldID data_fid; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); - -#ifdef POINTERS_ARE_64BIT - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - data = (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - data = (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + + data = JCL_NewRawDataObject (env, ptr); (*env)->SetObjectField (env, obj, data_fid, data); } @@ -198,22 +189,13 @@ static void * getData (JNIEnv * env, jobject obj) { jclass cls; - jfieldID field; jfieldID data_fid; jobject data; cls = (*env)->GetObjectClass (env, obj); - data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/RawData;"); + data_fid = (*env)->GetFieldID (env, cls, "data", "Lgnu/classpath/Pointer;"); assert (data_fid != 0); data = (*env)->GetObjectField (env, obj, data_fid); -#if SIZEOF_VOID_P == 8 - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, data, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, data, field); -#endif + return JCL_GetRawData(env, data); } diff --git a/native/jni/java-nio/java_nio_MappedByteBufferImpl.c b/native/jni/java-nio/java_nio_MappedByteBufferImpl.c index 9e23bb2ee..b49091982 100644 --- a/native/jni/java-nio/java_nio_MappedByteBufferImpl.c +++ b/native/jni/java-nio/java_nio_MappedByteBufferImpl.c @@ -57,8 +57,8 @@ exception statement from your version. */ /* FIXME these are defined in gnu_java_nio_channels_FileChannelImpl too; should be someplace common. */ -#define ALIGN_DOWN(p,s) ((p) - ((p) % (s))) -#define ALIGN_UP(p,s) ((p) + ((s) - ((p) % (s)))) +#define ALIGN_DOWN(p,s) ((jpointer)(p) - ((jpointer)(p) % (s))) +#define ALIGN_UP(p,s) ((jpointer)(p) + ((s) - ((jpointer)(p) % (s)))) /** * Returns the memory page size of this platform. @@ -97,14 +97,13 @@ get_raw_values (JNIEnv *env, jobject this, void **address, size_t *size) const long pagesize = get_pagesize (); jfieldID MappedByteBufferImpl_address; jfieldID MappedByteBufferImpl_size; - jfieldID RawData_data; jobject MappedByteBufferImpl_address_value = NULL; *address = NULL; /* 'address' is declared in java.nio.Buffer */ MappedByteBufferImpl_address = (*env)->GetFieldID (env, (*env)->GetObjectClass (env, this), - "address", "Lgnu/classpath/RawData;"); + "address", "Lgnu/classpath/Pointer;"); /* 'cap' -- likewise, the capacity */ MappedByteBufferImpl_size = (*env)->GetFieldID (env, (*env)->GetObjectClass (env, this), @@ -123,22 +122,8 @@ get_raw_values (JNIEnv *env, jobject this, void **address, size_t *size) return; } -#if (SIZEOF_VOID_P == 4) - RawData_data = - (*env)->GetFieldID (env, (*env)->GetObjectClass (env, MappedByteBufferImpl_address_value), - "data", "I"); *address = (void *) - ALIGN_DOWN ((*env)->GetIntField (env, MappedByteBufferImpl_address_value, - RawData_data), pagesize); -#elif (SIZEOF_VOID_P == 8) - RawData_data = - (*env)->GetFieldID (env, (*env)->GetObjectClass (env, MappedByteBufferImpl_address_value), - "data", "J"); - *address = (void *) - ALIGN_DOWN ((*env)->GetLongField (env, MappedByteBufferImpl_address_value, - RawData_data), pagesize); -#endif /* SIZEOF_VOID_P */ - + ALIGN_DOWN (JCL_GetRawData (env, MappedByteBufferImpl_address_value), pagesize); *size = (size_t) ALIGN_UP ((*env)->GetIntField (env, this, MappedByteBufferImpl_size), pagesize); diff --git a/native/jni/java-nio/java_nio_VMDirectByteBuffer.c b/native/jni/java-nio/java_nio_VMDirectByteBuffer.c index fec431cdc..06e29906a 100644 --- a/native/jni/java-nio/java_nio_VMDirectByteBuffer.c +++ b/native/jni/java-nio/java_nio_VMDirectByteBuffer.c @@ -45,106 +45,6 @@ exception statement from your version. */ #include "java_nio_VMDirectByteBuffer.h" -static jclass classRawData; -static jmethodID methodRawDataInit; -static jfieldID fieldNativePointer; - -static void *NIOGetPointer (JNIEnv *, jobject); -static jobject NIOGetRawData (JNIEnv *, void *pointer); - -static void * -NIOGetPointer (JNIEnv * env, jobject rawdata) -{ -#if SIZEOF_VOID_P == 4 - return (void *) (*env)->GetIntField (env, rawdata, fieldNativePointer); -#elif SIZEOF_VOID_P == 8 - return (void *) (*env)->GetLongField (env, rawdata, fieldNativePointer); -#else -#error unsupported pointer size -#endif -} - -static jobject -NIOGetRawData (JNIEnv * env, void *pointer) -{ -#if SIZEOF_VOID_P == 4 - return (*env)->NewObject (env, classRawData, methodRawDataInit, - (jint) pointer); -#elif SIZEOF_VOID_P == 8 - return (*env)->NewObject (env, classRawData, methodRawDataInit, - (jlong) pointer); -#else -#error unsupported pointer size -#endif -} - -JNIEXPORT void JNICALL -Java_java_nio_VMDirectByteBuffer_init - (JNIEnv * env, jclass clazz __attribute__ ((__unused__))) -{ -#if SIZEOF_VOID_P == 4 - classRawData = (*env)->FindClass (env, "gnu/classpath/RawData32"); - if (classRawData == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal class"); - return; - } - - methodRawDataInit = (*env)->GetMethodID (env, classRawData, - "<init>", "(I)V"); - if (methodRawDataInit == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal constructor"); - return; - } - - fieldNativePointer = (*env)->GetFieldID (env, classRawData, "data", "I"); - if (fieldNativePointer == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal field"); - return; - } -#elif SIZEOF_VOID_P == 8 - classRawData = (*env)->FindClass (env, "gnu/classpath/RawData64"); - if (classRawData == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal class"); - return; - } - - methodRawDataInit = (*env)->GetMethodID (env, classRawData, - "<init>", "(J)V"); - if (methodRawDataInit == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal constructor"); - return; - } - - fieldNativePointer = (*env)->GetFieldID (env, classRawData, "data", "J"); - if (fieldNativePointer == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "unable to find internal field"); - return; - } -#else -#error unsupported pointer size -#endif - - /* We need to wrap the jclass in global reference to make it persistent */ - if ((classRawData = (*env)->NewGlobalRef (env, classRawData)) == NULL) - { - JCL_ThrowException (env, "java/lang/InternalError", - "failed to create global reference"); - return; - } -} - JNIEXPORT jobject JNICALL Java_java_nio_VMDirectByteBuffer_allocate (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jint capacity) @@ -160,51 +60,51 @@ Java_java_nio_VMDirectByteBuffer_allocate return 0; } - return NIOGetRawData (env, buffer); + return JCL_NewRawDataObject (env, buffer); } JNIEXPORT void JNICALL Java_java_nio_VMDirectByteBuffer_free (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address) { - free (NIOGetPointer (env, address)); + free (JCL_GetRawData (env, address)); } JNIEXPORT jbyte JNICALL -Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I +Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_Pointer_2I (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint index) { - return ((jbyte *) NIOGetPointer (env, address))[index]; + return ((jbyte *) JCL_GetRawData (env, address))[index]; } JNIEXPORT void JNICALL -Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_RawData_2IB +Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_Pointer_2IB (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint index, jbyte value) { - jbyte *pointer = (jbyte *) NIOGetPointer (env, address) + index; + jbyte *pointer = (jbyte *) JCL_GetRawData (env, address) + index; *pointer = value; } JNIEXPORT void JNICALL -Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_RawData_2I_3BII +Java_java_nio_VMDirectByteBuffer_get__Lgnu_classpath_Pointer_2I_3BII (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint index, jbyteArray dst, jint dst_offset, jint dst_len) { - jbyte *src = (jbyte *) NIOGetPointer (env, address) + index; + jbyte *src = (jbyte *) JCL_GetRawData (env, address) + index; jbyte *_dst = (*env)->GetByteArrayElements (env, dst, NULL) + dst_offset; memcpy (_dst, src, dst_len); (*env)->ReleaseByteArrayElements (env, dst, _dst, 0); } JNIEXPORT void JNICALL -Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_RawData_2I_3BII +Java_java_nio_VMDirectByteBuffer_put__Lgnu_classpath_Pointer_2I_3BII (JNIEnv *env, jclass clazz __attribute__ ((__unused__)), jobject address, jint index, jbyteArray src, jint src_offset, jint src_len) { jbyte *_src = (*env)->GetByteArrayElements (env, src, NULL) + src_offset; - jbyte *dst = (jbyte *) NIOGetPointer (env, address) + index; + jbyte *dst = (jbyte *)JCL_GetRawData (env, address) + index; (*env)->ReleaseByteArrayElements (env, src, _src, 0); memcpy (dst, _src, src_len); } @@ -214,8 +114,8 @@ Java_java_nio_VMDirectByteBuffer_shiftDown (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint dst_offset, jint src_offset, jint count) { - jbyte *dst = (jbyte *) NIOGetPointer (env, address) + dst_offset; - jbyte *src = (jbyte *) NIOGetPointer (env, address) + src_offset; + jbyte *dst = (jbyte *) JCL_GetRawData (env, address) + dst_offset; + jbyte *src = (jbyte *) JCL_GetRawData (env, address) + src_offset; memmove (dst, src, count); } @@ -224,5 +124,5 @@ Java_java_nio_VMDirectByteBuffer_adjustAddress (JNIEnv * env, jclass clazz __attribute__ ((__unused__)), jobject address, jint offset) { - return NIOGetRawData (env, (jbyte *) NIOGetPointer (env, address) + offset); + return JCL_NewRawDataObject (env, (jbyte *) JCL_GetRawData (env, address) + offset); } diff --git a/native/jni/xmlj/xmlj_util.c b/native/jni/xmlj/xmlj_util.c index 498cb7092..409eb6e75 100644 --- a/native/jni/xmlj/xmlj_util.c +++ b/native/jni/xmlj/xmlj_util.c @@ -39,6 +39,7 @@ exception statement from your version. */ #include "xmlj_error.h" #include <libxml/tree.h> #include <unistd.h> +#include <jcl.h> /* xmlChar->jstring cache */ #ifdef XMLJ_STRING_CACHE @@ -218,35 +219,13 @@ jmethodID xmljGetMethodID (JNIEnv *env, void * xmljAsPointer (JNIEnv *env, jobject ptr) { - jclass cls; - jfieldID field; - -#if defined XMLJ_64BIT_POINTER - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - field = (*env)->GetFieldID (env, cls, "data", "J"); - return (void *) (*env)->GetLongField (env, ptr, field); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - field = (*env)->GetFieldID (env, cls, "data", "I"); - return (void *) (*env)->GetIntField (env, ptr, field); -#endif + return JCL_GetRawData(env, ptr); } jobject xmljAsField (JNIEnv *env, void * ptr) { - jclass cls; - jmethodID method; - -#if defined XMLJ_64BIT_POINTER - cls = (*env)->FindClass (env, "gnu/classpath/RawData64"); - method = (*env)->GetMethodID (env, cls, "<init>", "(J)V"); - return (*env)->NewObject (env, cls, method, (jlong) ptr); -#else - cls = (*env)->FindClass (env, "gnu/classpath/RawData32"); - method = (*env)->GetMethodID (env, cls, "<init>", "(I)V"); - return (*env)->NewObject (env, cls, method, (jint) ptr); -#endif + return JCL_NewRawDataObject(env, ptr); } JNIEnv * diff --git a/org/omg/DynamicAny/DynAny.java b/org/omg/DynamicAny/DynAny.java index 7e26ce505..fd2336310 100644 --- a/org/omg/DynamicAny/DynAny.java +++ b/org/omg/DynamicAny/DynAny.java @@ -1,6 +1,5 @@ /* DynAny.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 @@ -66,7 +65,7 @@ import org.omg.CORBA.portable.IDLEntity; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynAny extends DynAnyOperations, IDLEntity, - org.omg.CORBA.Object, Serializable +public interface DynAny + extends DynAnyOperations, IDLEntity, org.omg.CORBA.Object, Serializable { }
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynAnyFactory.java b/org/omg/DynamicAny/DynAnyFactory.java new file mode 100644 index 000000000..5d4cc7249 --- /dev/null +++ b/org/omg/DynamicAny/DynAnyFactory.java @@ -0,0 +1,55 @@ +/* DynAnyFactory.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.DynamicAny; + +import java.io.Serializable; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * Produces DynAnys from Anys or typecodes. The produced DynAnys are initialized + * to they agreed default values. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynAnyFactory + extends DynAnyFactoryOperations, IDLEntity, org.omg.CORBA.Object, + Serializable +{ +} diff --git a/org/omg/DynamicAny/DynAnyFactoryHelper.java b/org/omg/DynamicAny/DynAnyFactoryHelper.java new file mode 100644 index 000000000..b6fd15151 --- /dev/null +++ b/org/omg/DynamicAny/DynAnyFactoryHelper.java @@ -0,0 +1,173 @@ +/* DynAnyFactoryHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynAnyFactory}. Following the 1.5 JDK + * specifications, DynAnyFactory is always a local object, so the two methods of + * this helper ({@link #read} and {@link #write} are not in use, always + * throwing {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynAnyFactoryHelper +{ + /** + * Cast the passed object into the DynAnyFactory. As DynAnyFactory is a local + * object, the method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynAnyFactory. + */ + public static DynAnyFactory narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynAnyFactory) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + + " is not a DynAnyFactory"); + } + } + + /** + * Get the type code of the {@link DynAnyFactory}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynAnyFactory"); + } + + /** + * Insert the DynAnyFactory into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynAnyFactory to insert. + */ + public static void insert(Any any, DynAnyFactory that) + { + any.insert_Object(that); + } + + /** + * Extract the DynAnyFactory from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynAnyFactory. + */ + public static DynAnyFactory extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynAnyFactory repository id. + * + * @return "IDL:omg.org/DynamicAny/DynAnyFactory:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynAnyFactory:1.0"; + } + + /** + * This should read DynAnyFactory from the CDR input stream, but (following + * the JDK 1.5 API) it does not. The factory can only be obtained from the + * ORB. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynAnyFactory read(InputStream input) + { + throw new MARSHAL(not_applicable(id())); + } + + /** + * This should read DynAnyFactory from the CDR input stream, but (following + * the JDK 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynAnyFactory value) + { + throw new MARSHAL(not_applicable(id())); + } + + /** + * The package level method for throwing exception, explaining that the + * operation is not applicable. + * + * @param Id the Id for the typecode for that the operations was attempted to + * perform. + */ + static String not_applicable(String Id) + { + try + { + throw new MARSHAL("The read/write are not applicable for " + Id); + } + catch (Exception e) + { + throw new MARSHAL(); + } + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynAnyFactoryOperations.java b/org/omg/DynamicAny/DynAnyFactoryOperations.java new file mode 100644 index 000000000..c3ea4a9dc --- /dev/null +++ b/org/omg/DynamicAny/DynAnyFactoryOperations.java @@ -0,0 +1,148 @@ +/* DynAnyFactoryOperations.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.DynamicAny; + +import org.omg.CORBA.Any; +import org.omg.CORBA.TypeCode; +import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode; + +/** + * Defines the operations, applicable for DynAnyFactory. These operations + * produce new DynAny's either from Any, serving as a template and value + * provider, or from the given typecode. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynAnyFactoryOperations +{ + /** + * Create DynAny for holding the data of the given type. The returned DynAny + * is initialised to its agreed default value. The agreed default values are: + * <table border='1'> + * <tr> + * <th>Type</th> + * <th>Value</th> + * <th>Creates</th> + * </tr> + * + * <tr> + * <td>boolean</td> + * <td>false</td> + * <td>{@link DynAny}</td> + * </tr> + * <tr> + * <td>numeric types, octet, fixed</td> + * <td>0</td> + * <td>{@link DynAny}</td> + * </tr> + * <tr> + * <td>char, wchar</td> + * <td>(char) 0</td> + * <td>{@link DynAny}</td> + * </tr> + * <tr> + * <td>string, wstring</td> + * <td>empty string ("", not <code>null<code>)</td> + * <td>{@link DynAny}</td> + * </tr> + * <tr> + * <td>{@link Any}</td> + * <td>{@link Any} with no value and typecode of kind {@link TCKind.tk_null}</td> + * <td>{@link DynAny}</td> + * </tr> + * <tr> + * <td>Sequence</td> + * <td>Empty (zero size) sequence</td> + * <td>{@link DynSequence}</td> + * </tr> + * <tr> + * <td>Array</td> + * <td>All members of array are recursively initialised to default values.</td> + * <td>{@link DynArray}</td> + * </tr> + * <tr> + * <td>Structure, exception</td> + * <td>All fields of the structure (if any) are recursively initialised to + * default values.</td> + * <td>{@link DynStruct}</td> + * </tr> + * <tr> + * <td>Enumeration</td> + * <td>Default value, indicated by typecode.</td> + * <td>{@link DynEnum}</td> + * </tr> + * <tr> + * <td>Union</td> + * <td>Default variant (indicated by typecode), recursively initialised to + * its default value.</td> + * <td>{@link DynUnion}</td> + * </tr> + * <tr> + * <td>Value, ValueBox</td> + * <td>null</td> + * <td>{@link DynValue}, {@link DynValueBox}</td> + * </tr> + * + * </table> + * + * @param type the type of the data being stored. + * + * @return the created DynAny, having the passed type. + * + * @throws InconsistentTypeCode if type.kind() is tk_Principal, tk_native or + * tk_abstract_interface. These types cannot be stored in DynAny. + */ + DynAny create_dyn_any_from_type_code(TypeCode type) + throws InconsistentTypeCode; + + /** + * Create DynAny using the given Any as template. + * + * @param value the Any, providing type and value for the DynAny being + * created. + * + * @return the created DynAny, having the same type and storing the same value + * as the passed Any. + * + * @throws InconsistentTypeCode if value.type().kind() is tk_Principal, + * tk_native or tk_abstract_interface. These types cannot be stored in DynAny. + */ + DynAny create_dyn_any(Any value) + throws InconsistentTypeCode; +} diff --git a/org/omg/DynamicAny/DynAnyHelper.java b/org/omg/DynamicAny/DynAnyHelper.java new file mode 100644 index 000000000..ca48cd4c5 --- /dev/null +++ b/org/omg/DynamicAny/DynAnyHelper.java @@ -0,0 +1,152 @@ +/* DynAnyHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynAny}. Following the 1.5 JDK + * specifications, DynAny is always a local object, so the two methods of this + * helper ({@link #read} and {@link #write} are not in use, always throwing + * {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynAnyHelper +{ + /** + * Cast the passed object into the DynAny. As DynAny is a local object, the + * method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynAny. + */ + public static DynAny narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynAny) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynAny"); + } + } + + /** + * Get the type code of the {@link DynAny}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynAny"); + } + + /** + * Insert the DynAny into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynAny to insert. + */ + public static void insert(Any any, DynAny that) + { + any.insert_Object(that); + } + + /** + * Extract the DynAny from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynAny. + */ + public static DynAny extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynAny repository id. + * + * @return "IDL:omg.org/DynamicAny/DynAny:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynAny:1.0"; + } + + /** + * This should read DynAny from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynAny read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynAny from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynAny value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynAnyOperations.java b/org/omg/DynamicAny/DynAnyOperations.java index 1e9aac5cc..67e356cfe 100644 --- a/org/omg/DynamicAny/DynAnyOperations.java +++ b/org/omg/DynamicAny/DynAnyOperations.java @@ -1,6 +1,5 @@ /* DynAnyOperations.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 @@ -60,7 +59,7 @@ public interface DynAnyOperations * @throws TypeMismatch if the source DynAny is invalid. */ void assign(DynAny from) - throws TypeMismatch, InvalidValue; + throws TypeMismatch; /** * Fully clones the content of this Any, returning a deep copy. @@ -73,8 +72,12 @@ public interface DynAnyOperations * DynAny can be used to get or set the value of the focused component. If the * DynAny holds a primitive type with no components, this implementation * returns <code>null</code>. + * + * @throws TypeMismatch if called on DynAny that cannot have active + * components, like {@link DynEnum}. */ - DynAny current_component(); + DynAny current_component() + throws TypeMismatch; /** * Destroys this DynAny, freeing the used resources. In java, resources are @@ -95,7 +98,7 @@ public interface DynAnyOperations * otherwise invalid. */ void from_any(Any an_any) - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * This method is used when the wrapped Any contains an instance of another @@ -105,7 +108,7 @@ public interface DynAnyOperations * the typecode of this DynAny. */ Any get_any() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the boolean value that is expected to be stored in this DynAny. @@ -113,7 +116,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ boolean get_boolean() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the char value that is expected to be stored in this DynAny. @@ -121,7 +124,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ char get_char() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the <code>double</code> value that is expected to be stored in @@ -130,7 +133,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ double get_double() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the <code>float</code> value that is expected to be stored in @@ -139,7 +142,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ float get_float() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the int (CORBA long) value that is expected to be stored in this @@ -148,7 +151,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ int get_long() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the long (CORBA long long) value that is expected to be stored in @@ -157,7 +160,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ long get_longlong() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the byte (CORBA octet) value that is expected to be stored in this @@ -166,7 +169,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ byte get_octet() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the CORBA object reference that is expected to be stored in this @@ -175,7 +178,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ org.omg.CORBA.Object get_reference() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the <code>short</code> value that is expected to be stored in @@ -184,7 +187,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ short get_short() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the string value that is expected to be stored in this DynAny. @@ -192,7 +195,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ String get_string() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the {@link TypeCode} value that is expected to be stored in this @@ -201,7 +204,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ TypeCode get_typecode() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the unsigned int (CORBA ulong) value that is expected to be stored @@ -210,7 +213,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ int get_ulong() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the unsingel long (CORBA unsigned long long )value that is expected @@ -219,7 +222,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ long get_ulonglong() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the unsigned short value that is expected to be stored in this @@ -228,7 +231,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ short get_ushort() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the value that is expected to be stored in this DynAny. @@ -236,7 +239,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ Serializable get_val() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the wide (usually UTF-16) character value that is expected to be @@ -245,7 +248,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ char get_wchar() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Extract the wide (usually UFT-16) string that is expected to be stored in @@ -254,7 +257,7 @@ public interface DynAnyOperations * @throws TypeMismatch if this DynAny holds the value of the different type. */ String get_wstring() - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Insert the {@link Any} value into the enclosed {@link Any} inside this @@ -265,7 +268,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_any(Any an_any) - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Insert the boolean value into the enclosed {@link Any} inside this DynAny @@ -275,7 +278,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_boolean(boolean a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the char value into the enclosed {@link Any} inside this DynAny @@ -285,7 +288,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_char(char a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the double value into the enclosed {@link Any} inside this DynAny @@ -295,7 +298,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_double(double a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the float value into the enclosed {@link Any} inside this DynAny @@ -305,7 +308,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_float(float a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the int (CORBA long) value into the enclosed {@link Any} inside this @@ -316,7 +319,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_long(int a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the long (CORBA long long) value into the enclosed {@link Any} @@ -327,7 +330,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_longlong(long a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the byte (CORBA octet) value into the enclosed {@link Any} inside @@ -338,7 +341,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_octet(byte a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the object reference into the enclosed {@link Any} inside this @@ -349,7 +352,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_reference(org.omg.CORBA.Object a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the <code>short</code> value into the enclosed {@link Any} inside @@ -360,7 +363,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_short(short a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the string value into the enclosed {@link Any} inside this DynAny @@ -370,7 +373,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_string(String a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the {@link TypeCode} value into the enclosed {@link Any} inside this @@ -381,7 +384,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_typecode(TypeCode a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the int (CORBA unsinged long) value into the enclosed {@link Any} @@ -392,7 +395,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_ulong(int a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the long (CORBA unsigned long long) value into the enclosed @@ -403,7 +406,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_ulonglong(long a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the short (CORBA unsigned short) value into the enclosed {@link Any} @@ -414,7 +417,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_ushort(short a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the value into the enclosed {@link Any} inside this DynAny @@ -424,7 +427,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_val(Serializable a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the wide char (usually UTF-16) value into the enclosed {@link Any} @@ -435,7 +438,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_wchar(char a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Insert the wide string (usually UTF-16) into the enclosed {@link Any} @@ -446,7 +449,7 @@ public interface DynAnyOperations * enclosed {@link Any}. */ void insert_wstring(String a_x) - throws InvalidValue, TypeMismatch; + throws InvalidValue, TypeMismatch; /** * Advances the internal pointer, described in the {@link current_component}, @@ -481,8 +484,7 @@ public interface DynAnyOperations * * @return shallow copy of the enclosed {@link Any}. */ - Any to_any() - throws TypeMismatch; + Any to_any(); /** * Returns the typecode of the object, inserted into this DynAny. @@ -501,17 +503,17 @@ public interface DynAnyOperations * @throws InvalidValue if the current position points nowhere. */ void insert_dyn_any(DynAny insert_it) - throws TypeMismatch, InvalidValue; + throws TypeMismatch, InvalidValue; /** * Checks for equality with another Dynamic Any. * * * @specnote This method is currently only implemented only for case when - * another DynAny was created by the factory of this implementation and - * is not an independent class, just implementing interface. Otherwise, - * a NO_IMPLEMENT minor 8148 will be thrown. General implementation is - * highly ineffective, but we will do if somebody would ever need it. + * another DynAny was created by the factory of this implementation and is not + * an independent class, just implementing interface. Otherwise, a + * NO_IMPLEMENT minor 8148 will be thrown. General implementation is highly + * ineffective, but we will do if somebody would ever need it. */ boolean equal(DynAny other); @@ -534,5 +536,5 @@ public interface DynAnyOperations * @throws InvalidValue if the current position points nowhere. */ DynAny get_dyn_any() - throws TypeMismatch, InvalidValue; -}
\ No newline at end of file + throws TypeMismatch, InvalidValue; +} diff --git a/org/omg/DynamicAny/DynArray.java b/org/omg/DynamicAny/DynArray.java index f2285970a..30b556acf 100644 --- a/org/omg/DynamicAny/DynArray.java +++ b/org/omg/DynamicAny/DynArray.java @@ -1,6 +1,5 @@ /* DynArray.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 @@ -43,11 +42,13 @@ import java.io.Serializable; import org.omg.CORBA.portable.IDLEntity; /** - * Represents a fixed size array. All components in the array have the same type. + * Represents a fixed size array. All components in the array have the same + * type. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynArray extends DynArrayOperations, DynAny, IDLEntity, - org.omg.CORBA.Object, Serializable +public interface DynArray + extends DynArrayOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable { } diff --git a/org/omg/DynamicAny/DynArrayHelper.java b/org/omg/DynamicAny/DynArrayHelper.java new file mode 100644 index 000000000..0372b5851 --- /dev/null +++ b/org/omg/DynamicAny/DynArrayHelper.java @@ -0,0 +1,151 @@ +/* DynArrayHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynArray}. Following the 1.5 JDK + * specifications, DynArray is always a local object, so the two methods of this + * helper ({@link #read} and {@link #write} are not in use, always throwing + * {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynArrayHelper +{ + /** + * Cast the passed object into the DynArray. As DynArray is a local object, + * the method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynArray. + */ + public static DynArray narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynArray) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynArray"); + } + } + + /** + * Get the type code of the {@link DynArray}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynArray"); + } + + /** + * Insert the DynArray into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynArray to insert. + */ + public static void insert(Any any, DynArray that) + { + any.insert_Object(that); + } + + /** + * Extract the DynArray from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynArray. + */ + public static DynArray extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynArray repository id. + * + * @return "IDL:omg.org/DynamicAny/DynArray:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynArray:1.0"; + } + + /** + * This should read DynArray from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynArray read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynArray from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynArray value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynArrayOperations.java b/org/omg/DynamicAny/DynArrayOperations.java index c1cf2e428..18693039b 100644 --- a/org/omg/DynamicAny/DynArrayOperations.java +++ b/org/omg/DynamicAny/DynArrayOperations.java @@ -1,6 +1,5 @@ /* DynArrayOperations.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 @@ -47,7 +46,8 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynArrayOperations extends DynAnyOperations +public interface DynArrayOperations + extends DynAnyOperations { /** * Returns the array. @@ -68,25 +68,26 @@ public interface DynArrayOperations extends DynAnyOperations * * @param value the array of elements an DynAny's. * - * @throws TypeMismatch if the members of the passed array does not - * match array component type. + * @throws TypeMismatch if the members of the passed array does not match + * array component type. * - * @throws InvalidValue if the number of elements in the passed array - * is not the same as the size of this DynArray. + * @throws InvalidValue if the number of elements in the passed array is not + * the same as the size of this DynArray. */ - void set_elements_as_dyn_any(DynAny[] value) throws TypeMismatch, - InvalidValue; + void set_elements_as_dyn_any(DynAny[] value) + throws TypeMismatch, InvalidValue; /** * Sets the array. * * @param value the array of elements as Any's. * - * @throws TypeMismatch if the members of the passed array does not - * match array component type. + * @throws TypeMismatch if the members of the passed array does not match + * array component type. * - * @throws InvalidValue if the number of elements in the passed array - * is not the same as the size of this DynArray. + * @throws InvalidValue if the number of elements in the passed array is not + * the same as the size of this DynArray. */ - void set_elements(Any[] value) throws TypeMismatch, InvalidValue; + void set_elements(Any[] value) + throws TypeMismatch, InvalidValue; } diff --git a/org/omg/DynamicAny/DynEnum.java b/org/omg/DynamicAny/DynEnum.java index b37931fa2..6f71bb8f8 100644 --- a/org/omg/DynamicAny/DynEnum.java +++ b/org/omg/DynamicAny/DynEnum.java @@ -1,6 +1,5 @@ /* DynEnum.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 @@ -50,7 +49,8 @@ import org.omg.CORBA.portable.IDLEntity; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynEnum extends DynEnumOperations, DynAny, IDLEntity, - org.omg.CORBA.Object, Serializable +public interface DynEnum + extends DynEnumOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable { } diff --git a/org/omg/DynamicAny/DynEnumHelper.java b/org/omg/DynamicAny/DynEnumHelper.java new file mode 100644 index 000000000..944d43757 --- /dev/null +++ b/org/omg/DynamicAny/DynEnumHelper.java @@ -0,0 +1,152 @@ +/* DynEnumHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynEnum}. Following the 1.5 JDK + * specifications, DynEnum is always a local object, so the two methods of this + * helper ({@link #read} and {@link #write} are not in use, always throwing + * {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynEnumHelper +{ + /** + * Cast the passed object into the DynEnum. As DynEnum is a local object, the + * method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynEnum. + */ + public static DynEnum narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynEnum) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynEnum"); + } + } + + /** + * Get the type code of the {@link DynEnum}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynEnum"); + } + + /** + * Insert the DynEnum into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynEnum to insert. + */ + public static void insert(Any any, DynEnum that) + { + any.insert_Object(that); + } + + /** + * Extract the DynEnum from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynEnum. + */ + public static DynEnum extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynEnum repository id. + * + * @return "IDL:omg.org/DynamicAny/DynEnum:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynEnum:1.0"; + } + + /** + * This should read DynEnum from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynEnum read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynEnum from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynEnum value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynEnumOperations.java b/org/omg/DynamicAny/DynEnumOperations.java index 0ac4d78cd..3bc3ae208 100644 --- a/org/omg/DynamicAny/DynEnumOperations.java +++ b/org/omg/DynamicAny/DynEnumOperations.java @@ -1,6 +1,5 @@ /* DynEnumOperations.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 @@ -50,6 +49,7 @@ import org.omg.DynamicAny.DynAnyPackage.InvalidValue; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public interface DynEnumOperations + extends DynAnyOperations { /** * Get the current enumeration value, as string. @@ -67,7 +67,8 @@ public interface DynEnumOperations * @throws InvalidValue if the passed string is not one of the allowed values * for this enumeration. */ - void set_as_string(String value) throws InvalidValue; + void set_as_string(String value) + throws InvalidValue; /** * Set the current enumeration value, as int. @@ -75,6 +76,7 @@ public interface DynEnumOperations * @throws InvalidValue if the passed string is not one of the allowed values * for this enumeration. */ - void set_as_ulong(int value) throws InvalidValue; + void set_as_ulong(int value) + throws InvalidValue; } diff --git a/org/omg/DynamicAny/DynFixed.java b/org/omg/DynamicAny/DynFixed.java index 3561b01df..65aa98f15 100644 --- a/org/omg/DynamicAny/DynFixed.java +++ b/org/omg/DynamicAny/DynFixed.java @@ -1,6 +1,5 @@ /* DynFixed.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 @@ -49,7 +48,8 @@ import org.omg.CORBA.portable.IDLEntity; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynFixed extends DynFixedOperations, DynAny, IDLEntity, - org.omg.CORBA.Object, Serializable +public interface DynFixed + extends DynFixedOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable { } diff --git a/org/omg/DynamicAny/DynFixedHelper.java b/org/omg/DynamicAny/DynFixedHelper.java new file mode 100644 index 000000000..1d818d7b1 --- /dev/null +++ b/org/omg/DynamicAny/DynFixedHelper.java @@ -0,0 +1,152 @@ +/* DynFixedHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynFixed}. Following the 1.5 JDK + * specifications, DynFixed is always a local object, so the two methods of this + * helper ({@link #read} and {@link #write} are not in use, always throwing + * {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynFixedHelper +{ + /** + * Cast the passed object into the DynFixed. As DynFixed is a local object, + * the method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynFixed. + */ + public static DynFixed narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynFixed) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynFixed"); + } + } + + /** + * Get the type code of the {@link DynFixed}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynFixed"); + } + + /** + * Insert the DynFixed into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynFixed to insert. + */ + public static void insert(Any any, DynFixed that) + { + any.insert_Object(that); + } + + /** + * Extract the DynFixed from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynFixed. + */ + public static DynFixed extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynFixed repository id. + * + * @return "IDL:omg.org/DynamicAny/DynFixed:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynFixed:1.0"; + } + + /** + * This should read DynFixed from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynFixed read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynFixed from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynFixed value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynFixedOperations.java b/org/omg/DynamicAny/DynFixedOperations.java index 1178e7c92..e8c69a768 100644 --- a/org/omg/DynamicAny/DynFixedOperations.java +++ b/org/omg/DynamicAny/DynFixedOperations.java @@ -1,6 +1,5 @@ /* DynFixedOperations.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 @@ -48,6 +47,7 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public interface DynFixedOperations + extends DynAnyOperations { /** * Get the value of the enclosed DynFixed, as string. @@ -66,5 +66,6 @@ public interface DynFixedOperations * @return true if the passed value can be represented without the loss of * precision, false if some fractional digits were truncated. */ - boolean set_value(String fixed_value) throws TypeMismatch, InvalidValue; + boolean set_value(String fixed_value) + throws TypeMismatch, InvalidValue; } diff --git a/org/omg/DynamicAny/DynSequence.java b/org/omg/DynamicAny/DynSequence.java index bde3a418e..08c7b527e 100644 --- a/org/omg/DynamicAny/DynSequence.java +++ b/org/omg/DynamicAny/DynSequence.java @@ -1,6 +1,5 @@ /* DynSequence.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 @@ -48,7 +47,8 @@ import org.omg.CORBA.portable.IDLEntity; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynSequence extends DynSequenceOperations, DynAny, IDLEntity, - org.omg.CORBA.Object, Serializable +public interface DynSequence + extends DynSequenceOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable { } diff --git a/org/omg/DynamicAny/DynSequenceHelper.java b/org/omg/DynamicAny/DynSequenceHelper.java new file mode 100644 index 000000000..c38a51f09 --- /dev/null +++ b/org/omg/DynamicAny/DynSequenceHelper.java @@ -0,0 +1,151 @@ +/* DynSequenceHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynSequence}. Following the 1.5 JDK + * specifications, DynSequence is always a local object, so the two methods of + * this helper ({@link #read} and {@link #write} are not in use, always + * throwing {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynSequenceHelper +{ + /** + * Cast the passed object into the DynSequence. As DynSequence is a local + * object, the method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynSequence. + */ + public static DynSequence narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynSequence) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynSequence"); + } + } + + /** + * Get the type code of the {@link DynSequence}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynSequence"); + } + + /** + * Insert the DynSequence into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynSequence to insert. + */ + public static void insert(Any any, DynSequence that) + { + any.insert_Object(that); + } + + /** + * Extract the DynSequence from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynSequence. + */ + public static DynSequence extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynSequence repository id. + * + * @return "IDL:omg.org/DynamicAny/DynSequence:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynSequence:1.0"; + } + + /** + * This should read DynSequence from the CDR input stream, but (following the + * JDK 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynSequence read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynSequence from the CDR input stream, but (following the + * JDK 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynSequence value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynSequenceOperations.java b/org/omg/DynamicAny/DynSequenceOperations.java index 8c295dbbb..77cd28383 100644 --- a/org/omg/DynamicAny/DynSequenceOperations.java +++ b/org/omg/DynamicAny/DynSequenceOperations.java @@ -1,6 +1,5 @@ /* DynSequenceOperations.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 @@ -53,6 +52,7 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public interface DynSequenceOperations + extends DynAnyOperations { /** * Get the length of the sequence. @@ -74,7 +74,8 @@ public interface DynSequenceOperations * @throws InvalidValue if this is a bounded sequence, and the size being set * exceeds the sequence bound. */ - public void set_length(int length) throws InvalidValue; + public void set_length(int length) + throws InvalidValue; /** * Returns the array, containing the sequence elements. @@ -102,8 +103,8 @@ public interface DynSequenceOperations * @throws InvalidValue if this is a bounded sequence and the number of * elements in the passed array exceeds the sequence bound. */ - void set_elements_as_dyn_any(DynAny[] value) throws TypeMismatch, - InvalidValue; + void set_elements_as_dyn_any(DynAny[] value) + throws TypeMismatch, InvalidValue; /** * Sets the sequence elements from the array. The length of the sequence is @@ -118,5 +119,6 @@ public interface DynSequenceOperations * @throws InvalidValue if this is a bounded sequence and the number of * elements in the passed array exceeds the sequence bound. */ - void set_elements(Any[] value) throws TypeMismatch, InvalidValue; + void set_elements(Any[] value) + throws TypeMismatch, InvalidValue; } diff --git a/org/omg/DynamicAny/DynStruct.java b/org/omg/DynamicAny/DynStruct.java index b7b900a0d..540537547 100644 --- a/org/omg/DynamicAny/DynStruct.java +++ b/org/omg/DynamicAny/DynStruct.java @@ -1,6 +1,5 @@ /* DynStruct.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 @@ -43,12 +42,13 @@ import java.io.Serializable; import org.omg.CORBA.portable.IDLEntity; /** - * Defines a fixed size structure with the named fields that may have - * different types. + * Defines a fixed size structure with the named fields that may have different + * types. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynStruct extends DynStructOperations, DynAny, IDLEntity, - org.omg.CORBA.Object, Serializable +public interface DynStruct + extends DynStructOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable { } diff --git a/org/omg/DynamicAny/DynStructHelper.java b/org/omg/DynamicAny/DynStructHelper.java new file mode 100644 index 000000000..e4790b443 --- /dev/null +++ b/org/omg/DynamicAny/DynStructHelper.java @@ -0,0 +1,151 @@ +/* DynStructHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynStruct}. Following the 1.5 JDK + * specifications, DynStruct is always a local object, so the two methods of + * this helper ({@link #read} and {@link #write} are not in use, always + * throwing {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynStructHelper +{ + /** + * Cast the passed object into the DynStruct. As DynStruct is a local object, + * the method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynStruct. + */ + public static DynStruct narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynStruct) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynStruct"); + } + } + + /** + * Get the type code of the {@link DynStruct}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynStruct"); + } + + /** + * Insert the DynStruct into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynStruct to insert. + */ + public static void insert(Any any, DynStruct that) + { + any.insert_Object(that); + } + + /** + * Extract the DynStruct from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynStruct. + */ + public static DynStruct extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynStruct repository id. + * + * @return "IDL:omg.org/DynamicAny/DynStruct:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynStruct:1.0"; + } + + /** + * This should read DynStruct from the CDR input stream, but (following the + * JDK 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynStruct read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynStruct from the CDR input stream, but (following the + * JDK 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynStruct value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynStructOperations.java b/org/omg/DynamicAny/DynStructOperations.java index 303adae3d..3b5af1710 100644 --- a/org/omg/DynamicAny/DynStructOperations.java +++ b/org/omg/DynamicAny/DynStructOperations.java @@ -1,6 +1,5 @@ /* DynStructOperations.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 @@ -47,7 +46,8 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynStructOperations extends DynAnyOperations +public interface DynStructOperations + extends DynAnyOperations { /** * Get the kind of the structure field at the current position. @@ -57,7 +57,8 @@ public interface DynStructOperations extends DynAnyOperations * @throws TypeMismatch for an empty structure (normally exception). * @throws InvalidValue if the current position does not indicate a memeber. */ - TCKind current_member_kind() throws TypeMismatch, InvalidValue; + TCKind current_member_kind() + throws TypeMismatch, InvalidValue; /** * Get the name of the structure field at the current position. @@ -67,7 +68,8 @@ public interface DynStructOperations extends DynAnyOperations * @throws TypeMismatch for an empty structure (normally exception). * @throws InvalidValue if the current position does not indicate a memeber. */ - String current_member_name() throws TypeMismatch, InvalidValue; + String current_member_name() + throws TypeMismatch, InvalidValue; /** * Return array, describing describing the name and the value of each member @@ -102,14 +104,14 @@ public interface DynStructOperations extends DynAnyOperations * @param an array of NameDynValuePair's, each defining a single field in the * structure. * - * @throws TypeMismatch if the member of the passed array has a different - * type than the corresponding structure field. + * @throws TypeMismatch if the member of the passed array has a different type + * than the corresponding structure field. * * @throws InvalidValue if the size of the passed array is not the same as the * number of fields in this structure. */ - void set_members_as_dyn_any(NameDynAnyPair[] value) throws TypeMismatch, - InvalidValue; + void set_members_as_dyn_any(NameDynAnyPair[] value) + throws TypeMismatch, InvalidValue; /** * Set the structure contend from the array, where each member defines the @@ -126,12 +128,13 @@ public interface DynStructOperations extends DynAnyOperations * @param an array of NameValuePair's, each defining a single field in the * structure. * - * @throws TypeMismatch if the member of the passed array has a different - * type than the corresponding structure field. + * @throws TypeMismatch if the member of the passed array has a different type + * than the corresponding structure field. * * @throws InvalidValue if the size of the passed array is not the same as the * number of fields in this structure. */ - void set_members(NameValuePair[] value) throws TypeMismatch, InvalidValue; + void set_members(NameValuePair[] value) + throws TypeMismatch, InvalidValue; } diff --git a/org/omg/DynamicAny/DynUnion.java b/org/omg/DynamicAny/DynUnion.java index b75ff613b..8875d15fa 100644 --- a/org/omg/DynamicAny/DynUnion.java +++ b/org/omg/DynamicAny/DynUnion.java @@ -1,6 +1,5 @@ /* DynUnion.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 @@ -48,7 +47,8 @@ import org.omg.CORBA.portable.IDLEntity; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface DynUnion extends DynUnionOperations, DynAny, IDLEntity, - org.omg.CORBA.Object, Serializable +public interface DynUnion + extends DynUnionOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable { } diff --git a/org/omg/DynamicAny/DynUnionHelper.java b/org/omg/DynamicAny/DynUnionHelper.java new file mode 100644 index 000000000..794098333 --- /dev/null +++ b/org/omg/DynamicAny/DynUnionHelper.java @@ -0,0 +1,151 @@ +/* DynUnionHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynUnion}. Following the 1.5 JDK + * specifications, DynUnion is always a local object, so the two methods of this + * helper ({@link #read} and {@link #write} are not in use, always throwing + * {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynUnionHelper +{ + /** + * Cast the passed object into the DynUnion. As DynUnion is a local object, + * the method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynUnion. + */ + public static DynUnion narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynUnion) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynUnion"); + } + } + + /** + * Get the type code of the {@link DynUnion}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynUnion"); + } + + /** + * Insert the DynUnion into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynUnion to insert. + */ + public static void insert(Any any, DynUnion that) + { + any.insert_Object(that); + } + + /** + * Extract the DynUnion from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynUnion. + */ + public static DynUnion extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynUnion repository id. + * + * @return "IDL:omg.org/DynamicAny/DynUnion:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynUnion:1.0"; + } + + /** + * This should read DynUnion from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynUnion read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynUnion from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynUnion value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynUnionOperations.java b/org/omg/DynamicAny/DynUnionOperations.java index 0a35bc9c7..b39dd93ff 100644 --- a/org/omg/DynamicAny/DynUnionOperations.java +++ b/org/omg/DynamicAny/DynUnionOperations.java @@ -1,6 +1,5 @@ /* DynUnionOperations.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 @@ -57,6 +56,7 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public interface DynUnionOperations + extends DynAnyOperations { /** * Get the value of discriminator, defining which content variant (member) is @@ -75,7 +75,8 @@ public interface DynUnionOperations * * @throws TypeMismatch if the discriminator has a wrong type of this union. */ - void set_discriminator(DynAny aDiscriminator) throws TypeMismatch; + void set_discriminator(DynAny aDiscriminator) + throws TypeMismatch; /** * Get the kind of the union descriminator. @@ -92,7 +93,8 @@ public interface DynUnionOperations * * @throws InvalidValue if the union has no active member. */ - DynAny member() throws InvalidValue; + DynAny member() + throws InvalidValue; /** * Returns the kind of the currently active union member. @@ -101,7 +103,8 @@ public interface DynUnionOperations * * @throws InvalidValue if the union has no active member. */ - TCKind member_kind() throws InvalidValue; + TCKind member_kind() + throws InvalidValue; /** * Returns the name of the currently active union member. @@ -110,7 +113,8 @@ public interface DynUnionOperations * * @throws InvalidValue if the union has no active member. */ - String member_name() throws InvalidValue; + String member_name() + throws InvalidValue; /** * Returns true if the union has no active member. This happens if If the @@ -126,7 +130,8 @@ public interface DynUnionOperations * * @throws TypeMismatch if the default case is not defined for this union. */ - void set_to_default_member() throws TypeMismatch; + void set_to_default_member() + throws TypeMismatch; /** * Set the discriminator to value that does not correspond any content variant @@ -135,5 +140,6 @@ public interface DynUnionOperations * * @throws TypeMismatch if the union has explicit default case. */ - void set_to_no_active_member() throws TypeMismatch; -}
\ No newline at end of file + void set_to_no_active_member() + throws TypeMismatch; +} diff --git a/org/omg/DynamicAny/DynValue.java b/org/omg/DynamicAny/DynValue.java new file mode 100644 index 000000000..831ce60b4 --- /dev/null +++ b/org/omg/DynamicAny/DynValue.java @@ -0,0 +1,58 @@ +/* DynValue.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.DynamicAny; + +import java.io.Serializable; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * Defines a non boxed value type. From the view point of DynAny, the Value is + * very much like structure. The access to fields of this structer are supported + * via {@link DynValueOperations} interface.Unlike structure, the value can also + * be equal to <code>null</code> that is supported via + * {@link DynValueCommonOperations} interface. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynValue + extends DynValueOperations, DynValueCommon, DynAny, IDLEntity, + org.omg.CORBA.Object, Serializable +{ +} diff --git a/org/omg/DynamicAny/DynValueBox.java b/org/omg/DynamicAny/DynValueBox.java new file mode 100644 index 000000000..e3806464f --- /dev/null +++ b/org/omg/DynamicAny/DynValueBox.java @@ -0,0 +1,55 @@ +/* DynValueBox.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.DynamicAny; + +import org.omg.CORBA.portable.IDLEntity; + +import java.io.Serializable; + +/** + * A "ValueBox" is a Value type container, holding a single instance of the + * other CORBA type. This content can be set to <code>null</code>. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynValueBox + extends DynValueBoxOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable +{ +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynValueBoxOperations.java b/org/omg/DynamicAny/DynValueBoxOperations.java new file mode 100644 index 000000000..d32541bbb --- /dev/null +++ b/org/omg/DynamicAny/DynValueBoxOperations.java @@ -0,0 +1,91 @@ +/* DynValueBoxOperation.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.DynamicAny; + +import org.omg.CORBA.Any; +import org.omg.DynamicAny.DynAnyPackage.InvalidValue; +import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; + +/** + * Defines operations, applicable for the boxed value type. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynValueBoxOperations + extends DynValueCommonOperations, DynAnyOperations +{ + /** + * Get the return the content of the "box" as the DynAny. + * + * @throws InvalidValue if the object is holding <code>null</code>. + */ + DynAny get_boxed_value_as_dyn_any() + throws InvalidValue; + + /** + * Get the return the content of the "box" as the Any. + * + * @throws InvalidValue if the object is holding <code>null</code>. + */ + Any get_boxed_value() + throws InvalidValue; + + /** + * Set the value of the "box" from DynAny. + * + * @param boxIt a value to box. + * + * @throws TypeMismatch if the type is not matching the current boxed value + * type. + */ + void set_boxed_value_as_dyn_any(DynAny boxIt) + throws TypeMismatch; + + /** + * Set the value of the "box" as Any. + * + * @param boxIt a value to place into the box. + * + * @throws TypeMismatch if the type is not matching the current boxed value + * type. + */ + void set_boxed_value(Any boxIt) + throws TypeMismatch; + +} diff --git a/org/omg/DynamicAny/DynValueCommon.java b/org/omg/DynamicAny/DynValueCommon.java new file mode 100644 index 000000000..0982eee12 --- /dev/null +++ b/org/omg/DynamicAny/DynValueCommon.java @@ -0,0 +1,76 @@ +/* DynValueCommon.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.DynamicAny; + +import org.omg.CORBA.portable.IDLEntity; + +import java.io.Serializable; + +/** + * Defines DynAny that may hold CORBA <code>null</code>. The + * {@link DynValueCommonOperations} provides methods for setting the value to + * <code>null</code> or non-<code>null</code> and checking if the value is + * <code>null</code>. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynValueCommon + extends DynValueOperations, DynAny, IDLEntity, org.omg.CORBA.Object, + Serializable +{ + /** + * Check if this {@link DynAny} is holding the <code>null</code>. + * + * @return true if this {@link DynAny} is holding the <code>null</code>, + * false otherwise. + */ + boolean is_null(); + + /** + * Set the value of this {@link DynAny} to CORBA <code>null</code>. + */ + void set_to_null(); + + /** + * Set the value of this {@link DynAny} to the default non-null value. The + * target {@link DynAny} creates a new data structure, intialised to the + * agreed default values, as defined in {@link DynAnyFactoryOperations}. + */ + void set_to_value(); +} diff --git a/org/omg/DynamicAny/DynValueCommonOperations.java b/org/omg/DynamicAny/DynValueCommonOperations.java new file mode 100644 index 000000000..31c31678e --- /dev/null +++ b/org/omg/DynamicAny/DynValueCommonOperations.java @@ -0,0 +1,69 @@ +/* DynValueCommonOperations.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.DynamicAny; + +/** + * Provides operations, applicable to {@link DynAny}s that may hold CORBA + * <code>null</code>. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynValueCommonOperations + extends DynAnyOperations +{ + /** + * Check if this {@link DynAny} is holding the <code>null</code>. + * + * @return true if this {@link DynAny} is holding the <code>null</code>, + * false otherwise. + */ + boolean is_null(); + + /** + * Set the value of this {@link DynAny} to CORBA <code>null</code>. + */ + void set_to_null(); + + /** + * Set the value of this {@link DynAny} to the default non-null value. The + * target {@link DynAny} creates a new data structure, intialised to the + * agreed default values, as defined in {@link DynAnyFactoryOperations}. + */ + void set_to_value(); +} diff --git a/org/omg/DynamicAny/DynValueHelper.java b/org/omg/DynamicAny/DynValueHelper.java new file mode 100644 index 000000000..a6d7afaa9 --- /dev/null +++ b/org/omg/DynamicAny/DynValueHelper.java @@ -0,0 +1,151 @@ +/* DynValueHelper.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.DynamicAny; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Any; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for {@link DynValue}. Following the 1.5 JDK + * specifications, DynValue is always a local object, so the two methods of this + * helper ({@link #read} and {@link #write} are not in use, always throwing + * {@link MARSHAL}. + * + * @specnote always throwing MARSHAL in read and write ensures compatibility + * with other popular implementations like Sun's. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DynValueHelper +{ + /** + * Cast the passed object into the DynValue. As DynValue is a local object, + * the method just uses java type cast. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a DynValue. + */ + public static DynValue narrow(org.omg.CORBA.Object obj) + { + try + { + return (DynValue) obj; + } + catch (ClassCastException cex) + { + throw new BAD_PARAM(obj.getClass().getName() + " is not a DynValue"); + } + } + + /** + * Get the type code of the {@link DynValue}. + */ + public static TypeCode type() + { + return ORB.init().create_interface_tc(id(), "DynValue"); + } + + /** + * Insert the DynValue into the given Any. + * + * @param any the Any to insert into. + * + * @param that the DynValue to insert. + */ + public static void insert(Any any, DynValue that) + { + any.insert_Object(that); + } + + /** + * Extract the DynValue from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain DynValue. + */ + public static DynValue extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the DynValue repository id. + * + * @return "IDL:omg.org/DynamicAny/DynValue:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/DynamicAny/DynValue:1.0"; + } + + /** + * This should read DynValue from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static DynValue read(InputStream input) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } + + /** + * This should read DynValue from the CDR input stream, but (following the JDK + * 1.5 API) it does not. + * + * @param input a org.omg.CORBA.portable stream to read from. + * + * @specenote Sun throws the same exception. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, DynValue value) + { + throw new MARSHAL(DynAnyFactoryHelper.not_applicable(id())); + } +}
\ No newline at end of file diff --git a/org/omg/DynamicAny/DynValueOperations.java b/org/omg/DynamicAny/DynValueOperations.java new file mode 100644 index 000000000..b986c24dd --- /dev/null +++ b/org/omg/DynamicAny/DynValueOperations.java @@ -0,0 +1,134 @@ +/* DynValueOperations.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.DynamicAny; + +import org.omg.CORBA.TCKind; +import org.omg.DynamicAny.DynAnyPackage.InvalidValue; +import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; + +/** + * Defines operations, applicable to DynValue. From the view point of DynAny, + * the Value is very much like structure. However, differently from the + * structure, the value type can also have private members. The private members + * of DynValue are also accessible via this interface, but this possibility + * should only be used in applications like in debuggers or inter-orb bridges. + * Unlike structure, the value can also be equal to <code>null</code>. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface DynValueOperations + extends DynAnyOperations, DynValueCommonOperations +{ + /** + * Get the kind of the current member. + * + * @return the kind of member at the current position. + * + * @throws TypeMismatch if this DynValue is holding <code>null</code>. + * @thorws InvalidValue if the current position does not indicate the member. + */ + TCKind current_member_kind() + throws TypeMismatch, InvalidValue; + + /** + * Get the name of the current member. + * + * @return the name of the current member as defined by the typecode. May be + * an empty string. + * + * @throws TypeMismatch if this DynValue is holding <code>null</code>. + * @thorws InvalidValue if the current position does not indicate the member. + */ + String current_member_name() + throws TypeMismatch, InvalidValue; + + /** + * Get all members as an array of the named DynAny's. The returned names are + * set as they are defined by typecode. + * + * @return the array, representing the members of this instance of value. + * + * @throws InvalidValue if this DynValue is holding <code>null</code>. + */ + NameDynAnyPair[] get_members_as_dyn_any() + throws InvalidValue; + + /** + * Get all members as an array of the named Any's. The returned names are set + * as they are defined by typecode. + * + * @return the array, representing the members of this instance of value. + * + * @throws InvalidValue if this DynValue is holding <code>null</code>. + */ + NameValuePair[] get_members() + throws InvalidValue; + + /** + * Set all members from the array of the named Any's. + * + * @param value the array, where the data for fields of the structure must + * occur exactly in the same order, as defined by typecode. + * + * @throws TypeMismatch if the type or name of the array member does not match + * the name and type of the corresponding field in the DynValue data + * structure. The empty string is assumed matching any name. + * + * @throws InvalidValue if the size of the array does not match the number of + * fields. + */ + void set_members_as_dyn_any(NameDynAnyPair[] value) + throws TypeMismatch, InvalidValue; + + /** + * Set all members from the array of the named Any's. + * + * @param value the array, where the data for fields of the structure must + * occur exactly in the same order, as defined by typecode. + * + * @throws TypeMismatch if the type or name of the array member does not match + * the name and type of the corresponding field in the DynValue data + * structure. The empty string is assumed matching any name. + * + * @throws InvalidValue if the size of the array does not match the number of + * fields. + */ + void set_members(NameValuePair[] value) + throws TypeMismatch, InvalidValue; +} diff --git a/org/omg/DynamicAny/NameDynAnyPair.java b/org/omg/DynamicAny/NameDynAnyPair.java index 34b27b69c..5fe438b5e 100644 --- a/org/omg/DynamicAny/NameDynAnyPair.java +++ b/org/omg/DynamicAny/NameDynAnyPair.java @@ -1,6 +1,5 @@ /* NameDynAnyPair.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 @@ -48,7 +47,8 @@ import java.io.Serializable; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public final class NameDynAnyPair implements IDLEntity, Serializable +public final class NameDynAnyPair + implements IDLEntity, Serializable { /** * Use serialVersionUID (v1.4) for interoperability. diff --git a/org/omg/DynamicAny/NameValuePair.java b/org/omg/DynamicAny/NameValuePair.java index eb82cfa26..e0ce752a5 100644 --- a/org/omg/DynamicAny/NameValuePair.java +++ b/org/omg/DynamicAny/NameValuePair.java @@ -1,56 +1,56 @@ /* NameValuePair.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.DynamicAny; import org.omg.CORBA.Any; import org.omg.CORBA.DynStruct; -import org.omg.CORBA.IDLEntity; +import org.omg.CORBA.portable.IDLEntity; import java.io.Serializable; /** * Holds the value, having the given name(id). This class is used by with * {@link DynStruct} to name the fields of the record (structure). - * + * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public final class NameValuePair implements Serializable, IDLEntity +public final class NameValuePair + implements Serializable, IDLEntity { /** * Use serialVersionUID (v1.4) for interoperability. @@ -76,10 +76,10 @@ public final class NameValuePair implements Serializable, IDLEntity /** * Creates the name-value pair, initialising the fields to the passed values. - * + * * @param aName the name (also called id) of the name-value pair, normally the * name of the structure field. - * + * * @param aValue the value of the name-value pair. */ public NameValuePair(String aName, Any aValue) diff --git a/scripts/eclipse-gnu.xml b/scripts/eclipse-gnu.xml index 8d04e08e1..2b69f10c4 100644 --- a/scripts/eclipse-gnu.xml +++ b/scripts/eclipse-gnu.xml @@ -1,33 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> -<profiles version="6"> -<profile name="GNU" version="6"> -<setting id="comment_clear_blank_lines" value="true"/> -<setting id="comment_format_comments" value="true"/> -<setting id="comment_format_header" value="false"/> -<setting id="comment_format_html" value="true"/> -<setting id="comment_format_source_code" value="true"/> -<setting id="comment_indent_parameter_description" value="true"/> -<setting id="comment_indent_root_tags" value="true"/> -<setting id="comment_line_length" value="80"/> -<setting id="comment_new_line_for_parameter" value="true"/> -<setting id="comment_separate_root_tags" value="true"/> +<profiles version="8"> +<profile name="GNU" version="8"> <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="18"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="18"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="18"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="18"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="18"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="82"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="18"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="18"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="18"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="21"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="21"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="21"/> +<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="21"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="1"/> @@ -38,25 +31,43 @@ <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="2"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_shifted"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> +<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_shifted"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line"/> +<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_comments" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/> <setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> <setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> +<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/> +<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/> @@ -64,20 +75,31 @@ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> @@ -86,13 +108,22 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> @@ -104,16 +135,24 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> @@ -126,11 +165,15 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> @@ -139,19 +182,32 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> @@ -163,13 +219,16 @@ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> +<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/> @@ -182,5 +241,6 @@ <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/> +<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> </profile> </profiles> diff --git a/vm/reference/java/lang/VMClass.java b/vm/reference/java/lang/VMClass.java index e3f31d3be..406fa69ab 100644 --- a/vm/reference/java/lang/VMClass.java +++ b/vm/reference/java/lang/VMClass.java @@ -251,18 +251,22 @@ final class VMClass static native ClassLoader getClassLoader(Class klass); /** - * VM implementors are free to make this method a noop if - * the default implementation is acceptable. + * Load the requested class and record the specified loader as the + * initiating class loader. * * @param name the name of the class to find + * @param initialize should the class initializer be run? + * @param loader the class loader to use (or null for the bootstrap loader) * @return the Class object representing the class or null for noop * @throws ClassNotFoundException if the class was not found by the - * classloader + * class loader * @throws LinkageError if linking the class fails * @throws ExceptionInInitializerError if the class loads, but an exception * occurs during initialization */ - static native Class forName(String name) throws ClassNotFoundException; + static native Class forName(String name, boolean initialize, + ClassLoader loader) + throws ClassNotFoundException; /** * Return whether this class is an array type. @@ -274,26 +278,6 @@ final class VMClass static native boolean isArray(Class klass); /** - * This method should trigger class initialization (if the - * class hasn't already been initialized) - * - * @param klass the Class object that's calling us - * @throws ExceptionInInitializerError if an exception - * occurs during initialization - */ - static native void initialize(Class klass); - - /** - * Load an array class. - * - * @return the Class object representing the class - * @throws ClassNotFoundException if the class was not found by the - * classloader - */ - static native Class loadArrayClass(String name, ClassLoader classloader) - throws ClassNotFoundException; - - /** * Throw a checked exception without declaring it. */ static native void throwException(Throwable t); diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java index 69f812ca5..4fe124036 100644 --- a/vm/reference/java/lang/VMClassLoader.java +++ b/vm/reference/java/lang/VMClassLoader.java @@ -284,17 +284,9 @@ final class VMClassLoader } /** - * Set this field to true if the VM wants to keep its own cache. - * Note that this field is not final, to allow VMs to have a - * different setting without having to recompile ClassLoader.java. + * Find the class if this class loader previously defined this class + * or if this class loader has been recorded as the initiating class loader + * for this class. */ - static boolean USE_VM_CACHE = false; - - /** - * If the VM wants to keep its own cache, this method can be replaced. - */ - static Class findLoadedClass(ClassLoader cl, String name) - { - return (Class) cl.loadedClasses.get(name); - } + static native Class findLoadedClass(ClassLoader cl, String name); } diff --git a/vm/reference/java/nio/VMDirectByteBuffer.java b/vm/reference/java/nio/VMDirectByteBuffer.java index 480e6d10b..93a83883a 100644 --- a/vm/reference/java/nio/VMDirectByteBuffer.java +++ b/vm/reference/java/nio/VMDirectByteBuffer.java @@ -39,7 +39,7 @@ exception statement from your version. */ package java.nio; import gnu.classpath.Configuration; -import gnu.classpath.RawData; +import gnu.classpath.Pointer; final class VMDirectByteBuffer { @@ -50,18 +50,14 @@ final class VMDirectByteBuffer { System.loadLibrary("javanio"); } - - init(); } - private static native void init(); - - static native RawData allocate (int capacity); - static native void free(RawData address); - static native byte get(RawData address, int index); - static native void get(RawData address, int index, byte[] dst, int offset, int length); - static native void put(RawData address, int index, byte value); - static native void put(RawData address, int index, byte[] src, int offset, int length); - static native RawData adjustAddress(RawData address, int offset); - static native void shiftDown(RawData address, int dst_offset, int src_offset, int count); + static native Pointer allocate (int capacity); + static native void free(Pointer address); + static native byte get(Pointer address, int index); + static native void get(Pointer address, int index, byte[] dst, int offset, int length); + static native void put(Pointer address, int index, byte value); + static native void put(Pointer address, int index, byte[] src, int offset, int length); + static native Pointer adjustAddress(Pointer address, int offset); + static native void shiftDown(Pointer address, int dst_offset, int src_offset, int count); } |