EMMA instructions

2006-08-24 Thread Anthony Balkissoon
Attached is a file with some instructions on how to use EMMA to generate
the coverage reports for Mauve/Classpath.

I will be on IRC in the next few days and will try to commit a script
that automatically generates a list of which classes can be
instrumented.  I've included instructions on how that script can be
written in the attachment.

Hopefully I'll be on IRC in the next little while and find time to make
some small contributions to the community.  

Thanks very much for the experience and camaraderie of the past 16
months.

Cheers,
Tony 
EMMA INSTRUCTIONS:
===

- the following instructions refer to emma.jar.  Copy this from 
  /home/abalkiss/emma.jar.


THE SETUP:
 - create a folder for instrumented sources, $INST
 - cp -r /home/user/sources/classpath/install $INST
 - cd $INST/install/share/classpath
 - cp emma.jar .
 - fastjar xf emma.jar
 - (unzip glibj.zip and remove glibj.zip)
 - setup a JamVM (--disable-zip, --with-classpath-install-dir=$INST/install 
   --prefix=$JAMINSTR)


INSTRUMENT THE CLASSPATH INSTALLATION
 - cd sources/mauve
 - for the following commands, JAVA has been tested as either gij or Sun's 
   java
 - JAVA -cp emma.jar emma instr -m overwrite -cp $INST/$SUBFOLDER
 - a list of $SUBFOLDERs that can be instrumented is at the bottom of this file
 - this will drop a coverage.em into sources/mauve - this is one of the 
   files needed to generate the report


RUN THE TESTS USING THE INSTRUMENTED VM
 - JAVA Harness -vm $JAMINSTR/bin/jamvm gnu/testlet
 - when the tests complete, a coverage.ec will be dropped into sources/mauve
   - this is needed to generate the report


GENERATE THE REPORT
 - JAVA -cp emma.jar emma report -r html -sp $CPSRC -in coverage.em,coverage.ec 
-Dreport.sort=+name
 - notes: $CPSRC is the path to your regular Classpath sources, not 
   instrumented, not the build folder. For me, this is 
   /home/abalkiss/.workspace/classpath.  For you this might be 
   /home/fitzsim/sources/classpath.  This is so the line-by-line hilighting 
   can be done.
 - this drops a coverage folder into sources/mauve - this is the web report.
   coverage/index.html is the start page.


***SUBFOLDERS THAT CAN BE INSTRUMENTED***
the folders/classes that can currently be instrumented is reflected in the 
script on builder.classpath.org MauveEMMA

When instrumenting, EMMA accepts only a folder or a jar file, so if you want 
to test down to the class level which files can be instrumented, you should 
create a jar file containing the class and instrument it.  This can be 
seen in the MauveEMMA script on builder as well.

A script that automatically determines which classes can be instrumented 
can be written in this way - create a jar containing a single .class file, 
instrument it, try to run the jamvm built against it, and if the Harness 
starts up and everything is okay, this file can be instrumented.


Re: [cp-patches] RFA: List.java

2006-07-28 Thread Anthony Balkissoon
Tania's email is currently broken but after talking to her, this patch
is now commited.

2006-07-28  Anthony Balkissoon  [EMAIL PROTECTED]

* java/awt/List.java: Committed following patch from Tania.
Initialized private variable visibleIndex to -1.
(addItem(String, int)): If string is null, set to empty string. If int
 -1, set to -1.
(delItem): If the item to be deleted was selected, select the next 
item in the list.
(delItems): Checks are not necessary and all indices in selected should
be deleted.
(select): Update selected.
(deselect): Update selected.

--Tony

On Thu, 2006-07-27 at 17:55 -0400, Anthony Balkissoon wrote:
 On Thu, 2006-07-27 at 17:05 -0400, Anthony Balkissoon wrote:
  A couple of things to check first:
  
  - getSelectedIndex() should probably return -1 if no items are selected,
  not 0.
 Correct, it should return -1, the patch that Tania submitted did return
 -1, the branch if (selected == null) return 0 was never taken because
 selected was initialized in the constructor and not set to null
 anywhere.  It could potentially be null if the peer returns null for
 getSelectedIndexes() and in this case -1 should still be returned so I
 removed that if statement.
 
  - in delItem, if the last item is deleted, but it was selected, it looks
  like an ArrayIndexOutOfBoundsException will be thrown
 Actually, no.  If there are 3 items and the third one (index 2) is
 selected, and then delItem(2) is called, isSelected(2) still returns
 true.  This doesn't throw any exceptions.  getItem(2) will throw an
 exception but isSelected(2) should still return true.  I augmented the
 Mauve tests to show this.
 
  - what happens in select() if multiple mode is false and another index
  is already selected?  should be call deselect() here?
 The way it is now seems to be fine, initializing a new int array.
 
 
 All of these things should also be tested when there IS a peer present.
 For instance, in select(), if a peer is present, we call peer.select().
 I wonder if we should return at this point or continue on with the
 method.  These tests need to be written.
 
 
 The patch attached is essentially Tania's patch, with the aforementioned
 removal of an if statement and also with one small performance tweak in
 the select() method when multipleMode is false.
 
 I'll leave this for Tania to comment on and commit.
 
 --Tony
Index: java/awt/List.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/List.java,v
retrieving revision 1.28
diff -u -r1.28 List.java
--- java/awt/List.java	13 Jul 2006 17:30:24 -	1.28
+++ java/awt/List.java	28 Jul 2006 15:13:38 -
@@ -108,7 +108,7 @@
   * @serial An index value used by codemakeVisible()/code and
   * codegetVisibleIndex/code.
   */
-private int visibleIndex;
+private int visibleIndex = -1;
 
 // The list of ItemListeners for this object.
 private ItemListener item_listeners;
@@ -116,7 +116,6 @@
 // The list of ActionListeners for this object.
 private ActionListener action_listeners;
 
-
 /*/
 
 /*
@@ -176,6 +175,7 @@
 
   if (GraphicsEnvironment.isHeadless())
 throw new HeadlessException ();
+  
 }
 
 /*/
@@ -314,12 +314,13 @@
   */
 public void
 setMultipleSelections(boolean multipleMode)
-{
+{  
   this.multipleMode = multipleMode;
 
   ListPeer peer = (ListPeer) getPeer ();
   if (peer != null)
 peer.setMultipleMode (multipleMode);
+  
 }
 
 /*/
@@ -519,6 +520,12 @@
 public void
 addItem(String item, int index)
 {
+  if (item == null)
+item = ; 
+  
+  if (index  -1)
+index = -1;
+  
   if ((index == -1) || (index = items.size ()))
 items.addElement (item);
   else
@@ -543,7 +550,17 @@
 public void
 delItem(int index) throws IllegalArgumentException
 {
+  boolean selected = false;
+  if (isSelected(index))
+{
+  selected = true;
+  deselect(index);   
+}
+  
   items.removeElementAt (index);
+  
+  if (selected)
+select(index);
 
   ListPeer peer = (ListPeer) getPeer ();
   if (peer != null)
@@ -580,15 +597,6 @@
 public synchronized void
 delItems(int start, int end) throws IllegalArgumentException
 {
-  if ((start  0) || (start = items.size()))
-throw new IllegalArgumentException(Bad list start index value:  + start);
-
-  if ((start  0) || (start = items.size()))
-throw new IllegalArgumentException(Bad list start index value:  + start);
-
-  if (start  end)
-throw new IllegalArgumentException(Start is greater than end!);
-
   // We must run the loop in reverse direction.
   for (int i = end; i = start; --i)
 items.removeElementAt (i);
@@ -644,6 +652,8 @@
   ListPeer peer = (ListPeer) getPeer ();
   if (peer != null)
 peer.removeAll

[commit-cp] classpath ChangeLog java/awt/List.java

2006-07-28 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Changes by: Anthony Balkissoon abalkiss   06/07/28 15:18:06

Modified files:
.  : ChangeLog 
java/awt   : List.java 

Log message:
2006-07-28  Anthony Balkissoon  [EMAIL PROTECTED]

* java/awt/List.java: Committed following patch from Tania.
Initialized private variable visibleIndex to -1.
(addItem(String, int)): If string is null, set to empty string. 
If int
 -1, set to -1.
(delItem): If the item to be deleted was selected, select the 
next 
item in the list.
(delItems): Checks are not necessary and all indices in 
selected should
be deleted.
(select): Update selected.
(deselect): Update selected.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8253r2=1.8254
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/List.java?cvsroot=classpathr1=1.28r2=1.29




Re: [cp-patches] RFA: List.java

2006-07-27 Thread Anthony Balkissoon
A couple of things to check first:

- getSelectedIndex() should probably return -1 if no items are selected,
not 0.
- in delItem, if the last item is deleted, but it was selected, it looks
like an ArrayIndexOutOfBoundsException will be thrown
- what happens in select() if multiple mode is false and another index
is already selected?  should be call deselect() here?


I'll test out the patch and maybe write some more tests for this stuff.

--Tony


On Wed, 2006-07-26 at 10:53 -0400, Tania Bento wrote:
 Hey,
 
 This patch now makes a few of harmony's test suites now pass on
 classpath.  The main problem was that 'selected' was not being updated
 in a couple of necessary methods.  I have also committed some mauve
 tests (gnu.testlet.java.awt.List.testSelected.java).  The other minor
 modifications were also based on harmony's test suites.  
 
 If someone could kindly review this patch and approve and/or comment on
 it, that would be great.
 
 Thanks.
 Tania
 
 2006-07-26  Tania Bento  [EMAIL PROTECTED]
 
 * java/awt/List.java
 Initialized private variable visibleIndex to -1.
 (addItem(String, int)): If string is null, it should be
 set to the empty string.
 (addItem(String, int)): If int  -1, it should be
 set to -1.
 (delItem): If the item to be deleted was selected, the
 next item on the list automatically is selected.
 (delItems): Checks are not necessarily and all indices
 in selected should be deleted.
 (getSelectedIndex): If selected == null, 0 should be
 returned.
 (select): Updated selected.
 (deselect): Updated selected.
 
 
 




Re: [cp-patches] RFA: List.java

2006-07-27 Thread Anthony Balkissoon
On Thu, 2006-07-27 at 17:05 -0400, Anthony Balkissoon wrote:
 A couple of things to check first:
 
 - getSelectedIndex() should probably return -1 if no items are selected,
 not 0.
Correct, it should return -1, the patch that Tania submitted did return
-1, the branch if (selected == null) return 0 was never taken because
selected was initialized in the constructor and not set to null
anywhere.  It could potentially be null if the peer returns null for
getSelectedIndexes() and in this case -1 should still be returned so I
removed that if statement.

 - in delItem, if the last item is deleted, but it was selected, it looks
 like an ArrayIndexOutOfBoundsException will be thrown
Actually, no.  If there are 3 items and the third one (index 2) is
selected, and then delItem(2) is called, isSelected(2) still returns
true.  This doesn't throw any exceptions.  getItem(2) will throw an
exception but isSelected(2) should still return true.  I augmented the
Mauve tests to show this.

 - what happens in select() if multiple mode is false and another index
 is already selected?  should be call deselect() here?
The way it is now seems to be fine, initializing a new int array.


All of these things should also be tested when there IS a peer present.
For instance, in select(), if a peer is present, we call peer.select().
I wonder if we should return at this point or continue on with the
method.  These tests need to be written.


The patch attached is essentially Tania's patch, with the aforementioned
removal of an if statement and also with one small performance tweak in
the select() method when multipleMode is false.

I'll leave this for Tania to comment on and commit.

--Tony
Index: java/awt/List.java
===
RCS file: /cvsroot/classpath/classpath/java/awt/List.java,v
retrieving revision 1.28
diff -u -r1.28 List.java
--- java/awt/List.java	13 Jul 2006 17:30:24 -	1.28
+++ java/awt/List.java	27 Jul 2006 21:46:45 -
@@ -108,7 +108,7 @@
   * @serial An index value used by codemakeVisible()/code and
   * codegetVisibleIndex/code.
   */
-private int visibleIndex;
+private int visibleIndex = -1;
 
 // The list of ItemListeners for this object.
 private ItemListener item_listeners;
@@ -116,7 +116,6 @@
 // The list of ActionListeners for this object.
 private ActionListener action_listeners;
 
-
 /*/
 
 /*
@@ -176,6 +175,7 @@
 
   if (GraphicsEnvironment.isHeadless())
 throw new HeadlessException ();
+  
 }
 
 /*/
@@ -314,12 +314,13 @@
   */
 public void
 setMultipleSelections(boolean multipleMode)
-{
+{  
   this.multipleMode = multipleMode;
 
   ListPeer peer = (ListPeer) getPeer ();
   if (peer != null)
 peer.setMultipleMode (multipleMode);
+  
 }
 
 /*/
@@ -519,6 +520,12 @@
 public void
 addItem(String item, int index)
 {
+  if (item == null)
+item = ; 
+  
+  if (index  -1)
+index = -1;
+  
   if ((index == -1) || (index = items.size ()))
 items.addElement (item);
   else
@@ -543,7 +550,17 @@
 public void
 delItem(int index) throws IllegalArgumentException
 {
+  boolean selected = false;
+  if (isSelected(index))
+{
+  selected = true;
+  deselect(index);   
+}
+  
   items.removeElementAt (index);
+  
+  if (selected)
+select(index);
 
   ListPeer peer = (ListPeer) getPeer ();
   if (peer != null)
@@ -580,15 +597,6 @@
 public synchronized void
 delItems(int start, int end) throws IllegalArgumentException
 {
-  if ((start  0) || (start = items.size()))
-throw new IllegalArgumentException(Bad list start index value:  + start);
-
-  if ((start  0) || (start = items.size()))
-throw new IllegalArgumentException(Bad list start index value:  + start);
-
-  if (start  end)
-throw new IllegalArgumentException(Start is greater than end!);
-
   // We must run the loop in reverse direction.
   for (int i = end; i = start; --i)
 items.removeElementAt (i);
@@ -644,6 +652,8 @@
   ListPeer peer = (ListPeer) getPeer ();
   if (peer != null)
 peer.removeAll ();
+  
+  selected = new int[0];
 }
 
 /*/
@@ -695,6 +705,7 @@
 
   if (selected == null || selected.length != 1)
 return -1;
+  
   return selected[0];
 }
 
@@ -713,7 +724,8 @@
 {
   ListPeer l = (ListPeer) peer;
   selected = l.getSelectedIndexes ();
-}
+}   
+  
   return selected;
 }
 
@@ -862,13 +874,32 @@
   *
   * @param index The index of the item to select.
   */
-public synchronized void
-select(int index)
-{
-  ListPeer lp = (ListPeer)getPeer();
-  if (lp != null)
-lp.select(index);
-}
+  public synchronized void select(int index)
+  {
+ListPeer lp = (ListPeer) getPeer();
+if (lp != null)
+  lp.select(index);
+
+boolean

code coverage reports expanded

2006-07-17 Thread Anthony Balkissoon
Much of the java.net package has been added to the code coverage reports
(they will be online as soon as the autobuilder gets to it).  

As a rule, if a package you're interested in is not covered in the
reports, that does not mean it will never be covered.  I'm working on
expanding the reports to cover more packages.  Check back often or send
me a request.

The reports are at http://builder.classpath.org/~cpdev/coverage/


--Tony







classpath code coverage reports now online

2006-07-07 Thread Anthony Balkissoon
There are code coverage reports for classpath-mauve now at
builder.classpath.org/~cpdev/coverage (there is a link from the main
builder.classpath.org page).

There are some core classes missing from the reports because
instrumenting them caused headaches, but I will investigate these and
try to get as many up as possible.

Cheers,
Tony




Re: Mauve reports

2006-06-14 Thread Anthony Balkissoon
Hi everyone, sorry I was away for a few days until yesterday.

Roman this is great, thanks a lot.

Somebody asked about changing the timeout value, if the script is using
the old harness I don't think that's possible but if we change the
scripts to use the new stuff the command to run all the tests with a
custom timeout value would be

$(JAVA) Harness -timeout X 

David I'll investigate why some tests aren't running.

Cheers all,
Tony

On Thu, 2006-06-08 at 08:57 -0600, Tom Tromey wrote:
  Roman == Roman Kennke [EMAIL PROTECTED] writes:
 
 Roman FYI: I have set up my old Mauve report script on builder.classpath.org
 Roman to generate nice HTML for the Mauve results:
 
 Thanks!
 
 Roman http://builder.classpath.org/mauve/mauvereport.cgi
 
 I made a link to this from the builder's main web page.
 
 Tom
 




Re: Beanshell support for Mauve

2006-04-05 Thread Anthony Balkissoon
On Wed, 2006-04-05 at 19:50 +0200, Roman Kennke wrote:
 I'm sure there are more benefits, but only these two seem very appealing
 to me. Tony, you are currently working with Mauve, what do you think
 about this? And what do the others think about this?

Sounds good to me.  I've never dealt with BeanShell before but it still
seems very doable.  I would be happy to add this to my list of things to
add to Mauve.  

--Tony




Request for Comments: new Mauve harness

2006-03-27 Thread Anthony Balkissoon
Attached is the start of the new Mauve test harness I've been working
on.  The features that are present so far include:

1. easier invocation:
   - from the mauve source folder type (using jamvm, for example), type
jamvm   Harness to run all tests.  
   - jamvm Harness -help displays a help screen.  
   - single test: jamvm Harness javax.swing.JTable.isCellEditable 
   - folder of tests: jamvm Harness javax.swing

Note that the Harness also accepts input from standard input, so any
scripts you have locally will still work.  Also, for the test name
above, a gnu.testlet. prefix would work as well, as would the name
gnu/testlet/javax/swing/JTable/isCellEditable, so tab-completion is
possible.


2. line numbers for failures and minimal information for exceptions
   - rather than counting tests, when a call to harness.check() fails, a
line number and a reason for the failure is given
   - type/location/point of origin are given for uncaught exceptions


3. constant number of tests
   - as discussed, by reporting each call to test() as one test, while
still printing out all the failing calls to harness.check(), we're able
to achieve a constant number of tests between successive runs, even if
there are uncaught exceptions.  



*** NOTE: This harness is not done yet.  There is no hang/crash
detection, so you will notice problems if you try to run all tests.  I'm
hoping for feedback on the things it *can* do so far.

This harness will eventually detect crashes/hangs and will also
auto-compile tests, so new or updated tests will be run properly without
having to compile them separately.  Code coverage tools may also be
added.  So although right now the harness provides no more than what was
already available, it eventually will and I'd like to develop it in
stages, which is why I submit this patch for comments.

Thanks,
Tony
Index: Harness.java
===
RCS file: Harness.java
diff -N Harness.java
--- /dev/null	1 Jan 1970 00:00:00 -
+++ Harness.java	27 Mar 2006 21:33:20 -
@@ -0,0 +1,955 @@
+// Copyright (c) 2006  Red Hat, Inc.
+// Written by Anthony Balkissoon [EMAIL PROTECTED]
+// Adapted from gnu.testlet.SimpleTestHarness written by Tom Tromey.
+// Copyright (c) 2005  Mark J. Wielaard  [EMAIL PROTECTED]
+
+// This file is part of Mauve.
+
+// Mauve 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.
+
+// Mauve 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 Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+// KNOWN BUGS:
+//   - should look for /*{ ... }*/ and treat contents as expected
+// output of test.  In this case we should redirect System.out
+// to a temp file we create.
+
+/*
+ * See the README.Harness file for information on how to use this
+ * file and what it is designed to do.
+ */
+
+import gnu.testlet.ResourceNotFoundException;
+import gnu.testlet.TestHarness;
+import gnu.testlet.TestReport;
+import gnu.testlet.TestResult;
+import gnu.testlet.TestSecurityManager;
+import gnu.testlet.Testlet;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Vector;
+
+public class Harness
+extends TestHarness
+{
+  private int count = 0;
+
+  private int failures = 0;
+
+  private static Vector expected_xfails = new Vector();
+
+  private int xfailures = 0;
+
+  private int xpasses = 0;
+
+  private int total = 0;
+
+  private boolean verbose = false;
+
+  private boolean debug = false;
+
+  private boolean results_only = false;
+
+  private boolean exceptions = false;
+
+  private String description;
+
+  private String last_check;
+
+  private TestReport report = null;
+
+  private TestResult currentResult = null;
+  
+  private static boolean recursion = true;
+  
+  private static boolean showPasses = false;
+  
+  private static int total_tests = 0;
+  
+  private static int total_test_fails = 0;  
+  
+  private final String getDescription(String pf)
+  {
+return (pf + :  + description
++ ((last_check == null) ?  : (:  + last_check)) +  (number 
++ (count + 1) + ));
+  }
+
+  protected int getFailures()
+  {
+return failures;
+  }
+
+  /**
+   * Removes the gnu.testlet. from the start of a String.
+   * @param val the String

[commit-cp] classpath ./ChangeLog javax/swing/JTable.java

2006-03-27 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/03/21 18:42:30

Modified files:
.  : ChangeLog 
javax/swing: JTable.java 

Log message:
2006-03-21  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JTable.java:
(columnAtPoint): Removed the null check, this method should throw a NPE
if the argument is null.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6847tr2=1.6848r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/JTable.java.diff?tr1=1.89tr2=1.90r1=textr2=text




[cp-patches] FYI: JTable fixlet

2006-03-21 Thread Anthony Balkissoon
While testing Mauve exception handling I tried to generate a NPE using
JTable.columnAtPoint but found that Classpath was gracefully ignoring
null argument while Sun was throwing the NPE I wanted.  So I removed
the != null check.

2006-03-21  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JTable.java:
(columnAtPoint): Removed the null check, this method should throw a NPE
if the argument is null.

--Tony
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.89
diff -u -r1.89 JTable.java
--- javax/swing/JTable.java	20 Mar 2006 11:26:04 -	1.89
+++ javax/swing/JTable.java	21 Mar 2006 18:40:07 -
@@ -1946,21 +1946,18 @@
*/
   public int columnAtPoint(Point point)
   {
-if (point != null)
-  {
-int ncols = getColumnCount();
-Dimension gap = getIntercellSpacing();
-TableColumnModel cols = getColumnModel();
-int x = point.x;
+int ncols = getColumnCount();
+Dimension gap = getIntercellSpacing();
+TableColumnModel cols = getColumnModel();
+int x = point.x;
 
-for (int i = 0; i  ncols; ++i)
-  {
-int width = cols.getColumn(i).getWidth()
-+ (gap == null ? 0 : gap.width);
-if (0 = x  x  width)
-  return i;
-x -= width;
-  }
+for (int i = 0; i  ncols; ++i)
+  {
+int width = cols.getColumn(i).getWidth()
++ (gap == null ? 0 : gap.width);
+if (0 = x  x  width)
+  return i;
+x -= width;
   }
 return -1;
   }
@@ -1969,8 +1966,7 @@
* Returns index of the row that contains specified point or -1 if this table
* doesn't contain this point.
* 
-   * @param point
-   *  point to identify the row
+   * @param point point to identify the row
* @return index of the row that contains specified point or -1 if this table
* doesn't contain this point.
*/


Re: Mauve wishlist

2006-03-20 Thread Anthony Balkissoon
On Fri, 2006-03-17 at 11:32 -0500, Thomas Fitzsimmons wrote:
 Hi,
 
 Anthony Balkissoon has expressed interest in improving Mauve so we'd
 like to know what would be the best things to work on.
 

Another suggestion that Tom Fitzsimmons had was to change the way we
count the number of tests.  Counting each invocation of the test()
method rather than each call to harness.check() has two benefits:

1) constant number of tests, regardless of exceptions being thrown or
which if-else branch is taken

2) more realistic number of tests, to accurately reflect the extent of
our testing


For point 1) this will help us see if we are making progress.  Right now
a Mauve run might say we have 113 fails out of 13200 tests and then a
later run could say 200 fails out of 34000 tests.  Is this an
improvement?  Hard to say.  But if we count each call to test() as a
test, and also detect hanging tests, then we should have a constant
number of tests in each run and will be able to say if changes made have
a positive impact on Mauve test results.  Of course, if in one
particular test file there are 1000 calls to harness.check() and only
one of them fails, it's not helpful to just report that the entire test
failed.  So the output will have to pinpoint which call to harness.check
failed (and preferably a line number).  The negative side here is that
the results will be overly pessimistic because any failing harness.check
trumps all the passing harness.check calls and the test is reported as a
failure.

What do people have to say about this idea?

--Tony




[cp-patches] FYI: Updated header comment in Character.java

2006-03-16 Thread Anthony Balkissoon
Updated the comment because it made reference to the old Unicode 3
support instead of the new Unicode 4 support.

2006-03-16  Anthony Balkissoon  [EMAIL PROTECTED]

* java/lang/Character.java: Updated header comment.

--Tony




Re: [cp-patches] FYI: Updated header comment in Character.java

2006-03-16 Thread Anthony Balkissoon
Forgot the patch, here it is.


On Thu, 2006-03-16 at 13:53 -0500, Anthony Balkissoon wrote:
 Updated the comment because it made reference to the old Unicode 3
 support instead of the new Unicode 4 support.
 
 2006-03-16  Anthony Balkissoon  [EMAIL PROTECTED]
 
   * java/lang/Character.java: Updated header comment.
 
 --Tony
 
 
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: java/lang/Character.java
===
RCS file: /cvsroot/classpath/classpath/java/lang/Character.java,v
retrieving revision 1.45
diff -u -r1.45 Character.java
--- java/lang/Character.java	15 Feb 2006 23:00:38 -	1.45
+++ java/lang/Character.java	16 Mar 2006 18:51:41 -
@@ -47,7 +47,7 @@
 /**
  * Wrapper class for the primitive char data type.  In addition, this class
  * allows one to retrieve property information and perform transformations
- * on the 57,707 defined characters in the Unicode Standard, Version 3.0.0.
+ * on the defined characters in the Unicode Standard, Version 4.0.0.
  * java.lang.Character is designed to be very dynamic, and as such, it
  * retrieves information on the Unicode character set from a separate
  * database, gnu.java.lang.CharData, which can be easily upgraded.
@@ -55,7 +55,7 @@
  * pFor predicates, boundaries are used to describe
  * the set of characters for which the method will return true.
  * This syntax uses fairly normal regular expression notation.
- * See 5.13 of the Unicode Standard, Version 3.0, for the
+ * See 5.13 of the Unicode Standard, Version 4.0, for the
  * boundary specification.
  *
  * pSee a href=http://www.unicode.org;http://www.unicode.org/a


[commit-cp] classpath ./ChangeLog java/lang/Character.java

2006-03-16 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/03/16 18:52:50

Modified files:
.  : ChangeLog 
java/lang  : Character.java 

Log message:
2006-03-16  Anthony Balkissoon  [EMAIL PROTECTED]

* java/lang/Character.java: Updated header comment.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6767tr2=1.6768r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/lang/Character.java.diff?tr1=1.45tr2=1.46r1=textr2=text




[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-03-10 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/28 20:31:02

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-28  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(divide(BigDecimal, int, RoundingMode)): New method.
(divide(BigDecimal, RoundingMode)): Likewise.
(divide(BigDecimal, int, int)): Removed incorrect throwing of exception
when the new scale is  0.
(setScale(int, RoundingMode)): New method.
(ulp): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.208tr2=1.2386.2.209r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.13tr2=1.17.2.14r1=textr2=text




[commit-cp] classpath/java/math BigDecimal.java [generics-branch]

2006-03-10 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/27 19:49:07

Modified files:
java/math  : BigDecimal.java 

Log message:
2006-02-27  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java: Added @throws clause to constructors.
(mathContext): Removed this unneeded field.
(BigDecimal(int, MathContext)): New constructor.
(BigDecimal(BigInteger, int, MathContext)): Likewise.
(multiply(BigDecimal, MathContext)): New method.
(negate(MathContext)): Likewise.
(plus(MathContext)): Likewise.
(numDigitsInLong): Fixed to properly handle negatives.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.11tr2=1.17.2.12r1=textr2=text




[commit-cp] classpath ChangeLog NEWS

2006-03-07 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/03/06 16:29:37

Modified files:
.  : ChangeLog NEWS 

Log message:
* NEWS: Fixed typo.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6631tr2=1.6632r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/NEWS.diff?tr1=1.121tr2=1.122r1=textr2=text




[commit-cp] classpath ChangeLog [generics-branch]

2006-03-04 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/27 19:49:48

Modified files:
.  : ChangeLog 

Log message:
2006-02-27  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java: Added @throws clause to constructors.
(mathContext): Removed this unneeded field.
(BigDecimal(int, MathContext)): New constructor.
(BigDecimal(BigInteger, int, MathContext)): Likewise.
(multiply(BigDecimal, MathContext)): New method.
(negate(MathContext)): Likewise.
(plus(MathContext)): Likewise.
(numDigitsInLong): Fixed to properly handle negatives.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.206tr2=1.2386.2.207r1=textr2=text




[commit-cp] classpath ./ChangeLog java/lang/StringBuilder.java

2006-03-04 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/03/02 20:18:44

Modified files:
.  : ChangeLog 
java/lang  : StringBuilder.java 

Log message:
2006-03-02  Anthony Balkissoon  [EMAIL PROTECTED]

* java/lang/StringBuilder.java:
(codePointAt): New method.
(codePointBefore): Likewise.
(codePointCount): Likewise.
(trimToSize): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6559tr2=1.6560r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/lang/StringBuilder.java.diff?tr1=1.6tr2=1.7r1=textr2=text




[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-03-03 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/03/01 17:04:22

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-03-01  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(remainder(BigDecimal)): New method.
(divideAndRemainder(BigDecimal)): Likewise.
(divideToIntegralValue(BigDecimal)): Likewise.
(floor): New implementation method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.209tr2=1.2386.2.210r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.14tr2=1.17.2.15r1=textr2=text




[cp-patches] FYI: missing StringBuilder methods

2006-03-02 Thread Anthony Balkissoon
I implemented the missing methods in StringBuilder.

2006-03-02  Anthony Balkissoon  [EMAIL PROTECTED]

* java/lang/StringBuilder.java:
(codePointAt): New method.
(codePointBefore): Likewise.
(codePointCount): Likewise.
(trimToSize): Likewise.

--Tony
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: java/lang/StringBuilder.java
===
RCS file: /cvsroot/classpath/classpath/java/lang/StringBuilder.java,v
retrieving revision 1.6
diff -u -r1.6 StringBuilder.java
--- java/lang/StringBuilder.java	24 Oct 2005 23:58:21 -	1.6
+++ java/lang/StringBuilder.java	2 Mar 2006 20:17:17 -
@@ -1006,4 +1006,65 @@
 return false;
 return true;
   }
+
+  /**
+   * Get the code point at the specified index.  This is like #charAt(int),
+   * but if the character is the start of a surrogate pair, and the
+   * following character completes the pair, then the corresponding
+   * supplementary code point is returned.
+   * @param index the index of the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or gt;= length()
+   * @since 1.5
+   */
+  public int codePointAt(int index)
+  {
+return Character.codePointAt(value, index, count);
+  }
+
+/**
+   * Get the code point before the specified index.  This is like
+   * #codePointAt(int), but checks the characters at codeindex-1/code and
+   * codeindex-2/code to see if they form a supplementary code point.
+   * @param index the index just past the codepoint to get, starting at 0
+   * @return the codepoint at the specified index
+   * @throws IndexOutOfBoundsException if index is negative or gt;= length()
+   * @since 1.5
+   */
+  public int codePointBefore(int index)
+  {
+// Character.codePointBefore() doesn't perform this check.  We
+// could use the CharSequence overload, but this is just as easy.
+if (index = count)
+  throw new IndexOutOfBoundsException();
+return Character.codePointBefore(value, index, 1);
+  }
+
+  /**
+   * Returns the number of Unicode code points in the specified sub sequence.
+   * Surrogate pairs count as one code point.
+   * @param beginIndex the start of the subarray
+   * @param endIndex the index after the last char in the subarray
+   * @return the number of code points
+   * @throws IndexOutOfBoundsException if beginIndex is less than zero or 
+   * greater than endIndex or if endIndex is greater than the length of this 
+   * StringBuilder
+   */
+  public int codePointCount(int beginIndex,int endIndex)
+  {
+if (beginIndex  0 || beginIndex  endIndex || endIndex  count)
+  throw new IndexOutOfBoundsException(invalid indices:  + beginIndex
+  + ,  + endIndex);
+return Character.codePointCount(value, beginIndex, endIndex - beginIndex);
+  }
+
+  public void trimToSize()
+  {
+if (count  value.length)
+  {
+char[] newValue = new char[count];
+System.arraycopy(value, 0, newValue, 0, count);
+value = newValue;
+  }
+  }
 }


[commit-cp] classpath ./ChangeLog javax/swing/DefaultListSe...

2006-03-02 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/28 21:10:14

Modified files:
.  : ChangeLog 
javax/swing: DefaultListSelectionModel.java 

Log message:
2006-02-28  Anthony Balkissoon  [EMAIL PROTECTED]

PR classpath/26434
* javax/swing/DefaultListSelectionModel.java:
(addSelectionInterval): Return early if either of the arguments is -1.
(removeSelectionInterval): Likewise.
(setSelectionInterval): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6542tr2=1.6543r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/DefaultListSelectionModel.java.diff?tr1=1.25tr2=1.26r1=textr2=text




[cp-patches] [generics] BigDecimal conversion methods

2006-03-01 Thread Anthony Balkissoon
Wrote the conversion methods longValueExact, intValueExact,
byteValueExact, and shortValueExact.  This required a fix in precision()
because very large numbers weren't handled properly.

2006-03-01  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(precision): Fixed overflow problem with large numbers.
(longValueExact): New method.
(intValueExact): Likewise.
(byteValueExact): Likewise.
(shortValueExact): Likewise.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.15
diff -u -r1.17.2.15 BigDecimal.java
--- java/math/BigDecimal.java	1 Mar 2006 17:04:22 -	1.17.2.15
+++ java/math/BigDecimal.java	1 Mar 2006 20:12:46 -
@@ -1023,13 +1023,11 @@
   {
 if (precision == 0)
   {
-precision = numDigitsInLong(intVal.longValue());
-// If numDigitsInLong returns 19 then we use numDigitsInBigInteger
-// to determine if there are actually more than 19 digits in intVal.
-if (precision == 19)
+if (intVal.compareTo(BigInteger.TEN.pow(18)) == 1)
   precision = numDigitsInBigInteger(intVal);
-  }
-
+else
+  precision = numDigitsInLong(intVal.longValue());
+  }
 return precision;
   }
   
@@ -1051,7 +1049,7 @@
 
   /**
* This method determines the number of digits in the long value l. 
-   * @param l the long value
+   * @param l1 the long value
* @return the number of digits in l
*/
   private static int numDigitsInLong(long l1)
@@ -1536,4 +1534,79 @@
   {
 return new BigDecimal(BigInteger.ONE, scale);
   }
+  
+  /**
+   * Converts this BigDecimal to a long value.
+   * @return the long value
+   * @throws ArithmeticException if rounding occurs or if overflow occurs
+   * @since 1.5
+   */
+  public long longValueExact()
+  {
+// Set scale will throw an exception if rounding occurs.
+BigDecimal temp = setScale(0, ROUND_UNNECESSARY);
+BigInteger tempVal = temp.intVal;
+// Check for overflow.
+long result = intVal.longValue();
+if (tempVal.compareTo(BigInteger.valueOf(Long.MAX_VALUE))  1
+|| (result  0  signum() == 1) || (result  0  signum() == -1))
+  throw new ArithmeticException(this BigDecimal is too  +
+large to fit into the return type);
+
+return intVal.longValue();
+  }
+  
+  /**
+   * Converts this BigDecimal into an int by first calling longValueExact
+   * and then checking that the codelong/code returned from that
+   * method fits into an codeint/code.
+   * @return an int whose value is codethis/code
+   * @throws ArithmeticException if this BigDecimal has a fractional part
+   * or is too large to fit into an int.
+   * @since 1.5
+   */
+  public int intValueExact()
+  {
+long temp = longValueExact();
+int result = (int)temp;
+if (result != temp)
+  throw new ArithmeticException (this BigDecimal cannot fit into an int);
+return result;
+  }
+  
+  /**
+   * Converts this BigDecimal into a byte by first calling longValueExact
+   * and then checking that the codelong/code returned from that
+   * method fits into a codebyte/code.
+   * @return a byte whose value is codethis/code
+   * @throws ArithmeticException if this BigDecimal has a fractional part
+   * or is too large to fit into a byte.
+   * @since 1.5
+   */
+  public byte byteValueExact()
+  {
+long temp = longValueExact();
+byte result = (byte)temp;
+if (result != temp)
+  throw new ArithmeticException (this BigDecimal cannot fit into a byte);
+return result;
+  }
+  
+  /**
+   * Converts this BigDecimal into a short by first calling longValueExact
+   * and then checking that the codelong/code returned from that
+   * method fits into a codeshort/code.
+   * @return a short whose value is codethis/code
+   * @throws ArithmeticException if this BigDecimal has a fractional part
+   * or is too large to fit into a short.
+   * @since 1.5
+   */
+  public short shortValueExact()
+  {
+long temp = longValueExact();
+short result = (short)temp;
+if (result != temp)
+  throw new ArithmeticException (this BigDecimal cannot fit into a short);
+return result;
+  }
 }


Re: Question about the Generics branch.

2006-03-01 Thread Anthony Balkissoon
On Wed, 2006-03-01 at 14:38 +, theUser BL wrote:
 What me more wonder is, that in the cvs at 
 http://cvs.savannah.gnu.org/viewcvs/?cvsroot=classpath there is no clue 
 about the two branches. It seems, that there existing only the one there.
 

Click on the classpath link, or go here:
http://cvs.savannah.gnu.org/viewcvs/classpath/?root=classpath
and then the drop-down menu at the bottom will allow you to switch
branches.

 Btw: Which JVM can run the generics-branch?

I am currently using JamVM with the generics branch, I had to update to
JamVM 1.4.2 but I'm not 100% sure if that's a requirement or just
something I had to do for my particular situation.


Cheers,
Tony




[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-03-01 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/27 21:35:15

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-27  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java: Replaced occurences of BigInteger.valueOf
with BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN where appropriate.
(add(BigDecimal, MathContext)): New method.
(subtract(BigDecimal, MathContext)): Likewise.
(precision): Fixed to correctly handle BigIntegers with more than 19
digits.
(pow(int, MathContext)): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.207tr2=1.2386.2.208r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.12tr2=1.17.2.13r1=textr2=text




[cp-patches] FYI: updated NEWS file

2006-02-28 Thread Anthony Balkissoon
I added a line about Unicode 4.0.0 support to the NEWS file.

2006-02-28  Anthony Balkissoon  [EMAIL PROTECTED]

* NEWS: Added line about Unicode 4.0.0 support.

--Tony
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: NEWS
===
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.114
diff -u -r1.114 NEWS
--- NEWS	24 Feb 2006 12:49:44 -	1.114
+++ NEWS	28 Feb 2006 16:14:58 -
@@ -7,6 +7,8 @@
   `java.security.' `javax.crypto,' and `javax.net.ssl' packages, and
   are service providers implementing the underlying algorithms.
  
+* Unicode 4.0.0 is supported.
+
 * The new folder tools includes GIOP and RMI stub and tie source code
   generators, IOR parser and both transient and persistent GIOP naming services. 
 


[cp-patches] FYI: BigInteger serialization fixes PR 26333

2006-02-28 Thread Anthony Balkissoon
I submitted the patch written by Rafael Teixeira: 
http://developer.classpath.org/pipermail/classpath-patches/2006-February/000473.html

that fixes BigInteger serialization.

2006-02-28  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigInteger.java:
Committed patch by Rafael: 
developer.classpath.org/pipermail/classpath-patches/
2006-February/000473.html
(signum): Return early 0 if words == null and ival == 0.
(readObject): Handle special case of magnitude.length or signum being
0.
(writeObject): If signum is zero return a zero-sized byte[].

--Tony
? patch.diff
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: java/math/BigInteger.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigInteger.java,v
retrieving revision 1.26
diff -u -r1.26 BigInteger.java
--- java/math/BigInteger.java	21 Sep 2005 17:00:33 -	1.26
+++ java/math/BigInteger.java	28 Feb 2006 17:59:13 -
@@ -356,9 +356,9 @@
 
   public int signum()
   {
-int top = words == null ? ival : words[ival-1];
-if (top == 0  words == null)
+if (ival == 0  words == null)
   return 0;
+int top = words == null ? ival : words[ival-1];
 return top  0 ? -1 : 1;
   }
 
@@ -2227,17 +2227,25 @@
 throws IOException, ClassNotFoundException
   {
 s.defaultReadObject();
-words = byteArrayToIntArray(magnitude, signum  0 ? -1 : 0);
-BigInteger result = make(words, words.length);
-this.ival = result.ival;
-this.words = result.words;
+if (magnitude.length == 0 || signum == 0)
+  {
+this.ival = 0;
+this.words = null;
+  }
+else
+  {
+words = byteArrayToIntArray(magnitude, signum  0 ? -1 : 0);
+BigInteger result = make(words, words.length);
+this.ival = result.ival;
+this.words = result.words;
+  }
   }
 
   private void writeObject(ObjectOutputStream s)
 throws IOException, ClassNotFoundException
   {
 signum = signum();
-magnitude = toByteArray();
+magnitude = signum == 0 ? new byte[0] : toByteArray();
 s.defaultWriteObject();
   }
 }


[cp-patches] [generics] BigDecimal fix and 4 new methods

2006-02-28 Thread Anthony Balkissoon
More BD stuff.

2006-02-28  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(divide(BigDecimal, int, RoundingMode)): New method.
(divide(BigDecimal, RoundingMode)): Likewise.
(divide(BigDecimal, int, int)): Removed incorrect throwing of exception
when the new scale is  0.
(setScale(int, RoundingMode)): New method.
(ulp): Likewise.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.13
diff -u -r1.17.2.13 BigDecimal.java
--- java/math/BigDecimal.java	27 Feb 2006 21:35:15 -	1.17.2.13
+++ java/math/BigDecimal.java	28 Feb 2006 20:28:12 -
@@ -670,7 +670,38 @@
   {
 return divide (val, scale, roundingMode);
   }
+  
+  /**
+   * Returns a BigDecimal whose value is (this / val), with the specified scale
+   * and rounding according to the RoundingMode 
+   * @param val the divisor
+   * @param scale the scale of the BigDecimal returned
+   * @param roundingMode the rounding mode to use
+   * @return a BigDecimal whose value is approximately (this / val)
+   * @throws ArithmeticException if divisor is zero or the rounding mode is
+   * UNNECESSARY but the specified scale cannot represent the value exactly
+   * @since 1.5
+   */
+  public BigDecimal divide(BigDecimal val, 
+   int scale, RoundingMode roundingMode)
+  {
+return divide (val, scale, roundingMode.ordinal());
+  }
 
+  /**
+   * Returns a BigDecimal whose value is (this / val) rounded according to the
+   * RoundingMode
+   * @param val the divisor
+   * @param roundingMode the rounding mode to use
+   * @return a BigDecimal whose value is approximately (this / val)
+   * @throws ArithmeticException if divisor is zero or the rounding mode is
+   * UNNECESSARY but the specified scale cannot represent the value exactly
+   */
+  public BigDecimal divide (BigDecimal val, RoundingMode roundingMode)
+  {
+return divide (val, scale, roundingMode.ordinal());
+  }
+  
   public BigDecimal divide(BigDecimal val, int newScale, int roundingMode)
 throws ArithmeticException, IllegalArgumentException 
   {
@@ -678,9 +709,6 @@
   throw 
 	new IllegalArgumentException(illegal rounding mode:  + roundingMode);
 
-if (newScale  0)
-  throw new ArithmeticException (scale is negative:  + newScale);
-
 if (intVal.signum () == 0)	// handle special case of 0.0/0.0
   return newScale == 0 ? ZERO : new BigDecimal (ZERO.intVal, newScale);
 
@@ -1346,6 +1374,23 @@
   }
   
   /**
+   * Returns a BigDecimal whose value is the same as this BigDecimal but whose
+   * representation has a scale of codenewScale/code.  If the scale is
+   * reduced then rounding may occur, according to the RoundingMode.
+   * @param newScale
+   * @param roundingMode
+   * @return a BigDecimal whose scale is as given, whose value is 
+   * codethis/code with possible rounding
+   * @throws ArithmeticException if the rounding mode is UNNECESSARY but 
+   * rounding is required 
+   * @since 1.5
+   */
+  public BigDecimal setScale(int newScale, RoundingMode roundingMode)
+  {
+return setScale(newScale, roundingMode.ordinal());
+  }
+  
+  /**
* Returns a new BigDecimal constructed from the BigDecimal(String) 
* constructor using the Double.toString(double) method to obtain
* the String.
@@ -1419,4 +1464,15 @@
 result = result.round(mc);
 return result;
   }
+  
+  /**
+   * Returns the size of a unit in the last place of this BigDecimal.  This
+   * returns a BigDecimal with [unscaledValue, scale] = [1, this.scale()].
+   * @return the size of a unit in the last place of codethis/code.
+   * @since 1.5
+   */
+  public BigDecimal ulp()
+  {
+return new BigDecimal(BigInteger.ONE, scale);
+  }
 }


[cp-patches] [generics] BigDecimal stuff again

2006-02-27 Thread Anthony Balkissoon
Some more missing stuff from the BigDecimal class.  This spans 2 commits
because the first time I forgot the ChangeLog entry.

2006-02-27  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java: Added @throws clause to constructors.
(mathContext): Removed this unneeded field.
(BigDecimal(int, MathContext)): New constructor.
(BigDecimal(BigInteger, int, MathContext)): Likewise.
(multiply(BigDecimal, MathContext)): New method.
(negate(MathContext)): Likewise.
(plus(MathContext)): Likewise.
(numDigitsInLong): Fixed to properly handle negatives.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.11
diff -u -r1.17.2.11 BigDecimal.java
--- java/math/BigDecimal.java	24 Feb 2006 21:48:07 -	1.17.2.11
+++ java/math/BigDecimal.java	27 Feb 2006 19:42:03 -
@@ -41,7 +41,6 @@
 {
   private BigInteger intVal;
   private int scale;
-  private MathContext mathContext;
   private int precision = 0;
   private static final long serialVersionUID = 6108874887143696463L;
 
@@ -88,6 +87,27 @@
   }
   
   /**
+   * Constructs a BigDecimal using the BigDecimal(int) constructor and then
+   * rounds according to the MathContext.
+   * @param val the value for the initial (unrounded) BigDecimal
+   * @param mc the MathContext specifying the rounding
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal (int val, MathContext mc)
+  {
+this (val);
+if (mc.getPrecision() != 0)
+  {
+BigDecimal result = this.round(mc);
+this.intVal = result.intVal;
+this.scale = result.scale;
+this.precision = result.precision;
+  }
+  }
+  
+  /**
* Constructs a new BigDecimal whose unscaled value is val and whose
* scale is zero.
* @param val the value of the new BigDecimal
@@ -103,6 +123,8 @@
* and then rounds according to the MathContext.
* @param val the long from which we create the initial BigDecimal
* @param mc the MathContext that specifies the rounding behaviour
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
* @since 1.5
*/
   public BigDecimal (long val, MathContext mc)
@@ -124,7 +146,9 @@
* the number of digits in num, then rounding is necessary.
* @param num the unscaledValue, before rounding
* @param mc the MathContext that specifies the precision
-   * @since 1.5
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
+   * * @since 1.5
*/
   public BigDecimal (BigInteger num, MathContext mc)
   {
@@ -144,6 +168,8 @@
* according to the MathContext mc.
* @param val the String from which we construct the initial BigDecimal
* @param mc the MathContext that specifies the rounding
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY   
* @since 1.5
*/
   public BigDecimal (String val, MathContext mc)
@@ -179,12 +205,36 @@
 this.intVal = num;
 this.scale = scale;
   }
+  
+  /**
+   * Constructs a BigDecimal using the BigDecimal(BigInteger, int) 
+   * constructor and then rounds according to the MathContext.
+   * @param num the unscaled value of the unrounded BigDecimal
+   * @param scale the scale of the unrounded BigDecimal
+   * @param mc the MathContext specifying the rounding
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal (BigInteger num, int scale, MathContext mc)
+  {
+this (num, scale);
+if (mc.getPrecision() != 0)
+  {
+BigDecimal result = this.round(mc);
+this.intVal = result.intVal;
+this.scale = result.scale;
+this.precision = result.precision;
+  }
+  }
 
   /**
* Constructs a BigDecimal in the same way as BigDecimal(double) and then
* rounds according to the MathContext.
* @param num the double from which the initial BigDecimal is created
* @param mc the MathContext that specifies the rounding behaviour
+   * @throws ArithmeticException if the result is inexact but the rounding type
+   * is RoundingMode.UNNECESSARY 
* @since 1.5
*/
   public BigDecimal (double num, MathContext mc)
@@ -569,6 +619,21 @@
   {
 return new BigDecimal (intVal.multiply (val.intVal), scale + val.scale);
   }
+  
+  /**
+   * Returns a BigDecimal whose value is (this x val) before it is rounded
+   * according to the MathContext mc. 
+   * @param val the multiplicand
+   * @param mc the MathContext for rounding
+   * @return a new BigDecimal with value approximately (this x val)
+   * @throws ArithmeticException

[cp-patches] [generics] some BigDecimal fixes and new methods

2006-02-27 Thread Anthony Balkissoon
More stuff.  Sorry for not sending this BigDecimal stuff all at once but
my test cases are small and I prefer to get the stuff committed once its
been tested.  Also helps me use JAPI to determine what needs to be done.

2006-02-27  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java: Replaced occurences of BigInteger.valueOf
with BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN where appropriate.
(add(BigDecimal, MathContext)): New method.
(subtract(BigDecimal, MathContext)): Likewise.
(precision): Fixed to correctly handle BigIntegers with more than 19
digits.
(pow(int, MathContext)): New method.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.12
diff -u -r1.17.2.12 BigDecimal.java
--- java/math/BigDecimal.java	27 Feb 2006 19:49:07 -	1.17.2.12
+++ java/math/BigDecimal.java	27 Feb 2006 21:31:00 -
@@ -49,21 +49,21 @@
* @since 1.5
*/
   public static final BigDecimal ZERO = 
-new BigDecimal (BigInteger.valueOf (0), 0);
+new BigDecimal (BigInteger.ZERO, 0);
 
   /**
* The constant one as a BigDecimal with scale zero.
* @since 1.5
*/
   public static final BigDecimal ONE = 
-new BigDecimal (BigInteger.valueOf (1), 0);
+new BigDecimal (BigInteger.ONE, 0);
 
   /**
* The constant ten as a BigDecimal with scale zero.
* @since 1.5
*/
   public static final BigDecimal TEN = 
-new BigDecimal (BigInteger.valueOf (10), 0);
+new BigDecimal (BigInteger.TEN, 0);
 
   public static final int ROUND_UP = 0;
   public static final int ROUND_DOWN = 1;
@@ -603,18 +603,48 @@
 BigInteger op1 = intVal;
 BigInteger op2 = val.intVal;
 if (scale  val.scale)
-  op1 = op1.multiply (BigInteger.valueOf (10).pow (val.scale - scale));
+  op1 = op1.multiply (BigInteger.TEN.pow (val.scale - scale));
 else if (scale  val.scale)
-  op2 = op2.multiply (BigInteger.valueOf (10).pow (scale - val.scale));
+  op2 = op2.multiply (BigInteger.TEN.pow (scale - val.scale));
 
 return new BigDecimal (op1.add (op2), Math.max (scale, val.scale));
   }
+  
+  /**
+   * Returns a BigDecimal whose value is found first by calling the 
+   * method add(val) and then by rounding according to the MathContext mc.
+   * @param val the augend
+   * @param mc the MathContext for rounding
+   * @throws ArithmeticException if the value is inexact but the rounding is
+   * RoundingMode.UNNECESSARY
+   * @return codethis/code + codeval/code, rounded if need be
+   * @since 1.5
+   */
+  public BigDecimal add (BigDecimal val, MathContext mc)
+  {
+return add(val).round(mc);
+  }
 
   public BigDecimal subtract (BigDecimal val) 
   {
 return this.add(val.negate());
   }
 
+  /**
+   * Returns a BigDecimal whose value is found first by calling the 
+   * method subtract(val) and then by rounding according to the MathContext mc.
+   * @param val the subtrahend
+   * @param mc the MathContext for rounding
+   * @throws ArithmeticException if the value is inexact but the rounding is
+   * RoundingMode.UNNECESSARY
+   * @return codethis/code - codeval/code, rounded if need be
+   * @since 1.5
+   */
+  public BigDecimal subtract (BigDecimal val, MathContext mc)
+  {
+return subtract(val).round(mc);
+  }
+
   public BigDecimal multiply (BigDecimal val) 
   {
 return new BigDecimal (intVal.multiply (val.intVal), scale + val.scale);
@@ -661,11 +691,11 @@
   {
 	// Effectively increase the scale of val to avoid an
 	// ArithmeticException for a negative power.
-valIntVal = valIntVal.multiply (BigInteger.valueOf (10).pow (-power));
+valIntVal = valIntVal.multiply (BigInteger.TEN.pow (-power));
 	power = 0;
   }
 
-BigInteger dividend = intVal.multiply (BigInteger.valueOf (10).pow (power));
+BigInteger dividend = intVal.multiply (BigInteger.TEN.pow (power));
 
 BigInteger parts[] = dividend.divideAndRemainder (valIntVal);
 
@@ -674,7 +704,7 @@
   return new BigDecimal (unrounded, newScale);
 
 if (roundingMode == ROUND_UNNECESSARY)
-  throw new ArithmeticException (newScale is not large enough);
+  throw new ArithmeticException (Rounding necessary);
 
 int sign = intVal.signum () * valIntVal.signum ();
 
@@ -726,9 +756,9 @@
   return intVal.compareTo (val.intVal);
 
 BigInteger thisParts[] = 
-  intVal.divideAndRemainder (BigInteger.valueOf (10).pow (scale));
+  intVal.divideAndRemainder (BigInteger.TEN.pow (scale));
 BigInteger valParts[] =
-  val.intVal.divideAndRemainder (BigInteger.valueOf (10).pow (val.scale));
+  val.intVal.divideAndRemainder (BigInteger.TEN.pow (val.scale));
 
 int compare;
 if ((compare = thisParts[0].compareTo (valParts[0])) != 0)
@@ -737,15 +767,15 @@
 // quotients are the same, so compare remainders
 
 // remove

[cp-patches] [generics] (even) more BigDecimal methods

2006-02-24 Thread Anthony Balkissoon
Fixed a problem with toBigInteger, it was crashing when the scale was
negative.  Also wrote the new methods toBigIntegerExact and
stripTrailingZeros.

2006-02-24  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java
(toBigInteger): Fixed problem where this method couldn't handle 
negative values for scale.
(toBigIntegerExact): New method.
(stripTrailingZeros): Likewise.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.9
diff -u -r1.17.2.9 BigDecimal.java
--- java/math/BigDecimal.java	23 Feb 2006 22:39:04 -	1.17.2.9
+++ java/math/BigDecimal.java	24 Feb 2006 19:43:16 -
@@ -1017,16 +1017,78 @@
 return sb.toString();
   }
   
+  /**
+   * Converts this BigDecimal to a BigInteger.  Any fractional part will
+   * be discarded.
+   * @return a BigDecimal whose value is equal to floor[this]
+   */
   public BigInteger toBigInteger () 
   {
-return scale == 0 ? intVal :
-  intVal.divide (BigInteger.valueOf (10).pow (scale));
+// If scale  0 then we must divide, if scale  0 then we must multiply,
+// and if scale is zero then we just return intVal;
+if (scale  0)
+  return intVal.divide (BigInteger.valueOf (10).pow (scale));
+else if (scale  0)
+  return intVal.multiply(BigInteger.valueOf(10).pow(-scale));
+return intVal;
+  }
+  
+  /**
+   * Converts this BigDecimal into a BigInteger, throwing an 
+   * ArithmeticException if the conversion is not exact.
+   * @return a BigInteger whose value is equal to the value of this BigDecimal
+   * @since 1.5
+   */
+  public BigInteger toBigIntegerExact()
+  {
+if (scale  0)
+  {
+// If we have to divide, we must check if the result is exact.
+BigInteger[] result = 
+  intVal.divideAndRemainder(BigInteger.valueOf(10).pow(scale));
+if (result[1].equals(BigInteger.ZERO))
+  return result[0];
+throw new ArithmeticException(No exact BigInteger representation);
+  }
+else if (scale  0)
+  // If we're multiplying instead, then we needn't check for exactness.
+  return intVal.multiply(BigInteger.valueOf(10).pow(-scale));
+// If the scale is zero we can simply return intVal.
+return intVal;
   }
 
   public int intValue () 
   {
 return toBigInteger ().intValue ();
   }
+  
+  /**
+   * Returns a BigDecimal which is numerically equal to this BigDecimal but 
+   * with no trailing zeros in the representation.  For example, if this 
+   * BigDecimal has [unscaledValue, scale] = [6313000, 4] this method returns
+   * a BigDecimal with [unscaledValue, scale] = [6313, 1].  As another 
+   * example, [12400, -2] would become [124, -4].
+   * @return a numerically equal BigDecimal with no trailing zeros
+   */
+  public BigDecimal stripTrailingZeros()  
+  {
+String intValStr = intVal.toString();
+int newScale = scale;
+int pointer = intValStr.length() - 1;
+// This loop adjusts pointer which will be used to give us the substring
+// of intValStr to use in our new BigDecimal, and also accordingly
+// adjusts the scale of our new BigDecimal.
+while (intValStr.charAt(pointer) == '0')
+  {
+pointer --;
+newScale --;
+  }
+// Create a new BigDecimal with the appropriate substring and then
+// set its scale.
+BigDecimal result = new BigDecimal(intValStr.substring(0, pointer + 1));
+result.scale = newScale;
+return result;
+  }
 
   public long longValue ()
   {


[cp-patches] [generics] (still) more BigDecimal methods

2006-02-24 Thread Anthony Balkissoon
I tested the rounding methods and made a fix to the round() method.
Satisfied with this I implemented several constructors that required
rounding facilities and the abs(MathContext) method that also required
rounding.

2006-02-24  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(BigDecimal(long, MathContext)): New constructor.
(BigDecimal(BigInteger, MathContext)): Likewise.
(BigDecimal(String, MathContext)): Likewise.
(BigDecimal(double, MathContext)): Likewise.
(round): Fixed a typo where the precision field was used instead of a
call to the precision method, and also store the new precision in the
returned BigDecimal.
(abs(MathContext)): New method.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.10
diff -u -r1.17.2.10 BigDecimal.java
--- java/math/BigDecimal.java	24 Feb 2006 19:44:30 -	1.17.2.10
+++ java/math/BigDecimal.java	24 Feb 2006 21:45:04 -
@@ -99,6 +99,66 @@
   }
   
   /**
+   * Constructs a BigDecimal from the long in the same way as BigDecimal(long)
+   * and then rounds according to the MathContext.
+   * @param val the long from which we create the initial BigDecimal
+   * @param mc the MathContext that specifies the rounding behaviour
+   * @since 1.5
+   */
+  public BigDecimal (long val, MathContext mc)
+  {
+this(val);
+if (mc.getPrecision() != 0)
+  {
+BigDecimal result = this.round(mc);
+this.intVal = result.intVal;
+this.scale = result.scale;
+this.precision = result.precision;
+  }
+  }
+  
+  /**
+   * Constructs a BigDecimal whose value is given by num rounded according to 
+   * mc.  Since num is already a BigInteger, the rounding refers only to the 
+   * precision setting in mc, if mc.getPrecision() returns an int lower than
+   * the number of digits in num, then rounding is necessary.
+   * @param num the unscaledValue, before rounding
+   * @param mc the MathContext that specifies the precision
+   * @since 1.5
+   */
+  public BigDecimal (BigInteger num, MathContext mc)
+  {
+this (num, 0);
+if (mc.getPrecision() != 0)
+  {
+BigDecimal result = this.round(mc);
+this.intVal = result.intVal;
+this.scale = result.scale;
+this.precision = result.precision;
+  }
+  }
+  
+  /**
+   * Constructs a BigDecimal from the String val according to the same
+   * rules as the BigDecimal(String) constructor and then rounds 
+   * according to the MathContext mc.
+   * @param val the String from which we construct the initial BigDecimal
+   * @param mc the MathContext that specifies the rounding
+   * @since 1.5
+   */
+  public BigDecimal (String val, MathContext mc)
+  {
+this (val);
+if (mc.getPrecision() != 0)
+  {
+BigDecimal result = this.round(mc);
+this.intVal = result.intVal;
+this.scale = result.scale;
+this.precision = result.precision;
+  }
+  }
+  
+  /**
* Constructs a BigDecimal whose unscaled value is num and whose
* scale is zero.
* @param num the value of the new BigDecimal
@@ -120,6 +180,25 @@
 this.scale = scale;
   }
 
+  /**
+   * Constructs a BigDecimal in the same way as BigDecimal(double) and then
+   * rounds according to the MathContext.
+   * @param num the double from which the initial BigDecimal is created
+   * @param mc the MathContext that specifies the rounding behaviour
+   * @since 1.5
+   */
+  public BigDecimal (double num, MathContext mc)
+  {
+this (num);
+if (mc.getPrecision() != 0)
+  {
+BigDecimal result = this.round(mc);
+this.intVal = result.intVal;
+this.scale = result.scale;
+this.precision = result.precision;
+  }
+  }
+  
   public BigDecimal (double num) throws NumberFormatException 
   {
 if (Double.isInfinite (num) || Double.isNaN (num))
@@ -703,7 +782,7 @@
   public BigDecimal round(MathContext mc)
   {
 int mcPrecision = mc.getPrecision();
-int numToChop = precision - mcPrecision;
+int numToChop = precision() - mcPrecision;
 // If mc specifies not to chop any digits or if we've already chopped 
 // enough digits (say by using a MathContext in the constructor for this
 // BigDecimal) then just return this.
@@ -716,6 +795,7 @@
   new BigDecimal(BigInteger.valueOf((long)Math.pow(10, numToChop)));
 BigDecimal rounded = divide(div, scale, mc.getRoundingMode().ordinal());
 rounded.scale -= numToChop;
+rounded.precision = mcPrecision;
 return rounded;
   }
   
@@ -1161,5 +1241,16 @@
 return result;
   }
   
-
+  /**
+   * Returns a BigDecimal whose value is the absolute value of this BigDecimal
+   * with rounding according to the given MathContext.
+   * @param mc the MathContext
+   * @return the new BigDecimal
+   */
+  public

[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-02-24 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/23 18:54:51

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-23  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(toString): Rewrote this method to behave as specified.  Added API
comments to explain behaviour.
(scaleByPowerOfTen): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.202tr2=1.2386.2.203r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.7tr2=1.17.2.8r1=textr2=text




[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-02-24 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/23 22:39:04

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-23  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(toString): Fixed a problem where the negative sign was being displayed
twice in the exponent.
(toEngineeringString): New method.
(toPlainString): Likewise.
(pow): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.203tr2=1.2386.2.204r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.8tr2=1.17.2.9r1=textr2=text




[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-02-24 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/24 19:44:30

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-24  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java
(toBigInteger): Fixed problem where this method couldn't handle
negative values for scale.
(toBigIntegerExact): New method.
(stripTrailingZeros): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.204tr2=1.2386.2.205r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.9tr2=1.17.2.10r1=textr2=text




[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-02-24 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/24 21:48:07

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-24  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(BigDecimal(long, MathContext)): New constructor.
(BigDecimal(BigInteger, MathContext)): Likewise.
(BigDecimal(String, MathContext)): Likewise.
(BigDecimal(double, MathContext)): Likewise.
(round): Fixed a typo where the precision field was used instead of a
call to the precision method, and also store the new precision in the
returned BigDecimal.
(abs(MathContext)): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.205tr2=1.2386.2.206r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.10tr2=1.17.2.11r1=textr2=text




[cp-patches] [generics] more BigDecimal stuff

2006-02-23 Thread Anthony Balkissoon
I wrote the 'scaleByPowerOfTen' method and when testing it noticed that
the toString method wasn't behaving as specified, so I fixed it and
added the comments explaining how it should behave.

2006-02-23  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(toString): Rewrote this method to behave as specified.  Added API
comments to explain behaviour.
(scaleByPowerOfTen): New method.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /sources/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.7
diff -u -r1.17.2.7 BigDecimal.java
--- java/math/BigDecimal.java	22 Feb 2006 21:56:44 -	1.17.2.7
+++ java/math/BigDecimal.java	23 Feb 2006 18:51:53 -
@@ -783,37 +783,82 @@
 // 18 or 19 digits.
 return (l  100L) ? 18 : 19;
   }
-  
-  public String toString () 
+
+  /**
+   * Returns the String representation of this BigDecimal, using scientific
+   * notation if necessary.  The following steps are taken to generate
+   * the result:
+   * 
+   * 1. the BigInteger unscaledValue's toString method is called and if
+   * codescale == 0code is returned.
+   * 2. an codeint adjExp/code is created which is equal to the negation
+   * of codescale/code plus the number of digits in the unscaled value, 
+   * minus one.
+   * 3. if codescale = 0  adjExp = -6/code then we represent this 
+   * BigDecimal without scientific notation.  A decimal is added if the 
+   * scale is positive and zeros are prepended as necessary.
+   * 4. if scale is negative or adjExp is less than -6 we use scientific
+   * notation.  If the unscaled value has more than one digit, a decimal 
+   * as inserted after the first digit, the character 'E' is appended
+   * and adjExp is appended.
+   */
+  public String toString()
   {
+// bigStr is the String representation of the unscaled value.  If
+// scale is zero we simply return this.
 String bigStr = intVal.toString();
-if (scale == 0) 
+if (scale == 0)
   return bigStr;
 
-boolean negative = (bigStr.charAt(0) == '-');
+// This is the adjusted exponent described above.
+int adjExp = -scale + (numDigitsInLong(intVal.longValue()) - 1);
+StringBuilder val = new StringBuilder();
 
-int point = bigStr.length() - scale - (negative ? 1 : 0);
-
-StringBuffer sb = new StringBuffer(bigStr.length() + 2 +
-   (point = 0 ? (-point + 1) : 0));
-if (point = 0)
+if (scale = 0  adjExp = -6)
   {
-if (negative)
-  sb.append('-');
-sb.append('0').append('.');
-while (point  0)
+// Convert to character form without scientific notation.
+boolean negative = (bigStr.charAt(0) == '-');
+int point = bigStr.length() - scale - (negative ? 1 : 0);
+if (point = 0)
+  {
+// Zeros need to be prepended to the StringBuilder.
+if (negative)
+  val.append('-');
+// Prepend a '0' and a '.' and then as many more '0's as necessary.
+val.append('0').append('.');
+while (point  0)
+  {
+val.append('0');
+point++;
+  }
+// Append the unscaled value.
+val.append(bigStr.substring(negative ? 1 : 0));
+  }
+else
   {
-sb.append('0');
-point++;
+// No zeros need to be prepended so the String is simply the 
+// unscaled value with the decimal point inserted.
+val.append(bigStr);
+val.insert(point + (negative ? 1 : 0), '.');
   }
-sb.append(bigStr.substring(negative ? 1 : 0));
   }
 else
   {
-	sb.append(bigStr);
-	sb.insert(point + (negative ? 1 : 0), '.');
+// We must use scientific notation to represent this BigDecimal.
+val.append(bigStr);
+// If there is more than one digit in the unscaled value we put a 
+// decimal after the first digit.
+if (bigStr.length()  1)
+  val.insert(1, '.');
+// And then append 'E' and the exponent - adjExp.
+val.append('E');
+if (adjExp  0)
+  val.append('-');
+else
+  val.append('+');
+val.append(adjExp);
   }
-return sb.toString();
+return val.toString();
   }
 
   public BigInteger toBigInteger () 
@@ -868,4 +913,18 @@
   throw new NumberFormatException(argument cannot be NaN or infinite.);
 return new BigDecimal(Double.toString(val));
   }
+  
+  /**
+   * Returns a BigDecimal whose numerical value is the numerical value
+   * of this BigDecimal multiplied by 10 to the power of coden/code. 
+   * @param n the power of ten
+   * @return the new BigDecimal
+   * @since 1.5
+   */
+  public BigDecimal scaleByPowerOfTen(int n)
+  {
+BigDecimal result = new BigDecimal(intVal, scale - n);
+result.precision

[cp-patches] [generics] more BigDecimal methods

2006-02-23 Thread Anthony Balkissoon
ChangeLog says it all.

2006-02-23  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(toString): Fixed a problem where the negative sign was being displayed
twice in the exponent.
(toEngineeringString): New method.
(toPlainString): Likewise.
(pow): Likewise.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.8
diff -u -r1.17.2.8 BigDecimal.java
--- java/math/BigDecimal.java	23 Feb 2006 18:54:51 -	1.17.2.8
+++ java/math/BigDecimal.java	23 Feb 2006 22:36:15 -
@@ -850,17 +850,173 @@
 // decimal after the first digit.
 if (bigStr.length()  1)
   val.insert(1, '.');
-// And then append 'E' and the exponent - adjExp.
+// And then append 'E' and the exponent (adjExp).
 val.append('E');
-if (adjExp  0)
-  val.append('-');
-else
+if (adjExp = 0)
   val.append('+');
 val.append(adjExp);
   }
 return val.toString();
   }
 
+  /**
+   * Returns the String representation of this BigDecimal, using engineering
+   * notation if necessary.  This is similar to toString() but when exponents 
+   * are used the exponent is made to be a multiple of 3 such that the integer
+   * part is between 1 and 999.
+   * 
+   * @return a String representation of this BigDecimal in engineering notation
+   * @since 1.5
+   */
+  public String toEngineeringString()
+  {
+// bigStr is the String representation of the unscaled value.  If
+// scale is zero we simply return this.
+String bigStr = intVal.toString();
+if (scale == 0)
+  return bigStr;
+
+// This is the adjusted exponent described above.
+int adjExp = -scale + (numDigitsInLong(intVal.longValue()) - 1);
+StringBuilder val = new StringBuilder();
+
+if (scale = 0  adjExp = -6)
+  {
+// Convert to character form without scientific notation.
+boolean negative = (bigStr.charAt(0) == '-');
+int point = bigStr.length() - scale - (negative ? 1 : 0);
+if (point = 0)
+  {
+// Zeros need to be prepended to the StringBuilder.
+if (negative)
+  val.append('-');
+// Prepend a '0' and a '.' and then as many more '0's as necessary.
+val.append('0').append('.');
+while (point  0)
+  {
+val.append('0');
+point++;
+  }
+// Append the unscaled value.
+val.append(bigStr.substring(negative ? 1 : 0));
+  }
+else
+  {
+// No zeros need to be prepended so the String is simply the 
+// unscaled value with the decimal point inserted.
+val.append(bigStr);
+val.insert(point + (negative ? 1 : 0), '.');
+  }
+  }
+else
+  {
+// We must use scientific notation to represent this BigDecimal.
+// The exponent must be a multiple of 3 and the integer part
+// must be between 1 and 999.
+val.append(bigStr);
+int zeros = adjExp % 3;
+int dot = 1;
+if (adjExp  0)
+  {
+// If the exponent is positive we just move the decimal to the
+// right and decrease the exponent until it is a multiple of 3.
+dot += zeros;
+adjExp -= zeros;
+  }
+else
+  {
+// If the exponent is negative then we move the dot to the right
+// and decrease the exponent (increase its magnitude) until 
+// it is a multiple of 3.  Note that this is not adjExp -= zeros
+// because the mod operator doesn't give us the distance to the 
+// correct multiple of 3.  (-5 mod 3) is -2 but the distance from
+// -5 to the correct multiple of 3 (-6) is 1, not 2.
+if (zeros == -2)
+  {
+dot += 1;
+adjExp -= 1;
+  }
+else if (zeros == -1)
+  {
+dot += 2;
+adjExp -= 2;
+  }
+  }
+
+// Either we have to append zeros because, for example, 1.1E+5 should
+// be 110E+3, or we just have to put the decimal in the right place.
+if (dot  val.length())
+  {
+while (dot  val.length())
+  val.append('0');
+  }
+else if (bigStr.length()  dot)
+  val.insert(dot, '.');
+
+// And then append 'E' and the exponent (adjExp).
+val.append('E');
+if (adjExp = 0)
+  val.append('+');
+val.append(adjExp);
+  }
+return val.toString();
+  }
+  
+  /**
+   * Returns a String representation of this BigDecimal without using 
+   * scientific notation.  This is how

[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-02-23 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/22 21:56:44

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-22  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(BigDecimal(char[], int, int, MathContext)): New constructor.
(BigDecimal(char[], MathContext)): Likewise.
(BigDecimal(char[])): Likewise.
(BigDecimal(char[], int, int)): Likewise.
(BigDecimal(String)): Fixed handling of exponent and scale.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.201tr2=1.2386.2.202r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.6tr2=1.17.2.7r1=textr2=text




[cp-patches] [generics] New BigDecimal constructors

2006-02-22 Thread Anthony Balkissoon
I added some of the missing constructors in BigDecimal and fixed a small
problem with one of the old ones.  

The BigDecimal(char[], int, int) constructor is the meat of this patch,
which I adapted from the BigDecimal(String) constructor but fixed some
problems and commented thoroughly.

More BigDecimal stuff to follow, the rounding is still yet untested.

2006-02-22  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(BigDecimal(char[], int, int, MathContext)): New constructor.
(BigDecimal(char[], MathContext)): Likewise.
(BigDecimal(char[])): Likewise.
(BigDecimal(char[], int, int)): Likewise.
(BigDecimal(String)): Fixed handling of exponent and scale.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.6
diff -u -r1.17.2.6 BigDecimal.java
--- java/math/BigDecimal.java	21 Feb 2006 21:14:59 -	1.17.2.6
+++ java/math/BigDecimal.java	22 Feb 2006 21:51:56 -
@@ -170,6 +170,209 @@
   }
   }
 
+  /**
+   * Constructs a BigDecimal from the char subarray and rounding 
+   * according to the MathContext.
+   * @param in the char array
+   * @param offset the start of the subarray
+   * @param len the length of the subarray
+   * @param mc the MathContext for rounding
+   * @throws NumberFormatException if the char subarray is not a valid 
+   * BigDecimal representation
+   * @throws ArithmeticException if the result is inexact but the rounding 
+   * mode is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal(char[] in, int offset, int len, MathContext mc)
+  {
+this(in, offset, len);
+// If mc has precision other than zero then we must round.
+if (mc.getPrecision() != 0)
+  {
+BigDecimal temp = this.round(mc);
+this.intVal = temp.intVal;
+this.scale = temp.scale;
+this.precision = temp.precision;
+  }
+  }
+  
+  /**
+   * Constructs a BigDecimal from the char array and rounding according
+   * to the MathContext. 
+   * @param in the char array
+   * @param mc the MathContext
+   * @throws NumberFormatException if codein/code is not a valid BigDecimal
+   * representation
+   * @throws ArithmeticException if the result is inexact but the rounding mode
+   * is RoundingMode.UNNECESSARY
+   * @since 1.5
+   */
+  public BigDecimal(char[] in, MathContext mc)
+  {
+this(in, 0, in.length);
+// If mc has precision other than zero then we must round.
+if (mc.getPrecision() != 0)
+  {
+BigDecimal temp = this.round(mc);
+this.intVal = temp.intVal;
+this.scale = temp.scale;
+this.precision = temp.precision;
+  } 
+  }
+  
+  /**
+   * Constructs a BigDecimal from the given char array, accepting the same
+   * sequence of characters as the BigDecimal(String) constructor.
+   * @param in the char array
+   * @throws NumberFormatException if codein/code is not a valid BigDecimal
+   * representation
+   * @since 1.5
+   */
+  public BigDecimal(char[] in)
+  {
+this(in, 0, in.length);
+  }
+  
+  /**
+   * Constructs a BigDecimal from a char subarray, accepting the same sequence
+   * of characters as the BigDecimal(String) constructor.  
+   * @param in the char array
+   * @param offset the start of the subarray
+   * @param len the length of the subarray
+   * @throws NumberFormatException if codein/code is not a valid
+   * BigDecimal representation.
+   * @since 1.5
+   */
+  public BigDecimal(char[] in, int offset, int len)
+  {
+//  start is the index into the char array where the significand starts
+int start = offset;
+//  end is one greater than the index of the last character used
+int end = offset + len;
+//  point is the index into the char array where the exponent starts
+//  (or, if there is no exponent, this is equal to end)
+int point = offset;
+//  dot is the index into the char array where the decimal point is 
+//  found, or -1 if there is no decimal point
+int dot = -1;
+
+//  The following examples show what these variables mean.  Note that
+//  point and dot don't yet have the correct values, they will be 
+//  properly assigned in a loop later on in this method.
+//
+//  Example 1
+//
+// +  1  0  2  .  4  6  9
+//  __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+//
+//  offset = 2, len = 8, start = 3, dot = 6, point = end = 10
+//
+//  Example 2
+//
+// +  2  3  4  .  6  1  3  E  -  1
+//  __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+//
+//  offset = 2, len = 11, start = 3, dot = 6, point = 10, end = 13
+//
+//  Example 3
+//
+// -  1  2  3  4  5  e  7  
+//  __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
+//
+//  offset = 2, len = 8, start = 3, dot = -1, point = 8, end = 10

Re: [cp-patches] [generics] RFC: new Enum java.math.RoundingMode

2006-02-21 Thread Anthony Balkissoon
This is committed as:

2006-02-21  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/MathContext.java: New class.
* java/math/RoundingMode: New Enum. 

In response to Andrew and Tom:

Andrew: Yes, the only thing restricting this to the generics branch is
the Enum.  But reading Sun's arguments in favour of Enums
(http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html) , they
make some reasonable points.  So maybe the pity isn't that they use
Enums here but that we're still not able to handle them on the trunk.
I'm not sure how far away that is though - from what I understand it's
because not all the compilers we use support the new language features?

Tom: Yeah, the header template isn't there, and also the Eclipse builder
options don't seem to be working properly.  Everytime I made any small
change it would do an entire rebuild, running autogen, configure,
ClasspathHeaders, BuildNative, etc.
Andrew Overholt gave it a quick look for me but we didn't see the
problem so we just worked around it on my local machine.


That's all for now, I should have some more java.math stuff ready soon.

--Tony

On Tue, 2006-02-21 at 08:32 +, Andrew John Hughes wrote:
 On Mon, 2006-02-20 at 17:33 -0500, Anthony Balkissoon wrote:
  On Mon, 2006-02-20 at 15:09 -0500, Anthony Balkissoon wrote:
   This is RFC because it's my first commit to the generics branch and I
   just want to make sure there aren't any special procedures I forgot. 
   
   2006-02-20  Anthony Balkissoon  [EMAIL PROTECTED]
   
 * java/math/RoundingMode: New Enum.
   
   --Tony
  
  
  This is replaced by:
  2006-02-20  Anthony Balkissoon  [EMAIL PROTECTED]
  
  * java/math/MathContext.java: New class.
  * java/math/RoundingMode: New Enum.
  
  Also, I forgot to put the GNU Classpath header in RoundingMode, but this
  patch includes it.  Comments are still appreciated.  I'll commit this
  tomorrow if no one objects.
  
  --Tony
 
 Looks fine to me -- the header would have been my only comment.  Of
 course, I'm assuming it applies cleanly and compiles... ;)
 
 It's a pity this new math stuff uses an enum for RoundingMode, because
 AFAICS that's the only thing that restricts this to the generics branch.
Index: java/math/MathContext.java
===
RCS file: java/math/MathContext.java
diff -N java/math/MathContext.java
--- /dev/null	1 Jan 1970 00:00:00 -
+++ java/math/MathContext.java	21 Feb 2006 15:32:37 -
@@ -0,0 +1,198 @@
+/* MathContext.java -- 
+   Copyright (C) 1999, 2000, 2002, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.math;
+
+import java.io.Serializable;
+
+/**
+ * Immutable objects describing settings such as rounding mode and digit
+ * precision for numerical operations such as those in the BigDecimal class.
+ * @author Anthony Balkissoon abalkiss at redhat dot com
+ *
+ */
+public final class MathContext implements Serializable
+{
+  /** A MathContext for unlimited precision arithmetic * */
+  public static final MathContext UNLIMITED = 
+new MathContext(0, RoundingMode.HALF_UP);
+  
+  /**
+   * A MathContext for the IEEE 754R Decimal32 format - 7 digit preicision and
+   * HALF_EVEN rounding.
+   */
+  public static final MathContext DECIMAL32 = 
+new

[cp-patches] [generics] new BigDecimal methods.

2006-02-21 Thread Anthony Balkissoon
Here are some of the missing BigDecimal methods.  More are coming but
I'm committing these now so the JAPI results will be more readable.  

2006-02-21  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(mathContext): New field.
(precision): Likewise.
(BigDecimal(int)): New constructor.
(BigDecimal(long)): Likewise.
(BigDecimal(BigInteger)): Added API docs.
(BigDecimal(BigInteger, int)): Removed incorrect NumberFormatException
and added API docs.
(plus): New method.
(round): Likewise.
(precision): Likewise.
(valueOf): Likewise.
(numDigitsInLong): New implementation method.

--Tony
Index: java/math/BigDecimal.java
===
RCS file: /cvsroot/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.17.2.5
diff -u -r1.17.2.5 BigDecimal.java
--- java/math/BigDecimal.java	2 Nov 2005 00:43:34 -	1.17.2.5
+++ java/math/BigDecimal.java	21 Feb 2006 21:07:26 -
@@ -41,6 +41,8 @@
 {
   private BigInteger intVal;
   private int scale;
+  private MathContext mathContext;
+  private int precision = 0;
   private static final long serialVersionUID = 6108874887143696463L;
 
   /**
@@ -73,15 +75,47 @@
   public static final int ROUND_HALF_EVEN = 6;
   public static final int ROUND_UNNECESSARY = 7;
 
+  /**
+   * Constructs a new BigDecimal whose unscaled value is val and whose
+   * scale is zero.
+   * @param val the value of the new BigDecimal
+   * @since 1.5
+   */
+  public BigDecimal (int val)
+  {
+this.intVal = BigInteger.valueOf(val);
+this.scale = 0;
+  }
+  
+  /**
+   * Constructs a new BigDecimal whose unscaled value is val and whose
+   * scale is zero.
+   * @param val the value of the new BigDecimal
+   */
+  public BigDecimal (long val)
+  {
+this.intVal = BigInteger.valueOf(val);
+this.scale = 0;
+  }
+  
+  /**
+   * Constructs a BigDecimal whose unscaled value is num and whose
+   * scale is zero.
+   * @param num the value of the new BigDecimal
+   */
   public BigDecimal (BigInteger num) 
   {
 this (num, 0);
   }
 
-  public BigDecimal (BigInteger num, int scale) throws NumberFormatException 
+  /**
+   * Constructs a BigDecimal whose unscaled value is num and whose
+   * scale is scale.
+   * @param num
+   * @param scale
+   */
+  public BigDecimal (BigInteger num, int scale)
   {
-if (scale  0) 
-  throw new NumberFormatException (scale of  + scale +  is  0);
 this.intVal = num;
 this.scale = scale;
   }
@@ -455,7 +489,108 @@
   {
 return new BigDecimal (intVal.negate (), scale);
   }
+  
+  /**
+   * Returns this BigDecimal.  This is included for symmetry with the 
+   * method negate().
+   * @return this
+   * @since 1.5
+   */
+  public BigDecimal plus()
+  {
+return this;
+  }
+  
+  /**
+   * Returns a BigDecimal which is this BigDecimal rounded according to the
+   * MathContext rounding settings.
+   * @param mc the MathContext that tells us how to round
+   * @return the rounded BigDecimal
+   */
+  public BigDecimal round(MathContext mc)
+  {
+int mcPrecision = mc.getPrecision();
+int numToChop = precision - mcPrecision;
+// If mc specifies not to chop any digits or if we've already chopped 
+// enough digits (say by using a MathContext in the constructor for this
+// BigDecimal) then just return this.
+if (mcPrecision == 0 || numToChop = 0)
+  return this;
+
+// Make a new BigDecimal which is the correct power of 10 to chop off
+// the required number of digits and then call divide.
+BigDecimal div = 
+  new BigDecimal(BigInteger.valueOf((long)Math.pow(10, numToChop)));
+BigDecimal rounded = divide(div, scale, mc.getRoundingMode().ordinal());
+rounded.scale -= numToChop;
+return rounded;
+  }
+  
+  /**
+   * Returns the precision of this BigDecimal (the number of digits in the
+   * unscaled value).  The precision of a zero value is 1.
+   * @return the number of digits in the unscaled value, or 1 if the value 
+   * is zero.
+   */
+  public int precision()
+  {
+if (precision == 0)
+  precision = numDigitsInLong(intVal.longValue());
+return precision;
+  }
 
+  /**
+   * This method determines the number of digits in the long value l. 
+   * @param l the long value
+   * @return the number of digits in l
+   */
+  private static int numDigitsInLong(long l)
+  {
+// We divide up the range in a binary fashion, this first if
+// takes care of numbers with 1 to 9 digits.
+if (l  10L)
+{
+  // This if is for numbers with 1 to 5 digits.
+  if (l  10L)
+{
+  if (l  100L)
+return (l  10L) ? 1 : 2;
+  if (l  1L)
+return (l  1000L) ? 3 : 4;
+  return 5;
+}
+  // Here we handle numbers with 6 to 9 digits.
+  if (l  1000L)
+return (l  100L) ? 6 : 7

[commit-cp] classpath ./ChangeLog java/math/BigDecimal.java [generics-branch]

2006-02-21 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: generics-branch
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/21 21:14:59

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-02-21  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/BigDecimal.java:
(mathContext): New field.
(precision): Likewise.
(BigDecimal(int)): New constructor.
(BigDecimal(long)): Likewise.
(BigDecimal(BigInteger)): Added API docs.
(BigDecimal(BigInteger, int)): Removed incorrect NumberFormatException
and added API docs.
(plus): New method.
(round): Likewise.
(precision): Likewise.
(valueOf): Likewise.
(numDigitsInLong): New implementation method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?only_with_tag=generics-branchtr1=1.2386.2.200tr2=1.2386.2.201r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/math/BigDecimal.java.diff?only_with_tag=generics-branchtr1=1.17.2.5tr2=1.17.2.6r1=textr2=text




[cp-patches] [generics] RFC: new Enum java.math.RoundingMode

2006-02-20 Thread Anthony Balkissoon
This is RFC because it's my first commit to the generics branch and I
just want to make sure there aren't any special procedures I forgot. 

2006-02-20  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/RoundingMode: New Enum.

--Tony
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: java/math/RoundingMode.java
===
RCS file: java/math/RoundingMode.java
diff -N java/math/RoundingMode.java
--- /dev/null	1 Jan 1970 00:00:00 -
+++ java/math/RoundingMode.java	20 Feb 2006 20:07:39 -
@@ -0,0 +1,40 @@
+package java.math;
+
+public enum RoundingMode
+{
+  UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY;
+  
+  /**
+   * Returns the RoundingMode object corresponding to the legacy rounding modes
+   * in BigDecimal.
+   * @param rm the legacy rounding mode
+   * @return the corresponding RoundingMode
+   */
+  public static RoundingMode valueOf(int rm)
+  {
+switch (rm)
+  {
+  case BigDecimal.ROUND_CEILING:
+return CEILING;
+  case BigDecimal.ROUND_FLOOR:
+return FLOOR;
+  case BigDecimal.ROUND_DOWN:
+return DOWN;
+  case BigDecimal.ROUND_UP:
+return UP;
+  case BigDecimal.ROUND_HALF_UP:
+return HALF_UP;
+  case BigDecimal.ROUND_HALF_DOWN:
+return HALF_DOWN;
+  case BigDecimal.ROUND_HALF_EVEN:
+return HALF_EVEN;
+  case BigDecimal.ROUND_UNNECESSARY:
+return UNNECESSARY;
+  default:
+throw new 
+  IllegalArgumentException(invalid argument:  + rm + 
+   .  Argument should be one of the  + 
+   rounding modes defined in BigDecimal.);
+  }
+  }
+}


Re: [cp-patches] [generics] RFC: new Enum java.math.RoundingMode

2006-02-20 Thread Anthony Balkissoon
On Mon, 2006-02-20 at 15:09 -0500, Anthony Balkissoon wrote:
 This is RFC because it's my first commit to the generics branch and I
 just want to make sure there aren't any special procedures I forgot. 
 
 2006-02-20  Anthony Balkissoon  [EMAIL PROTECTED]
 
   * java/math/RoundingMode: New Enum.
 
 --Tony


This is replaced by:
2006-02-20  Anthony Balkissoon  [EMAIL PROTECTED]

* java/math/MathContext.java: New class.
* java/math/RoundingMode: New Enum.

Also, I forgot to put the GNU Classpath header in RoundingMode, but this
patch includes it.  Comments are still appreciated.  I'll commit this
tomorrow if no one objects.

--Tony
Index: java/math/MathContext.java
===
RCS file: java/math/MathContext.java
diff -N java/math/MathContext.java
--- /dev/null	1 Jan 1970 00:00:00 -
+++ java/math/MathContext.java	20 Feb 2006 22:30:02 -
@@ -0,0 +1,195 @@
+/* MathContext.java -- 
+   Copyright (C) 1999, 2000, 2002, 2004, 2005  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.math;
+
+import java.io.Serializable;
+
+/**
+ * Immutable objects describing settings such as rounding mode and digit
+ * precision for numerical operations such as those in the BigDecimal class.
+ * @author Anthony Balkissoon abalkiss at redhat dot com
+ *
+ */
+public final class MathContext implements Serializable
+{
+  /** A MathContext for unlimited precision arithmetic * */
+  public static final MathContext UNLIMITED = 
+new MathContext(0, RoundingMode.HALF_UP);
+  
+  /**
+   * A MathContext for the IEEE 754R Decimal32 format - 7 digit preicision and
+   * HALF_EVEN rounding.
+   */
+  public static final MathContext DECIMAL32 = 
+new MathContext(7, RoundingMode.HALF_EVEN);
+  
+  /**
+   * A MathContext for the IEEE 754R Decimal64 format - 16 digit preicision and
+   * HALF_EVEN rounding.
+   */
+  public static final MathContext DECIMAL64 = 
+new MathContext(16, RoundingMode.HALF_EVEN);
+  
+  /**
+   * A MathContext for the IEEE 754R Decimal128 format - 34 digit preicision and
+   * HALF_EVEN rounding.
+   */
+  public static final MathContext DECIMAL128 = 
+new MathContext(34, RoundingMode.HALF_EVEN);
+  
+  /**
+   * This is the serialVersionUID reported here:
+   * java.sun.com/j2se/1.5.0/docs/api/serialized-form.html#java.math.MathContext
+   */
+  private static final long serialVersionUID = 5579720004786848255L;
+  
+  private int precision;
+  
+  private RoundingMode roundMode;
+  
+  /**
+   * Constructs a new MathContext with the specified precision and with HALF_UP
+   * rounding.
+   * @param setPrecision the precision for the new MathContext
+   * 
+   * @throws IllegalArgumentException if precision is  0.
+   */
+  public MathContext(int setPrecision)
+  {
+this(setPrecision, RoundingMode.HALF_UP);
+  }
+  
+  /**
+   * Constructs a new MathContext with the specified precision and rounding
+   * mode.
+   * @param setPrecision the precision
+   * @param setRoundingMode the rounding mode
+   * 
+   * @throws IllegalArgumentException if precision is  0.
+   */
+  public MathContext(int setPrecision, RoundingMode setRoundingMode)
+  {
+if (setPrecision  0)
+  throw new IllegalArgumentException(Precision cannot be less than zero.);
+precision

[commit-cp] classpath ./ChangeLog gnu/java/lang/CharData.ja...

2006-02-15 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/15 23:00:38

Modified files:
.  : ChangeLog 
gnu/java/lang  : CharData.java 
java/lang  : Character.java String.java 
scripts: unicode-muncher.pl 

Log message:
2006-02-15  Anthony Balkissoon  [EMAIL PROTECTED]

* gnu/java/lang/CharData.java: Regenerated from
doc/unicode/UnicodeData-4.0.0.txt, doc/unicode/SpecialCasing-4.0.0.txt
and scripts/unicode-muncher.pl.
* java/lang/Character.java:
(PrivateUseCharacters): New private static class.
(UnassignedCharacters): Likewise.
(blocks): Changed from char[] to char[][] to reflect the changes in
gnu/java/lang/CharData.  There is now one char[] per Unicode code
plane.
(data): Likewise.
(numValue): Likewise.
(upper): Likewise.
(lower): Likewise.
(direction): Likewise.
(readChar): Replaced this method with new method readCodePoint.
(readCodePoint): New method.
(isLowerCase(char)): Redirected to new isLowerCase(int).
(isLowerCase(int)): New method.
(isUpperCase(char)): Redirected to new isUpperCase(int).
(isUpperCase(int)): New method.
(isTitleCase(char)): Redirected to new isTitleCase(int).
(isTitleCase(int)): New method.
(isDigit(char)): Redirected to new isDigit(int).
(isDigit(int)): New method.
(isDefined(char)): Redirected to new isDefined(int).
(isDefined(int)): New method.
(isLetter(char)): Redirected to new isLetter(int).
(isLetter(int)): New method.
(isLetterOrDigit(char)): Redirected to new isLetterOrDigit(int).
(isLetterOrDigit(int)): New method.
(isJavaIdentifierStart(char)): Redirected to new
isJavaIdentifierStart(int).
(isJavaIdentifierStart(int)): New method.
(isJavaIdentifierPart(char)): Redirected to new
isJavaIdentifierPart(int).
(isJavaIdentifierPart(int)): New method.
(isUnicodeIdentifierStart(char)): Redirected to new
isUnicodeIdentifierStart(int).
(isUnicodeIdentifierStart(int)): New method.
(isUnicodeIdentifierPart(char)): Redirected to new
isUnicodeIdentifierPart(int).
(isUnicodeIdentifierPart(int)): New method.
(isIdentifierIgnorable(char)): Redirected to new
isIdentifierIgnorable(int).
(isIdentifierIgnorable(int)): New method.
(toLowerCase(char)): Changed access to lower to correspond with new
char[][] type of lower.
(toLowerCase(int)) New method.
(toUpperCase(char)): Changed access to upper to correspond with new
char[][] type of upper.
(toUpperCase(int)): New method.
(toTitleCase(int)): New method.
(digit(char, int)): Replaced call to readChar with call to
readCodePoint and changed access to numValue to reflect new char[][]
type of numValue.
(digit(int, int)): New method.
(getNumericValue(char)): Changed access to numValue to reflect new
char[][] type of numValue.
(getNumericValue(int)): New method.
(isSpaceChar(char)): Redirected to new isSpaceChar(int).
(isSpaceChar(int)): New method.
(isWhitespace(char)): Redirected to new isWhitespace(int).
(isWhitespace(int)): New method.
(isISOControl(char)): Redirected to new isISOControl(int).
(isISOControl(int)): New method.
(getType(char)): Redirected to new getType(int).
(getType(int)): New method.
(getDirectionality(char)): Redirected to new getDirectionality(int).
(getDirectionality(int)): New method.
(isMirrored(char)): Changed call to readChar to readCodePoint.
(isMirrored(int)): New method.
* java/lang/String.java:
(upperCaseExpansion): Changed access to Character.direction to reflect
new char[][] type of direction.
(offsetByCodePoints): New method.
* scripts/unicode-muncher.pl: Adapted this script to handle Unicode
4.0.0 which introduced supplementary character assignments.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6412tr2=1.6413r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/gnu/java/lang/CharData.java.diff?tr1=1.7tr2=1.8r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/lang/Character.java.diff?tr1=1.44tr2=1.45r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/lang/String.java.diff?tr1=1.80tr2=1.81r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/scripts/unicode-muncher.pl.diff?tr1=1.5tr2=1.6r1=textr2=text




Re: [cp-patches] FYI: ElementBuffer.clone

2006-02-13 Thread Anthony Balkissoon
On Fri, 2006-02-10 at 15:10 +, Roman Kennke wrote:
 I added the missing ElementBuffer.clone() method.
 
 2006-02-10  Roman Kennke  [EMAIL PROTECTED]
 
 * javax/swing/text/DefaultStyledDocument.java
 (ElementBuffer.clone): New method.

I don't understand ... I implemented this method on November 8, 2005 and
committed the ChangeLog and sent an email to this list ... did I forget
to commit the actual change or something?

Oh I see now...it was in the wrong place, not in the inner ElementBuffer
class.  Wups.

Roman, comparing the one I wrote to the one you wrote, I think your
second argument to replace is wrong ... no Elements are being removed
here since the just-created BranchElement has no children.  I think it
should be branchClone.replace(0, 0, cloneChildren).  

If you agree, can you fix this?  And could you remove the one I wrote at
the same time?

--Tony




[commit-cp] classpath ./ChangeLog doc/unicode/SpecialCasing...

2006-02-09 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/09 21:15:55

Modified files:
.  : ChangeLog 
Added files:
doc/unicode: SpecialCasing-4.0.0.txt UnicodeData-4.0.0.txt 

Log message:
2006-02-09  Anthony Balkissoon  [EMAIL PROTECTED]

* doc/unicode/SpecialCasing-4.0.0.txt: New file.
* doc/unicode/UnicodeData-4.0.0.txt: New file.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6323tr2=1.6324r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/doc/unicode/SpecialCasing-4.0.0.txt?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/doc/unicode/UnicodeData-4.0.0.txt?rev=1.1




Re: [cp-patches] RFC: new TextActions

2006-02-07 Thread Anthony Balkissoon
On Tue, 2006-02-07 at 16:15 +0100, Robert Schuster wrote:
 Hi,
 I am starting to grok that swing stuff. :)
 
 I added TextAction implementations for selecting the current line (backward 
 and
 forward), the whole text from the current position (backward  forward) and
 corrected the behavior of single character deletions when the text has a 
 selection.
 
 Or textfield and textareas now do what you would expect from them when 
 pressing
 shift-home, shift-end, shift-ctrl-home, shift-ctrl-end and del/backspace when
 your text has a selection.
 
 2006-02-07  Robert Schuster  [EMAIL PROTECTED]
 
 * javax/swing/text/DefaultEditorToolkit.java: Changed behavior
 of actions delete-next and delete-previous, added new TextAction
 implementations for selection-begin, selection-begin-line,
 selection-end and selection-end-line.
 
 Please comment.

Hi Robert, this looks great!

Cheers,
Tony




[commit-cp] classpath ./ChangeLog scripts/unicode-blocks.pl...

2006-02-01 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/02/01 16:36:57

Modified files:
.  : ChangeLog 
scripts: unicode-blocks.pl 
java/lang  : Character.java 
Added files:
doc/unicode: Blocks-4.0.0.txt 

Log message:
2006-02-01  Anthony Balkissoon  [EMAIL PROTECTED]

* doc/unicode/Blocks-4.0.0.txt: New file.
* java/lang/Character.java: Regenerated inner class UnicodeBlock from
scripts/unicode-blocks.pl and doc/unicode/Blocks-4.0.0.txt.
* scripts/unicode-blocks.pl: Copied this over from the generics branch
but replaced some 1.5-only features (such as enum).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6242tr2=1.6243r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/doc/unicode/Blocks-4.0.0.txt.diff?tr1=1.1tr2=1.2r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/scripts/unicode-blocks.pl.diff?tr1=1.3tr2=1.4r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/lang/Character.java.diff?tr1=1.43tr2=1.44r1=textr2=text




[cp-patches] FYI: More Character Unicode methods

2006-01-27 Thread Anthony Balkissoon
Implemented more of the missing Unicode-related methods in
java.lang.Character, and a missing constructor in java.lang.String.
Also fixed an off by one problem in Character and threw an Exception in
toChars that we weren't throwing.

Note that the String constructor still has issues - I believe the code
there is correct and the internal representation seems to be correct,
but when printing the String to an output stream it doesn't print
correctly.  I haven't investigated this very much, but I suspect it's a
problem with the printing (looping through the characters one 'char' at
a time rather than one 'character' at a time - since characters can be
two chars long if they are supplementary characters).

I have tests for this stuff but they are not yet in Mauve form.  I guess
I'll convert them now. 

More to follow.

2006-01-27  Anthony Balkissoon  [EMAIL PROTECTED]

* java/lang/Character.java:
(offsetByCodePoints(CharSequence, int, int)): New API method.
(offsetByCodePoints(char[], int, int, int, int)): Likewise.
(toChars): Throw the Exception that the docs say we throw.
(codePointAt): Fixed an off-by-one error in the bounds of the if 
statement.
* java/lang/String.java:
(String(int[], int, int)): New API constructor.

--Tony
Index: java/lang/Character.java
===
RCS file: /cvsroot/classpath/classpath/java/lang/Character.java,v
retrieving revision 1.42
diff -u -r1.42 Character.java
--- java/lang/Character.java	25 Jan 2006 22:00:44 -	1.42
+++ java/lang/Character.java	27 Jan 2006 19:13:57 -
@@ -1741,6 +1741,136 @@
   }
   
   /**
+   * Returns the index into the given CharSequence that is offset
+   * codecodePointOffset/code code points from codeindex/code.
+   * @param seq the CharSequence
+   * @param index the start position in the CharSequence
+   * @param codePointOffset the number of code points offset from the start
+   * position
+   * @return the index into the CharSequence that is codePointOffset code 
+   * points offset from index
+   * 
+   * @throws NullPointerException if seq is null
+   * @throws IndexOutOfBoundsException if index is negative or greater than the
+   * length of the sequence.
+   * @throws IndexOutOfBoundsException if codePointOffset is positive and the 
+   * subsequence from index to the end of seq has fewer than codePointOffset
+   * code points
+   * @throws IndexOutOfBoundsException if codePointOffset is negative and the
+   * subsequence from the start of seq to index has fewer than 
+   * (-codePointOffset) code points
+   * @since 1.5
+   */
+  public static int offsetByCodePoints(CharSequence seq,
+   int index,
+   int codePointOffset)
+  {
+int len = seq.length();
+if (index  0 || index  len)
+  throw new IndexOutOfBoundsException();
+
+int numToGo = codePointOffset;
+int offset = index;
+int adjust = 1;
+if (numToGo = 0)
+  {
+for (; numToGo  0; offset++)
+  {
+numToGo--;
+if (Character.isHighSurrogate(seq.charAt(offset))
+ (offset + 1)  len
+ Character.isLowSurrogate(seq.charAt(offset + 1)))
+  offset++;
+  }
+return offset;
+  }
+else
+  {
+numToGo *= -1;
+for (; numToGo  0;)
+  {
+numToGo--;
+offset--;
+if (Character.isLowSurrogate(seq.charAt(offset))
+ (offset - 1) = 0
+ Character.isHighSurrogate(seq.charAt(offset - 1)))
+  offset--;
+  }
+return offset;
+  }
+  }
+  
+  /**
+   * Returns the index into the given char subarray that is offset
+   * codecodePointOffset/code code points from codeindex/code.
+   * @param a the char array
+   * @param start the start index of the subarray
+   * @param count the length of the subarray
+   * @param index the index to be offset
+   * @param codePointOffset the number of code points offset from codeindex
+   * /code
+   * @return the index into the char array
+   * 
+   * @throws NullPointerException if a is null
+   * @throws IndexOutOfBoundsException if start or count is negative or if
+   * start + count is greater than the length of the array
+   * @throws IndexOutOfBoundsException if index is less than start or larger 
+   * than start + count
+   * @throws IndexOutOfBoundsException if codePointOffset is positive and the
+   * subarray from index to start + count - 1 has fewer than codePointOffset
+   * code points.
+   * @throws IndexOutOfBoundsException if codePointOffset is negative and the
+   * subarray from start to index - 1 has fewer than (-codePointOffset) code
+   * points
+   * @since 1.5
+
+   */
+  public static int offsetByCodePoints(char[] a,
+   int start

Re: [cp-patches] FYI: FormView

2006-01-25 Thread Anthony Balkissoon
On Wed, 2006-01-25 at 15:10 +, Roman Kennke wrote:
 I did a partial implementation of javax.swing.text.html.FormView and
 added FIXMEs for the things to do.

nice work!

--Tony


___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://developer.classpath.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: Implementing multiple editors for JTable (with example)

2006-01-20 Thread Anthony Balkissoon
On Thu, 2006-01-19 at 13:36 +0100, Meskauskas Audrius wrote:
 This patch add the multi-editor support for JTable. The table now 
 supports the two editors: text and boolean. The boolean values are 
 rendered and edited using JCheckBox.
 
 I  add the more complicated table example to the Swing demo to show the 
 table with header, multiple data types (text and boolean at the moment) 
 and placed int the scroll window. 

This is awesome stuff!  Good work, man.

--Tony



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: DefaultStyledDocument DocumentEvent handling and more

2006-01-17 Thread Anthony Balkissoon
I eagerly await the day when DefaultStyledDocument won't haunt my every
waking minute.

This patch addresses an outstanding and known issue with
DefaultStyledDocument and ElementBuffer which is that we weren't
updating the DocumentEvent associated with changes at the proper time.
We also weren't making structural changes at the proper time, and this
leads to problems within the text classes.  The main part of this patch
is to allow change Edit objects to use Vectors instead of arrays to
store added and removed children, and then to properly use this
throughout the ElementBuffer class.  Rather than always creating a new
Edit, we see if one exists already for the paragraph in question, and if
so, we simply augment it.  We then apply all the structural changes
stored in the Edit objects all at once and at the same time as updating
the DocumentEvent.

This patch also deals with a more subtle internal problem by treating
the first ContentTag inserted separately from the other tags.

Finally, a small fix that I found for StyleContext, an
ArrayIndexOutOfBoundsException was being thrown because the bounds of a
for loop were off by one.


2006-01-17  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(pad): New debugging method.
(printElements): Likewise.
(printPendingEdits): Likewise.
(printElement): Likewise.
(Edit): Improved docs, moved this class to be an inner class of
ElementBuffer since it only applies within that scope.  Changed added 
and removed to be Vectors instead of arrays because we need to be able 
to add to them after construction.
(ElementBuffer): Updated docs with link to article that helped in this
classes implementation.
(ElementBuffer.Edit.getRemovedElements): New method.
(ElementBuffer.Edit.getAddedElements): Likewise.
(ElementBuffer.Edit.addRemovedElement): Likewise.
(ElementBuffer.Edit.addRemovedElements): Likewise.
(ElementBuffer.Edit.addAddedElement): Likewise.
(ElementBuffer.Edit.addAddedElements): Likewise.
(ElementBuffer.Editinit): Improved docs, call addRemovedElements and 
addAddedElements.
(ElementBuffer.getEditForParagraphAndIndex): New method.
(ElementBuffer.removeUpdate): Changed type of paragraph to 
BranchElement.  Corrected style of adding the edit to use the new Edit
facilities.
(ElementBuffer.changeUpdate): Changed style of adding the edit to use
the new Edit facilities.
(ElementBuffer.split): Likewise.
(ElementBuffer.insertParagraph): Likewise.
(ElementBuffer.insertContentTag): Likewise.
(ElementBuffer.insert): Push all BranchElements until the deepest one, 
not just the root and the first one. Apply the structural changes to 
the tree at the same time as updating the DocumentEvent.
(ElementBuffer.insertUpdate): Fixed docs.  Removed the special case 
handling of EndTags as the first ElementSpec.  Instead have to handle
ContentTags as a special case if they are the first ElementSpec and if
not have to fracture the tree.
(ElementBuffer.createFracture): New method.  May not be complete yet.
Added FIXME indicating what may remain to be done.
(ElementBuffer.insertFirstContentTag): New method.
(ElementBuffer.insertFracture): Added FIXME explaining what remains to
be done.  Changed the adding of edits to use the new Edit facilities.
Removed the adding of edits for Elements that weren't in the tree prior
to the insertion.
(insertUpdate): Removed incorrect condition for setting a StartTag's
direction to JoinNextDirection.
* javax/swing/text/StyleContent.java: 
(SmallAttributeSet.toString): Fixed an off-by-one error in the loop 
that was causing an ArrayOutOfBoundsException.

--Tony
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.38
diff -u -r1.38 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	13 Jan 2006 20:04:38 -	1.38
+++ javax/swing/text/DefaultStyledDocument.java	17 Jan 2006 16:21:05 -
@@ -67,6 +67,44 @@
 public class DefaultStyledDocument extends AbstractDocument
   implements StyledDocument
 {
+  // Prints some spaces.
+  // This is just debugging code that will be used temporarily.
+  static void pad(int pad)
+  {
+for (int i = 0; i  pad; i++)
+  System.out.print( );
+  }
+
+  // Displays the Element hierarchy starting with codestart/code.
+  // This is just debugging code that will be used temporarily.
+  static void printElements (Element start, int pad

Re: [cp-patches] FYI: Old style event fixes, part 2

2006-01-16 Thread Anthony Balkissoon
On Fri, 2006-01-13 at 21:29 +, Roman Kennke wrote:
 This is the second part for the old (1.0) style AWT event handling. The
 problem that is fixed here is that events that are targetted at menu
 components (like ActionEvents) must be forwarded along the parent chain
 and finally must end up in the frame that holds the menu bar (I have an
 application here that expects exactly this). Unfortunatly, the MenuBar
 knows nothing about its parent frame (MenuBars are not part of the
 normal component hierarchy, also they are not derived from Component).
 MenuBar.getParent() returns null. So I had to add a reference to the
 parent frame to MenuBar and forward the event this way.
 

I haven't looked at this stuff, but this resembles very much what
happens in Swing's KeyboardManager class.  I don't know if the AWT
handles it the same way or not, but you might want to look at how it's
handled in Swing.

Cheers,
--Tony



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: fixlet for TransferHandler fixes Mauve regression

2006-01-12 Thread Anthony Balkissoon
This patch fixes a Mauve regression that Mark pointed out:
gnu.testlet.javax.swing.JTextField.CopyPaste

I also checked in a Mauve test for it:
gnu/testlet/javax/swing/TransferHandler/TransferActionConstructor

2006-01-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/TransferHandler.java:
(TransferActioninit): Call super constructor.  Fixes Mauve regression
gnu/testlet/javax/swing/JTextField/CopyPaste.

--Tony



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: Some Mauve regressions builder missed

2006-01-12 Thread Anthony Balkissoon
On Thu, 2006-01-12 at 15:04 +0100, Mark Wielaard wrote:
  - gnu.testlet.javax.swing.JTextField.createDefaultModel
  - gnu.testlet.javax.swing.JTextField.CopyPaste

Roman and I fixed these two.

  - gnu.testlet.javax.swing.JEditorPane.ConstructorsAndTypes

I don't think this is a real regression.  This happened after I made the
following change:

2005-12-09  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JEditorPane.java:
(setText): Allow the EditorKit to read the text into the Document,
allowing for other than plain text.

So before this change, the RTFParser wasn't actually reading the text.
Now it is, but it has bugs so it throws an exception, and the test fails
with an uncaught exception.  The problem is a new problem, one with
RTFParser.

--Tony




___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


[commit-cp] classpath ./ChangeLog javax/swing/TransferHandl...

2006-01-12 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/01/12 20:42:03

Modified files:
.  : ChangeLog 
javax/swing: TransferHandler.java 

Log message:
2006-01-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/TransferHandler.java:
(TransferActioninit): Call super constructor.  Fixes Mauve regression
gnu/testlet/javax/swing/JTextField/CopyPaste.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6031tr2=1.6032r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/TransferHandler.java.diff?tr1=1.13tr2=1.14r1=textr2=text




[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultS...

2006-01-12 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/01/12 22:29:43

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultStyledDocument.java 

Log message:
2006-01-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertContentTag): If the direction is JoinNextDirection
and we haven't come immediately after a fracture, adjust the Element
offsets.  Added comment explaining the situation.
(insert): Return early if no ElementSpecs passed in.  Removed redundant
call to insertUpdate.  Fired the UndoableEditUpdate.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6036tr2=1.6037r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.33tr2=1.34r1=textr2=text




[cp-patches] FYI: More DefaultStyledDocument ElementBuffer fixes

2006-01-11 Thread Anthony Balkissoon
This patch fixes more issues with the ElementBuffer.

2006-01-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertUpdate): Properly recreate Elements if the first
tag is an end tag. Avoid NPE by pushing the proper Element on to the 
elementStack when there is a start tag with JoinNextDirection.

--Tony
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.29
diff -u -r1.29 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	11 Jan 2006 19:25:57 -	1.29
+++ javax/swing/text/DefaultStyledDocument.java	11 Jan 2006 20:04:00 -
@@ -785,18 +785,31 @@
   if (data[0].getType() == ElementSpec.EndTagType)
 {
   // fracture deepest child here
-  Element curr = getDefaultRootElement();
+  BranchElement paragraph = (BranchElement) elementStack.peek();
+  Element curr = paragraph.getParentElement();
   int index = curr.getElementIndex(offset);
   while (!curr.isLeaf())
 {
   index = curr.getElementIndex(offset);
   curr = curr.getElement(index);
 }
-
-  Element newEl1 = createLeafElement(curr.getParentElement(),
+  Element parent = curr.getParentElement();
+  Element newEl1 = createLeafElement(parent,
  curr.getAttributes(),
  curr.getStartOffset(), offset);
-  ((BranchElement) curr.getParentElement()).
+  Element grandParent = parent.getParentElement();
+  BranchElement nextBranch = (BranchElement) grandParent.getElement(grandParent.getElementIndex(parent.getEndOffset()));
+  Element firstLeaf = nextBranch.getElement(0);
+  while (!firstLeaf.isLeaf())
+{
+  firstLeaf = firstLeaf.getElement(0);
+}
+  BranchElement parent2 = (BranchElement) firstLeaf.getParentElement();
+  Element newEl2 = createLeafElement(parent2, firstLeaf.getAttributes(), offset, firstLeaf.getEndOffset());
+  parent2.replace(0, 1, new Element[] { newEl2 });
+  
+  
+  ((BranchElement) parent).
   replace(index, 1, new Element[] { newEl1 });
 }
   
@@ -812,9 +825,8 @@
   insertFracture(data[i]);
   break;
 case ElementSpec.JoinNextDirection:
-  Element parent = paragraph.getParentElement();
-  int index = parent.getElementIndex(offset);
-  elementStack.push(parent.getElement(index + 1));
+  int index = paragraph.getElementIndex(offset);
+  elementStack.push(paragraph.getElement(index));
   break;
 case ElementSpec.OriginateDirection:
   Element current = (Element) elementStack.peek();
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] FYI: Another DefaultStyledDocument ElementBuffer fix

2006-01-11 Thread Anthony Balkissoon
These changes to DefaultStyledDocument make all the local tests I have
here pass.  I will commit these tests to Mauve now.  The number one
outstanding problem with DefaultStyledDocument and ElementBuffer is the
way DocumentEvents are handled and marked up.  Lillian is working on
that right now, hopefully we can have it sorted out before too long.

2006-01-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertContentTag): Don't adjust the structure here.  
This will have been taken care of in insertFracture.  Added a comment
explaining that we need to add edits to the DocumentEvent and that
this may be the place to do it.

--Tony
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.30
diff -u -r1.30 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	11 Jan 2006 20:07:24 -	1.30
+++ javax/swing/text/DefaultStyledDocument.java	11 Jan 2006 20:34:36 -
@@ -798,14 +798,19 @@
  curr.getAttributes(),
  curr.getStartOffset(), offset);
   Element grandParent = parent.getParentElement();
-  BranchElement nextBranch = (BranchElement) grandParent.getElement(grandParent.getElementIndex(parent.getEndOffset()));
+  BranchElement nextBranch = 
+(BranchElement) grandParent.getElement
+  (grandParent.getElementIndex(parent.getEndOffset()));
   Element firstLeaf = nextBranch.getElement(0);
   while (!firstLeaf.isLeaf())
 {
   firstLeaf = firstLeaf.getElement(0);
 }
   BranchElement parent2 = (BranchElement) firstLeaf.getParentElement();
-  Element newEl2 = createLeafElement(parent2, firstLeaf.getAttributes(), offset, firstLeaf.getEndOffset());
+  Element newEl2 = 
+createLeafElement(parent2, 
+  firstLeaf.getAttributes(), 
+  offset, firstLeaf.getEndOffset());
   parent2.replace(0, 1, new Element[] { newEl2 });
   
   
@@ -941,6 +946,9 @@
  */
 private void insertFracture(ElementSpec tag)
 {
+  System.out.println (BEFORE FRACTURE:);
+  printElements(getDefaultRootElement(), 0);
+  
   // This is the parent of the paragraph about to be fractured.  We will
   // create a new child of this parent.
   BranchElement parent = (BranchElement) elementStack.peek();
@@ -1007,6 +1015,9 @@
   parent.replace(parentIndex + 1, 0, new Element[] { newBranch });
   
   // FIXME: Add the edits to the DocumentEvent via the addEdit method.
+  
+  System.out.println (AFTER FRACTURE:);
+  printElements(getDefaultRootElement(), 0);
 }
 
 /**
@@ -1029,28 +1040,10 @@
 }
   else if (dir == ElementSpec.JoinNextDirection)
 {
-  BranchElement paragraph = (BranchElement) elementStack.peek();
-  int currentIndex = paragraph.getElementIndex(offset);
-  Element current = paragraph.getElement(currentIndex);
-  Element next = paragraph.getElement(currentIndex + 1);
-
-  if (next == null)
-return;
-
-  Element newEl1 = createLeafElement(paragraph,
- current.getAttributes(),
- current.getStartOffset(), 
- offset);
-  Element newEl2 = createLeafElement(paragraph,
- current.getAttributes(), 
- offset,
- next.getEndOffset());
-
-  Element[] add = new Element[] { newEl1, newEl2 };
-  Element[] remove = new Element[] { current, next };
-  paragraph.replace(currentIndex, 2, add);
-  // Add this action to the document event.
-  addEdit(paragraph, currentIndex, remove, add);
+  // Doing nothing here gives us the proper structure.  
+  // However, edits must be added to the document event. 
+  // It is possible these should happen here, or also possible that
+  // they should happen in insertFracture.
 }
   else if (dir == ElementSpec.OriginateDirection)
 {
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultS...

2006-01-11 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/01/11 20:07:24

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultStyledDocument.java 

Log message:
2006-01-11  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertUpdate): Properly recreate Elements if the first
tag is an end tag. Avoid NPE by pushing the proper Element on to the
elementStack when there is a start tag with JoinNextDirection.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6014tr2=1.6015r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.29tr2=1.30r1=textr2=text




[cp-patches] FYI: patch for DefaultStyledDocument

2006-01-09 Thread Anthony Balkissoon
Now that Lillian and I have good documentation for the ElementBuffer
class
(http://java.sun.com/products/jfc/tsc/articles/text/element_buffer/index.html)
we can finally nail this class down and get it right.

I coded some examples suggested in the document linked above and made
the following change.  The examples I coded will be turned into Mauve
tests and committed.

2006-01-09  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(insertUpdate): Removed call to checkForInsertAfterNewline and instead
inlined this method because it needs to change the value of the 
finalStartTag and finalStartDirection variables.
(checkForInsertAfterNewline): Removed this method.
(handleInsertAfterNewline): Added case for making the start tag's 
direction JoinNextDirection.

--Tony
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.26
diff -u -r1.26 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	5 Jan 2006 20:15:34 -	1.26
+++ javax/swing/text/DefaultStyledDocument.java	9 Jan 2006 18:53:51 -
@@ -1596,9 +1596,36 @@
 int segmentEnd = txt.offset + txt.count;
 
 // Check to see if we're inserting immediately after a newline.
-checkForInsertAfterNewline(offset, endOffset, prevParagraph, paragraph,
-   paragraphAttributes, prevCharWasNewline,
-   finalStartTag, finalStartDirection, specs);
+if (offset  0)
+  {
+try
+{
+  String s = getText(offset - 1, 1);
+  if (s.equals(\n))
+{
+  finalStartDirection = 
+handleInsertAfterNewline(specs, offset, endOffset,
+ prevParagraph,
+ paragraph,
+ paragraphAttributes);
+  
+  prevCharWasNewline = true;
+  // Find the final start tag from the ones just created.
+  for (int i = 0; i  specs.size(); i++)
+if (((ElementSpec) specs.get(i)).getType() 
+== ElementSpec.StartTagType)
+  finalStartTag = (ElementSpec)specs.get(i);
+}
+}
+catch (BadLocationException ble)
+{  
+  // This shouldn't happen.
+  AssertionError ae = new AssertionError();
+  ae.initCause(ble);
+  throw ae;
+}
+  }
+
 
 for (int i = txt.offset; i  segmentEnd; ++i)
   {
@@ -1663,49 +1690,6 @@
   }
 
   /**
-   * A helper method that checks to see if insertUpdate was called when text
-   * was inserted immediately after a newline, and calls 
-   * handleInsertAfterNewline if that is the case.
-   */
-  void checkForInsertAfterNewline(int offset, int endOffset,
-  Element prevParagraph, Element paragraph,
-  AttributeSet paragraphAttributes,
-  boolean prevCharWasNewline,
-  ElementSpec finalStartTag,
-  short finalStartDirection, Vector specs)
-  {
-if (offset  0)
-  {
-try
-{
-  String s = getText(offset - 1, 1);
-  if (s.equals(\n))
-{
-  finalStartDirection = 
-handleInsertAfterNewline(specs, offset, endOffset,
- prevParagraph,
- paragraph,
- paragraphAttributes);
-  
-  prevCharWasNewline = true;
-  // Find the final start tag from the ones just created.
-  for (int i = 0; i  specs.size(); i++)
-if (((ElementSpec) specs.get(i)).getType() 
-== ElementSpec.StartTagType)
-  finalStartTag = (ElementSpec)specs.get(i);
-}
-}
-catch (BadLocationException ble)
-{  
-  // This shouldn't happen.
-  AssertionError ae = new AssertionError();
-  ae.initCause(ble);
-  throw ae;
-}
-  }
-  }
-  
-  /**
* A helper method to set up the ElementSpec buffer for the special
* case of an insertion occurring immediately after a newline.
* @param specs the ElementSpec buffer to initialize.
@@ -1720,7 +1704,10 @@
 specs.add(new ElementSpec(a, ElementSpec.StartTagType));
 if (prevParagraph.getEndOffset() != endOffset)
   return ElementSpec.JoinFractureDirection;
-
+// If there is an Element after

[cp-patches] FYI: PlainDocument patch fixes recent regressions

2006-01-09 Thread Anthony Balkissoon
PlainDocument.insertUpdate needs to explicitly handle the special case
of an insertion happening right after a newline.  Apparently this worked
by accident before, and a recent patch that Lillian and I made to
GapContent exposed the weakness.  This is fixed and committed now.

2006-01-09  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/PlainDocument.java:
(insertUpdate): Handle special case of an insertion immediately 
following a newline character.

--Tony
? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: javax/swing/text/PlainDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainDocument.java,v
retrieving revision 1.18
diff -u -r1.18 PlainDocument.java
--- javax/swing/text/PlainDocument.java	16 Nov 2005 18:31:42 -	1.18
+++ javax/swing/text/PlainDocument.java	9 Jan 2006 21:53:51 -
@@ -113,6 +113,46 @@
 int elementIndex = rootElement.getElementIndex(offset);
 Element firstElement = rootElement.getElement(elementIndex);
 
+// If we're inserting immediately after a newline we have to fix the 
+// Element structure.
+if (offset  0)
+  {
+try
+{
+  String s = getText(offset - 1, 1);
+  if (s.equals(\n))
+{
+  int newEl2EndOffset = end;
+  boolean replaceNext = false;
+  if (rootElement.getElementCount()  elementIndex + 1)
+{
+  replaceNext = true;
+  newEl2EndOffset = 
+rootElement.getElement(elementIndex + 1).getEndOffset();
+}
+  Element newEl1 = 
+createLeafElement(rootElement, firstElement.getAttributes(), 
+  firstElement.getStartOffset(), offset);
+  Element newEl2 = 
+createLeafElement (rootElement, firstElement.getAttributes(), 
+   offset, newEl2EndOffset);
+  if (replaceNext)
+rootElement.replace(elementIndex, 2, new Element[] { newEl1, newEl2 });
+  else
+rootElement.replace(elementIndex, 1, new Element[] { newEl1, newEl2 });
+  firstElement = newEl2;
+  elementIndex ++;
+}
+}
+catch (BadLocationException ble)
+{  
+  // This shouldn't happen.
+  AssertionError ae = new AssertionError();
+  ae.initCause(ble);
+  throw ae;
+}
+  }
+
 // added and removed are Element arrays used to add an ElementEdit
 // to the DocumentEvent if there were entire lines added or removed.
 Element[] removed = new Element[1];
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultS...

2006-01-09 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/01/09 18:57:23

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultStyledDocument.java 

Log message:
2006-01-09  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(insertUpdate): Removed call to checkForInsertAfterNewline and instead
inlined this method because it needs to change the value of the
finalStartTag and finalStartDirection variables.
(checkForInsertAfterNewline): Removed this method.
(handleInsertAfterNewline): Added case for making the start tag's
direction JoinNextDirection.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5979tr2=1.5980r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.26tr2=1.27r1=textr2=text




Re: [cp-patches] FYI: Patches for several javax.swing.text files

2006-01-05 Thread Anthony Balkissoon
On Thu, 2006-01-05 at 21:36 +0100, Mark Wielaard wrote:
 Hi Tony,
  +Document doc = textComponent.getDocument();
  +if (doc != null)
  +  this.dot = Math.min(dot, doc.getLength());
  +this.dot = Math.max(dot, 0);

 There seems to be some confusion here between dot the parameter and
 this.dot. if doc != null you probably want to set the parameter dot to
 Math.min(dot,etc) since you will override this.dot immediately after
 that assignment.

Thanks Mark, this is fixed as follows:

2006-01-05  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultCaret.java:
(setDot): Fixed paramater to Math.max to be this.dot and not the 
parameter dot.


RCS
file: /cvsroot/classpath/classpath/javax/swing/text/DefaultCaret.java,v
retrieving revision 1.27
diff -u -r1.27 DefaultCaret.java
--- javax/swing/text/DefaultCaret.java  5 Jan 2006 20:15:34 -
1.27
+++ javax/swing/text/DefaultCaret.java  5 Jan 2006 23:53:08 -
@@ -833,7 +833,7 @@
 Document doc = textComponent.getDocument();
 if (doc != null)
   this.dot = Math.min(dot, doc.getLength());
-this.dot = Math.max(dot, 0);
+this.dot = Math.max(this.dot, 0);
 this.mark = dot;
 handleHighlight();
 adjustVisibility(this);

? include/gnu_java_net_PlainDatagramSocketImpl.h
? include/gnu_java_net_PlainSocketImpl.h
Index: javax/swing/text/DefaultCaret.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultCaret.java,v
retrieving revision 1.27
diff -u -r1.27 DefaultCaret.java
--- javax/swing/text/DefaultCaret.java	5 Jan 2006 20:15:34 -	1.27
+++ javax/swing/text/DefaultCaret.java	5 Jan 2006 23:50:04 -
@@ -833,7 +833,7 @@
 Document doc = textComponent.getDocument();
 if (doc != null)
   this.dot = Math.min(dot, doc.getLength());
-this.dot = Math.max(dot, 0);
+this.dot = Math.max(this.dot, 0);
 this.mark = dot;
 handleHighlight();
 adjustVisibility(this);
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[commit-cp] classpath ./ChangeLog javax/swing/JTextPane.jav...

2006-01-05 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/01/05 20:15:34

Modified files:
.  : ChangeLog 
javax/swing: JTextPane.java 
javax/swing/event: EventListenerList.java 
javax/swing/text: AbstractDocument.java DefaultCaret.java 
  DefaultStyledDocument.java View.java 

Log message:
2006-01-05  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JTextPane.java:
(replaceSelection): If the document is an AbstractDocument, use replace
rather than remove and insert.
* javax/swing/event/EventListenerList.java:
(getListeners): Reversed the order of the listeners to match the
reference implementation.
* javax/swing/text/AbstractDocument.java:
(insertString): Add the UndoableEdit from the content.insertString call
to the DocumentEvent.
(DefaultDocumentEvent.toString): Implemented.
* javax/swing/text/DefaultCaret.java:
(setDot): Make sure dot is  0 and less than the length of the
document.
* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertUpdate): Set the modified tag of the document
event when we get start and end tags.  This ensures that we create the
proper BranchElements in endEdit().
(ElementBuffer.insertUpdate): Added FIXME to handle
JoinFractureDirection case.
(insertUpdate): Added code to check if we're inserting immediately
after a newline and to handle this case (create start and end tags).
Only change the direction of the first and last tags if they are of
type ContentType.
(checkForInsertAfterNewline): New helper method.
(handleInsertAfterNewline): Likewise.
* javax/swing/text/View.java:
(updateLayout): Avoid NPE by checking if shape is null.  Repaint
container.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5949tr2=1.5950r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/JTextPane.java.diff?tr1=1.13tr2=1.14r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/event/EventListenerList.java.diff?tr1=1.13tr2=1.14r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/AbstractDocument.java.diff?tr1=1.42tr2=1.43r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultCaret.java.diff?tr1=1.26tr2=1.27r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.25tr2=1.26r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/View.java.diff?tr1=1.24tr2=1.25r1=textr2=text




[commit-cp] classpath ChangeLog

2006-01-05 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  06/01/05 23:54:44

Modified files:
.  : ChangeLog 

Log message:
Didn't commit proper ChangeLog with last patch.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5952tr2=1.5953r1=textr2=text




Re: [cp-patches] RFC: JMenuItem null accelerators

2006-01-04 Thread Anthony Balkissoon
On Wed, 2006-01-04 at 00:08 +0100, Mark Wielaard wrote:
 Hi,
 
 At various points we try to register a null KeyStroke with an InputMap.
 This gives some problems later on when InputMaps are copied because null
 entries aren't always expected. Does the following patch make sense?
 

looks OK to me.

Tony

 2006-01-03  Mark Wielaard  [EMAIL PROTECTED]
 
 * javax/swing/JMenuItem.java (configurePropertiesFromAction): Only
 register keyboard action when accelerator is not null.
 * javax/swing/plaf/basic/BasicMenuItemUI.java (propertyChange): Only
 re-register accelerator if not null.
 (installKeyboardActions): Only put accelerator in map when not null.
 
 Cheers,
 
 Mark
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] Patch: More fixes for DefaultStyledDocument

2005-12-22 Thread Anthony Balkissoon
Here come some more changes for DefaultStyledDocument.  These fix an NPE
and improve performance. 

2005-12-22  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertContentTag): Get the attributes from the tag. 
Return early if direction is JoinNextDirection but there is no next 
Element.  
(createDefaultRoot): Don't call createBranchElement here just 
instantiate a new BranchElement.
(insertUpdate): Removed unneeded fields newElement, newElement2.  When
building the buffer ElementSpecs, no need to check each time if we 
should join to the previous or next Element, just check the first and
last ElementSpecs after the buffer has been completely built.

--Tony
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.23
diff -u -r1.23 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	21 Dec 2005 20:27:31 -	1.23
+++ javax/swing/text/DefaultStyledDocument.java	22 Dec 2005 20:00:54 -
@@ -817,7 +817,7 @@
   prepareContentInsertion();
   int len = tag.getLength();
   int dir = tag.getDirection();
-  AttributeSet tagAtts = createLeafElement(null, null, 0, 0).getAttributes();
+  AttributeSet tagAtts = tag.getAttributes();
   if (dir == ElementSpec.JoinPreviousDirection)
 {
   // The mauve tests to this class show that a JoinPrevious insertion
@@ -832,19 +832,21 @@
   Element current = paragraph.getElement(currentIndex);
   Element next = paragraph.getElement(currentIndex + 1);
 
+  if (next == null)
+return;
+
   Element newEl1 = createLeafElement(paragraph,
  current.getAttributes(),
- current.getStartOffset(),  
+ current.getStartOffset(), 
  offset);
   Element newEl2 = createLeafElement(paragraph,
- current.getAttributes(),
+ current.getAttributes(), 
  offset,
  next.getEndOffset());
 
-  Element[] add = new Element[] {newEl1, newEl2};
-  Element[] remove = new Element[] {current, next};
+  Element[] add = new Element[] { newEl1, newEl2 };
+  Element[] remove = new Element[] { current, next };
   paragraph.replace(currentIndex, 2, add);
-  
   // Add this action to the document event.
   addEdit(paragraph, currentIndex, remove, add);
 }
@@ -1148,8 +1150,7 @@
 // Use createBranchElement() and createLeafElement instead.
 SectionElement section = new SectionElement();
 
-BranchElement paragraph =
-  (BranchElement) createBranchElement(section, null);
+BranchElement paragraph = new BranchElement(section, null);
 paragraph.setResolveParent(getStyle(StyleContext.DEFAULT_STYLE));
 tmp = new Element[1];
 tmp[0] = paragraph;
@@ -1483,7 +1484,6 @@
 int offset = ev.getOffset();
 int length = ev.getLength();
 int endOffset = offset + length;
-Element newElement, newElement2;
 AttributeSet paragraphAttributes = 
   getParagraphElement(endOffset).getAttributes();
 Segment txt = new Segment();
@@ -1503,7 +1503,7 @@
 
 Element prev = getCharacterElement(offset);
 Element next = getCharacterElement(endOffset);
-
+
 int segmentEnd = txt.offset + txt.count;
 for (int i = txt.offset; i  segmentEnd; ++i)
   {
@@ -1512,21 +1512,6 @@
   {
 ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType,
len);  
-// If we are at the last index, then check if we could probably be
-// joined with the next element.
-if (i == segmentEnd - 1)
-  {
-if (next.getAttributes().isEqual(attr))
-  spec.setDirection(ElementSpec.JoinNextDirection);
-  }
-// If we are at the first new element, then check if it could be
-// joined with the previous element.
-else if (specs.size() == 0)
-  {
-if (prev.getAttributes().isEqual(attr))
-spec.setDirection(ElementSpec.JoinPreviousDirection);
-  }
-
 specs.add(spec);
 
 // Add ElementSpecs for the newline.
@@ -1542,22 +1527,20 @@
   }
 
 // Create last element if last character hasn't been a newline.
-if (len  0)
-  {
-ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType

[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultS...

2005-12-22 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/22 20:02:59

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultStyledDocument.java 

Log message:
2005-12-22  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertContentTag): Get the attributes from the tag.
Return early if direction is JoinNextDirection but there is no next
Element.
(createDefaultRoot): Don't call createBranchElement here just
instantiate a new BranchElement.
(insertUpdate): Removed unneeded fields newElement, newElement2.  When
building the buffer ElementSpecs, no need to check each time if we
should join to the previous or next Element, just check the first and
last ElementSpecs after the buffer has been completely built.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5887tr2=1.5888r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.23tr2=1.24r1=textr2=text




[cp-patches] Patch: StyleContext.SmallAttributeSet fix and remove hack from DefaultStyledDocument

2005-12-21 Thread Anthony Balkissoon
I sent a message to the list yesterday (message is attached) detailing a
hack that I put into DefaultStyledDocument.  Roman helped me track down
the real problem and this patch fixes the problem as well as removes the
hack from DefaultStyledDocument.  

This is accompanied by
gnu/testlet/javax/swing/text/AttributeSet/isEqual.java

2005-12-21  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(insertUpdate): If the AttributeSet argument is null use an empty 
AttributeSet for comparisons. No need to create a new LeafElement to 
compare AttributeSets (ie - remove the hack added yesterday).
* javax/swing/text/StyleContext.java:
(SmallAttributeSet.isEqual): Don't return false for null arguments, 
this should throw an NPE instead.  Also, for performance, check that
sizes are equal and one set contains the other, rather than checking 
that each set contains the other.   

--Tony
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.22
diff -u -r1.22 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java 20 Dec 2005 18:35:22 -  1.22
+++ javax/swing/text/DefaultStyledDocument.java 21 Dec 2005 20:21:53 -
@@ -834,0 +834,0 @@

   Element newEl1 = createLeafElement(paragraph,
  current.getAttributes(),
- current.getStartOffset(),
+ current.getStartOffset(),
  offset);
   Element newEl2 = createLeafElement(paragraph,
  current.getAttributes(),
@@ -844,7 +844,7 @@
   Element[] add = new Element[] {newEl1, newEl2};
   Element[] remove = new Element[] {current, next};
   paragraph.replace(currentIndex, 2, add);
-
+
   // Add this action to the document event.
   addEdit(paragraph, currentIndex, remove, add);
 }
@@ -1477,6 +1477,9 @@
   protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr)
   {
 super.insertUpdate(ev, attr);
+// If the attribute set is null, use an empty attribute set.
+if (attr == null)
+  attr = SimpleAttributeSet.EMPTY;
 int offset = ev.getOffset();
 int length = ev.getLength();
 int endOffset = offset + length;
@@ -1508,28 +1511,18 @@
 if (txt.array[i] == '\n')
   {
 ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType,
-   len);
-// FIXME: This is a hack.  Without this, our check to see if
-// prev.getAttributes was the same as the attribute set for the new
-// ElementSpec was never true, because prev has an attribute key
-// LeafElement(content) that contains its start and end offset as
-// the value.  Similarly for next.
-newElement = createLeafElement(null, attr, prev.getStartOffset(),
-   prev.getEndOffset());
-newElement2 = createLeafElement(null, attr, next.getStartOffset(),
-   next.getEndOffset());
-
+   len);
 // If we are at the last index, then check if we could probably be
 // joined with the next element.
 if (i == segmentEnd - 1)
   {
-if (next.getAttributes().isEqual(newElement2.getAttributes()))
+if (next.getAttributes().isEqual(attr))
   spec.setDirection(ElementSpec.JoinNextDirection);
   }
 // If we are at the first new element, then check if it could be
 // joined with the previous element.
 else if (specs.size() == 0)
   {
-if (prev.getAttributes().isEqual(newElement.getAttributes()))
+if (prev.getAttributes().isEqual(attr))
 spec.setDirection(ElementSpec.JoinPreviousDirection);
   }

@@ -1551,25 +1544,14 @@
 // Create last element if last character hasn't been a newline.
 if (len  0)
   {
-ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len);
-
-// FIXME: This is a hack.  Without this, our check to see if
-// prev.getAttributes was the same as the attribute set for the new
-// ElementSpec was never true, because prev has an attribute key
-// LeafElement(content) that contains its start and end offset as
-// the value.  Similarly for next.
-newElement = createLeafElement(null, attr, prev.getStartOffset

[cp-patches] Patch: DefaultEditorKit.read

2005-12-21 Thread Anthony Balkissoon
2005-12-21  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultEditorKit.java:
(read): Changed the call to insertString to leave out the trailing
new line.
Index: javax/swing/text/DefaultEditorKit.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultEditorKit.java,v
retrieving revision 1.26
diff -u -r1.26 DefaultEditorKit.java
--- javax/swing/text/DefaultEditorKit.java	20 Dec 2005 22:42:04 -	1.26
+++ javax/swing/text/DefaultEditorKit.java	21 Dec 2005 21:57:22 -
@@ -948,7 +948,7 @@
 	content.append(\n);
   }
 
-document.insertString(offset, content.toString(),
+document.insertString(offset, content.substring(0, content.length() - 1),
 			  SimpleAttributeSet.EMPTY);
   }
 
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] Re: Patch: DefaultEditorKit.read

2005-12-21 Thread Anthony Balkissoon
Sorry, I meant to hit enter, but I hit CTRL-enter and sent that last
patch without any text description.

I'll include the patch and ChangeLog entry here, so at least one of the
emails is complete.

This patch accompanies changes to
gnu.testlet.javax.swing.text.DefaultStyledDocument.ElementBuffer.ElementStructure3

2005-12-21  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultEditorKit.java:
(read): Changed the call to insertString to leave out the trailing
new line.

--Tony
Index: javax/swing/text/DefaultEditorKit.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultEditorKit.java,v
retrieving revision 1.26
diff -u -r1.26 DefaultEditorKit.java
--- javax/swing/text/DefaultEditorKit.java	20 Dec 2005 22:42:04 -	1.26
+++ javax/swing/text/DefaultEditorKit.java	21 Dec 2005 21:57:22 -
@@ -948,7 +948,7 @@
 	content.append(\n);
   }
 
-document.insertString(offset, content.toString(),
+document.insertString(offset, content.substring(0, content.length() - 1),
 			  SimpleAttributeSet.EMPTY);
   }
 
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultE...

2005-12-21 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/21 21:59:30

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultEditorKit.java 

Log message:
2005-12-21  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultEditorKit.java:
(read): Changed the call to insertString to leave out the trailing
new line.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5877tr2=1.5878r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultEditorKit.java.diff?tr1=1.26tr2=1.27r1=textr2=text




Re: [cp-patches] Patch: several fixes for DefaultStyledDocument

2005-12-20 Thread Anthony Balkissoon
On Mon, 2005-12-19 at 17:54 -0500, Anthony Balkissoon wrote:
 This is the first part of the work I'm doing on DefaultStyledDocument.
 This fixes a couple issues associated with PR 24744 but the bug is not
 completely fixed yet, so the testcase for that PR still crashes.  I will
 continue to work on this but these changes are ready to go in and may
 help get some text/html test apps up and running so I'm committing this
 now.

This patch caused some Mauve regressions because it's causing an
unexpected exception, I'm working on this and will also be checking in
the Mauve tests I wrote while creating this patch.

--Tony



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] Patch: several fixes for DefaultStyledDocument

2005-12-20 Thread Anthony Balkissoon
On Tue, 2005-12-20 at 11:01 -0500, Anthony Balkissoon wrote:
 On Mon, 2005-12-19 at 17:54 -0500, Anthony Balkissoon wrote:
  This is the first part of the work I'm doing on DefaultStyledDocument.
  This fixes a couple issues associated with PR 24744 but the bug is not
  completely fixed yet, so the testcase for that PR still crashes.  I will
  continue to work on this but these changes are ready to go in and may
  help get some text/html test apps up and running so I'm committing this
  now.
 
 This patch caused some Mauve regressions because it's causing an
 unexpected exception, I'm working on this and will also be checking in
 the Mauve tests I wrote while creating this patch.
 
 --Tony

Okay, I've fixed the regressions and made progress with the attached
patch.  Yesterday I put code in ElementBuffer.insertContentTag to join
Elements if they had the same attribute sets.  This was incorrect and
led to the Mauve regressions.  The problem was that the wrong
information was being passed to insertContentTag.
DefaultStyledDocument.insertUpdate basically makes a list of
ElementSpecs that it wants the ElementBuffer to turn into Elements.
There was a problem in this method that was causing the wrong
ElementSpecs to be sent to the ElementBuffer (and eventually to
insertContentTag).  This is fixed, but the solution is somewhat of a
hack.  

The reason for the hack is as follows.  To create a LeafElement (a
structural object) we call AbstractDocument.createLeafElement which
takes as one of its parameters an AttributeSet that you want the
LeafElement to have.  However, in the process of creating the
LeafElement we actually add an attribute to the set that describes the
LeafElement's start and end offset positions.  So for instance, the
following code would print false (the parent, start_offset, end_offset
arguments are not important to this discussion):

SimpleAttributeSet set = new SimpleAttributeSet();
set.addAttribute(A, B);
Element e = createLeafElement(parent, set, start_offset, end_offset);
System.out.println (e.isEqual(set));

And this is the basis of our problem .. before we were comparing the
AttributeSet that we were going to use to create an Element with the
attribute set from an Element that already existed and so we'd always
get that they were not equal.  So the hack basically calls
createLeafElement to create an Element from which we get an
AttributeSet, and we use _that_ set in our comparisons.  The element
returned from createLeafElement is then thrown away, we don't actually
add it to the Document structure.

Since I consider this a bit of a hack, comments are appreciated (Roman?)
in case another solution is preferred.

2005-12-20  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertContentTag): If the direction is 
OriginateDirection split all the time, don't check the attribute sets.
Removed the special case for the first insertion.  These cases should
fall under the direction JoinPreviousDirection. Changed the comments to
reflect this.
(insertUpdate): Added a hack to get the right result when comparing
the attributes of the new ElementSpec to the attributes of either
the previous or next Element.

--Tony
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.21
diff -u -r1.21 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	19 Dec 2005 22:52:32 -	1.21
+++ javax/swing/text/DefaultStyledDocument.java	20 Dec 2005 18:24:13 -
@@ -866,89 +866,36 @@
   removed = new Element[0];
   index++;
 }
-  else if (current.getStartOffset() == offset
-current.getEndOffset() - 1 == endOffset)
-{
-  // This is if the new insertion covers the entire range of 
-  // codecurrent/code.  This will generally happen for the 
-  // first insertion into a new paragraph.
-  added = new Element[1];
-  added[0] = createLeafElement(paragraph, tagAtts,
-   offset, endOffset + 1);  
-}
   else if (current.getStartOffset() == offset)
-{
+{ 
   // This is if the new insertion happens immediately before 
-  // the codecurrent/code Element.  In this case, if there is
-  // a split, there are 2 resulting Elements.
-  
-  AttributeSet splitAtts = splitRes[1].getAttributes();  
-  if (attributeSetsAreSame(tagAtts, splitAtts))
-{
-  // If the attributes of the adjacent Elements are the same
-  // then we don't split them, we join them

[cp-patches] Patch for AbstractDocument fixes PR 25506

2005-12-20 Thread Anthony Balkissoon
Small fixlet fixes a long standing and annoying problem with text
components.

2005-12-20  Anthony Balkissoon  [EMAIL PROTECTED]

Fixes bug #25506
* javax/swing/text/AbstractDocument.java:
(insertString): Fire insert update whether the DocumentEvent was
changed or not.

--Tony
Index: javax/swing/text/AbstractDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.41
diff -u -r1.41 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java	15 Dec 2005 21:17:46 -	1.41
+++ javax/swing/text/AbstractDocument.java	20 Dec 2005 21:25:57 -
@@ -544,8 +544,7 @@
 insertUpdate(event, attributes);
 writeUnlock();
 
-if (event.modified)
-  fireInsertUpdate(event);
+fireInsertUpdate(event);
 if (undo != null)
   fireUndoableEditUpdate(new UndoableEditEvent(this, undo));
   }
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: javax.swing.JTextField

2005-12-20 Thread Anthony Balkissoon
On Mon, 2005-12-19 at 22:40 -0500, Christopher Lansdown wrote:
 Hi,
 
 JTextField doesn't seem to send any ActionEvent's when VK_ENTER is pressed,
 and looking through the source it doesn't seem to try to catch this.
 

Hi Chris, I ran a little test program and it seems to work for me.  Are
you trying to activate the ActionEvent programmatically, or were you
actually typing the ENTER key into the text area?  Are you using the
newest Classpath?  

Here's a little test program to run, type in some text and hit enter.
Every time you hit enter hi is printed to the console.  Works for me.
If this little program doesn't work for anyone, or if you can write a
small program that shows what's wrong, please file a bug or email the
list again.

Test Program:
import java.awt.event.*;
import javax.swing.*;

public class Test
{ 
  public static void main(String[] args)
  {
JFrame jf = new JFrame();
final JTextField text = new JTextField(10);
text.addActionListener (new ActionListener()
  {
public void actionPerformed(ActionEvent e)
{
  System.out.println (hi);
}
  }
);
jf.add(text);
jf.pack();
jf.setVisible(true);
  }
} 

--Tony





___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultS...

2005-12-20 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/20 18:35:22

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultStyledDocument.java 

Log message:
2005-12-20  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertContentTag): If the direction is
OriginateDirection split all the time, don't check the attribute sets.
Removed the special case for the first insertion.  These cases should
fall under the direction JoinPreviousDirection. Changed the comments to
reflect this.
(insertUpdate): Added a hack to get the right result when comparing
the attributes of the new ElementSpec to the attributes of either
the previous or next Element.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5866tr2=1.5867r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.21tr2=1.22r1=textr2=text




[commit-cp] classpath ./ChangeLog javax/swing/text/Abstract...

2005-12-20 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/20 21:28:16

Modified files:
.  : ChangeLog 
javax/swing/text: AbstractDocument.java 

Log message:
2005-12-20  Anthony Balkissoon  [EMAIL PROTECTED]

Fixes bug #25506
* javax/swing/text/AbstractDocument.java:
(insertString): Fire insert update whether the DocumentEvent was
changed or not.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5868tr2=1.5869r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/AbstractDocument.java.diff?tr1=1.41tr2=1.42r1=textr2=text




Re: [cp-patches] FYI: SwingUtilities.processKeyBindings() implemented

2005-12-19 Thread Anthony Balkissoon
On Sat, 2005-12-17 at 00:30 +, Roman Kennke wrote:
 Hi,
 
 thanks to the work done by Anthony Balkissoon (KeyboardManager) I finally
 could make some sense out of the method
 SwingUtilities.processKeyBindings() which previously caused headaches to
 me :-)
 
 What I think what this method actually should do (and this is how I
 implemented it) is, that it processes key bindings for a
 java.awt.Component (that is not derived from JComponent) that are in the
 WHEN_IN_FOCUSED_WINDOW scope. This is necessary because otherwise such
 events would get lost without notifying components with such bindings.
 However, I am not sure how this method should be triggered. From within
 Component.processKeyEvent() maybe, but calling into Swing code from AWT
 seems so ugly...

My interpretation was that it was up to the user to call this method if
they subclassed JComponent and didn't call super.processKeyEvent from
the subclass' processKeyEvent method.  Or, if they wrote Swing
Components that were not derived from JComponent .. I still thought it
was up to them to call it.  Things like JFrame, which aren't derived
from JComponent, shouldn't call this method internally.

Thanks for implementing this, I believe that was actually in my PR list.

--Tony



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: DefaultStyledDocument fixlet

2005-12-19 Thread Anthony Balkissoon
On Mon, 2005-12-19 at 13:59 +, Roman Kennke wrote:
 Hi there,
 
 this patch fixes DefaultStyledDocument.setParagraphAttributes(), so that
 it doesn't hang in an infinite loop like in the testcase of bug#
 

Hi Roman,
I worked on a patch on Friday that fixed this issue and also added
ElementEdits to the DocumentEvent.  I was going to commit it but my
internet connection went down.  Also, the writeLock() and writeUnlock()
should be in a try/finally block.  The patch includes several changes to
DefaultStyledDocument that I made as I read through the O'Reilly book
beefing up my knowledge about this class before I try to fix PR 24744.
I'll just paste the body of this method (setParagraphAttributes) here,
and let me know if you're okay with this change, and I'll send the full
patch up when it's ready.


  public void setParagraphAttributes(int offset, int length,
 AttributeSet attributes,
 boolean replace)
  {
try
  {
// Must obtain a write lock for this method.  writeLock() and
// writeUnlock() should always be in try/finally blocks to make
// sure that locking occurs in a balanced manner.
writeLock();

// Create a DocumentEvent to use for changedUpdate().
DefaultDocumentEvent ev = 
  new DefaultDocumentEvent (
offset, 
length, 
DocumentEvent.EventType.CHANGE);

// Have to iterate through all the _paragraph_ elements that are
// contained or partially contained in the interval
// (offset, offset + length).
Element rootElement = getDefaultRootElement();
int startElement = rootElement.getElementIndex(offset);
int endElement = rootElement.getElementIndex(offset + length -
1);
if (endElement  startElement)
  endElement = startElement;

for (int i = startElement; i = endElement; i++)
  {
Element par = rootElement.getElement(i);
MutableAttributeSet a = (MutableAttributeSet)
par.getAttributes();
// Add the change to the DocumentEvent.
ev.addEdit(new AttributeUndoableEdit(par, attributes,
replace));
// If replace is true remove the old attributes.
if (replace)
  a.removeAttributes(a);
// Add the new attributes.
a.addAttributes(attributes);
  }
fireChangedUpdate(ev);
fireUndoableEditUpdate(new UndoableEditEvent(this, ev));
  }
finally
  {
writeUnlock();
  }
  }

--Tony



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] Patch: several fixes for DefaultStyledDocument

2005-12-19 Thread Anthony Balkissoon
This is the first part of the work I'm doing on DefaultStyledDocument.
This fixes a couple issues associated with PR 24744 but the bug is not
completely fixed yet, so the testcase for that PR still crashes.  I will
continue to work on this but these changes are ready to go in and may
help get some text/html test apps up and running so I'm committing this
now.

2005-12-19  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(endOffset): New field.
(ElementBuffer.insert): If length is 0 return early.  Set the endOffset
variable here.
(ElementBuffer.insertContentTag): Added special case for when insertion
covers entire range of the current Element.  Replaced (offset + length)
with endOffset everywhere.  Added checks to see if the insertion has 
the same attributes as the surrounding Element(s), in which case we
don't split them, we join them.
(SectionElement.getName): Return the field SectionElementName instead 
of hardcoding a return value.
(getLogicalStyle): As the specs require, if the attributes from the 
resolve parent aren't of type Style, return null.
(setCharacterAttributes): Exit early if length is 0.  Obtain a 
write lock for the body of this method.  Changed the way we iterate
through the paragraphs to be more efficient and more intuitive.  Added
AttributeUndoableEdits to the DocumentEvent and fired the 
UndoableEditUpdate.
(setLogicalStyle): Return early if the Element is null.  Obtain a write
lock for the body of this method.  Fire the appropriate DocumentEvent.
(setParagraphAttributes): Changed the way we iterated through the 
paragraphs because it was incorrect and unintuitive.  Obtained a write
lock within a try/finally block.  Added AttributeUndoableEdits to the 
DocumentEvent and fired the event.
(insertUpdate): Changed the way we iterate because we cannot assume 
the Segment holds the characters starting from index 0.  Give the 
startTag the same attributes as the paragraph.  Removed the useless
offset += len line because len is 0.
(printElements): New temporary debugging method.
(attributeSetsAreSame): New method.

--Tony
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.20
diff -u -r1.20 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	19 Dec 2005 10:21:39 -	1.20
+++ javax/swing/text/DefaultStyledDocument.java	19 Dec 2005 22:36:04 -
@@ -48,6 +48,7 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.event.DocumentEvent;
+import javax.swing.event.UndoableEditEvent;
 import javax.swing.undo.AbstractUndoableEdit;
 import javax.swing.undo.UndoableEdit;
 
@@ -428,6 +429,9 @@
 
 /** Holds the length of structural changes. */
 private int length;
+
+/** Holds the end offset for structural changes. **/
+private int endOffset;
 
 /**
  * The number of inserted end tags. This is a counter which always gets
@@ -675,8 +679,11 @@
 public void insert(int offset, int length, ElementSpec[] data,
DefaultDocumentEvent ev)
 {
+  if (length == 0)
+return;
   this.offset = offset;
   this.length = length;
+  this.endOffset = offset + length;
   documentEvent = ev;
   // Push the root and the paragraph at offset onto the element stack.
   elementStack.clear();
@@ -799,7 +806,7 @@
 }
   return ret;
 }
-
+
 /**
  * Inserts a content element into the document structure.
  *
@@ -810,6 +817,7 @@
   prepareContentInsertion();
   int len = tag.getLength();
   int dir = tag.getDirection();
+  AttributeSet tagAtts = createLeafElement(null, null, 0, 0).getAttributes();
   if (dir == ElementSpec.JoinPreviousDirection)
 {
   // The mauve tests to this class show that a JoinPrevious insertion
@@ -845,45 +853,103 @@
   BranchElement paragraph = (BranchElement) elementStack.peek();
   int index = paragraph.getElementIndex(offset);
   Element current = paragraph.getElement(index);
-
+  
   Element[] added;
-  Element[] removed;
+  Element[] removed = new Element[] {current};
   Element[] splitRes = split(current, offset, length);
-  // Special case for when offset == startOffset or offset == endOffset.
   if (splitRes[0] == null)
 {
   added = new Element[2];
-  added[0] = createLeafElement(paragraph, tag.getAttributes(),
-   offset, offset + length);
+  added[0

[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultS...

2005-12-19 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/19 22:52:32

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultStyledDocument.java 

Log message:
2005-12-19  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(endOffset): New field.
(ElementBuffer.insert): If length is 0 return early.  Set the endOffset
variable here.
(ElementBuffer.insertContentTag): Added special case for when insertion
covers entire range of the current Element.  Replaced (offset + length)
with endOffset everywhere.  Added checks to see if the insertion has
the same attributes as the surrounding Element(s), in which case we
don't split them, we join them.
(SectionElement.getName): Return the field SectionElementName instead
of hardcoding a return value.
(getLogicalStyle): As the specs require, if the attributes from the
resolve parent aren't of type Style, return null.
(setCharacterAttributes): Exit early if length is 0.  Obtain a
write lock for the body of this method.  Changed the way we iterate
through the paragraphs to be more efficient and more intuitive.  Added
AttributeUndoableEdits to the DocumentEvent and fired the
UndoableEditUpdate.
(setLogicalStyle): Return early if the Element is null.  Obtain a write
lock for the body of this method.  Fire the appropriate DocumentEvent.
(setParagraphAttributes): Changed the way we iterated through the
paragraphs because it was incorrect and unintuitive.  Obtained a write
lock within a try/finally block.  Added AttributeUndoableEdits to the
DocumentEvent and fired the event.
(insertUpdate): Changed the way we iterate because we cannot assume
the Segment holds the characters starting from index 0.  Give the
startTag the same attributes as the paragraph.  Removed the useless
offset += len line because len is 0.
(printElements): New temporary debugging method.
(attributeSetsAreSame): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5864tr2=1.5865r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.20tr2=1.21r1=textr2=text




[commit-cp] classpath ./ChangeLog javax/swing/text/Abstract...

2005-12-15 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/15 21:17:46

Modified files:
.  : ChangeLog 
javax/swing/text: AbstractDocument.java 

Log message:
2005-12-15  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/AbstractDocument.java:
(AbstractElement.getAttribute): If no attribute could be found in the
AttributeSet hierarchy, then try the Element hierarchy instead.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5825tr2=1.5826r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/AbstractDocument.java.diff?tr1=1.40tr2=1.41r1=textr2=text




[commit-cp] classpath ./ChangeLog javax/swing/text/DefaultS...

2005-12-14 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/14 19:56:45

Modified files:
.  : ChangeLog 
javax/swing/text: DefaultStyledDocument.java 
javax/swing/text/html: HTMLDocument.java 

Log message:
2005-12-14  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/DefaultStyledDocument.java:
(insert): Put writeLock/writeUnlock combo in a try/finally block. Group
all inserts together so that we can add the appropriate ElementEdit to
the DocumentEvent.
* javax/swing/text/html/HTMLDocument.java:
(debug): New field.
(print): New method. Changed all System.out.println calls to calls to
this method so that they can be turned on and off via the debug
variable.
(HTMLReader.CharacterAction.start): Uncommented code that adds the
argument attributes to the current attributes.
(HTMLReader.HeadAction): Changed superclass to BlockAction instead of
TagAction.
(HTMLReader.blockOpen): Implemented.
(HTMLReader.blockClose): Implemented.
(HTMLReader.addContent): Added calls to printBuffer so if the debug
variable is true we can see what the buffer looks like before and
after adding content.  Also put in the proper check so that we only
flush the buffer if we've buffered the appropriate number of elements
first.
(printBuffer): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5814tr2=1.5815r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/DefaultStyledDocument.java.diff?tr1=1.18tr2=1.19r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/html/HTMLDocument.java.diff?tr1=1.13tr2=1.14r1=textr2=text




Re: [cp-patches] RFC: HTMLDocument.HTMLReader partial implementation

2005-12-13 Thread Anthony Balkissoon
No objections were raised, and I got a couple of go-aheads, so this is
committed as follows (same as before plus 1 more stubbed method that
Lillian needed).

2005-12-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/html/HTMLDocument.java:
(tokenThreshold): New field.
(parser): New field.
(getParser): New API method.
(setParser): New API method.
(getTokenThreshold): New API method.
(setTokenThreshold): New API method.
(getReader(int, int, int, HTML.Tag)): New API method, not implemented.
(HTMLReader): New API class, partially implemented.
(HTMLReader.BlockAction): New API class, not implemented.
(HTMLReader.CharacterAction): Likewise.
(HTMLReader.FormAction): Likewise.
(HTMLReader.HiddenAction): Likewise.
(HTMLReader.IsindexAction): Likewise.
(HTMLReader.ParagraphAction): Likewise.
(HTMLReader.PreAction): Likewise.
(HTMLReader.SpecialAction): Likewise.
(HTMLReader.TagAction): New API class, implemented.
* javax/swing/text/html/HTMLEditorKit.java:
(createDefaultDocument): Set the parser for the new HTMLDocument.

--Tony

On Mon, 2005-12-12 at 17:38 -0500, Anthony Balkissoon wrote:
 This is a partial implementation of HTMLDocument.HTMLReader.  I am still
 working on this, so it will be more fully implemented soon.
 
 I submit this as RFC because it has several methods that have nothing
 more than FIXME: Implement as well as some debugging statements.
 These are there so that Lillian and myself can work on the entire HTML
 package.  Since some of the classes she's working on require
 HTMLDocument.HTMLReader I want these methods to be available so her
 classes can build even if they are not yet implemented, with the
 understanding that I will implement them shortly.  The debugging
 (System.out.println) statements are there so that as we run test apps we
 can see how the different classes are linked together.
 
 Since we are the only two people that I know of working on this
 javax.swing.text.html package I don't think this should be a problem but
 I'm still asking if anyone has objections to me checking in this patch
 with stubs and println's.  Note that all of the stubs have FIXME notes
 and that the println's can easily be taken out before the next release
 if we haven't finished implementing the methods yet.
 
 Objections?
 
 2005-12-12  Anthony Balkissoon  [EMAIL PROTECTED]
 
   * javax/swing/text/html/HTMLDocument.java:
   (tokenThreshold): New field.
   (parser): New field.
   (getParser): New API method.
   (setParser): New API method.
   (getTokenThreshold): New API method.
   (setTokenThreshold): New API method.
   (HTMLReader): New API class, partially implemented.
   (HTMLReader.BlockAction): New API class, not implemented.
   (HTMLReader.CharacterAction): Likewise.
   (HTMLReader.FormAction): Likewise.
   (HTMLReader.HiddenAction): Likewise.
   (HTMLReader.IsindexAction): Likewise.
   (HTMLReader.ParagraphAction): Likewise.
   (HTMLReader.PreAction): Likewise.
   (HTMLReader.SpecialAction): Likewise.
   (HTMLReader.TagAction): New API class, implemented.
   * javax/swing/text/html/HTMLEditorKit.java:
   (createDefaultDocument): Set the parser for the new HTMLDocument.
 
 --Tony
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/text/html/HTMLDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLDocument.java,v
retrieving revision 1.7
diff -u -r1.7 HTMLDocument.java
--- javax/swing/text/html/HTMLDocument.java	9 Dec 2005 17:52:54 -	1.7
+++ javax/swing/text/html/HTMLDocument.java	13 Dec 2005 16:10:41 -
@@ -39,12 +39,18 @@
 package javax.swing.text.html;
 
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Stack;
+import java.util.Vector;
 
 import javax.swing.text.AbstractDocument;
 import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
 import javax.swing.text.DefaultStyledDocument;
 import javax.swing.text.Element;
 import javax.swing.text.ElementIterator;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
 import javax.swing.text.html.HTML.Tag;
 
 /**
@@ -60,6 +66,49 @@
   public static final String AdditionalComments = AdditionalComments;
   URL baseURL = null;
   boolean preservesUnknownTags = true;
+  int tokenThreshold = Integer.MAX_VALUE;
+  HTMLEditorKit.Parser parser;
+  
+  /**
+   * Returns the parser used by this HTMLDocument to insert HTML.
+   * 
+   * @return the parser used by this HTMLDocument to insert HTML.
+   */
+  public HTMLEditorKit.Parser getParser()
+  {
+return parser; 
+  }
+  
+  /**
+   * Sets the parser used

[commit-cp] classpath ./ChangeLog javax/swing/text/html/HTM...

2005-12-13 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/13 16:13:08

Modified files:
.  : ChangeLog 
javax/swing/text/html: HTMLDocument.java HTMLEditorKit.java 

Log message:
2005-12-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/html/HTMLDocument.java:
(tokenThreshold): New field.
(parser): New field.
(getParser): New API method.
(setParser): New API method.
(getTokenThreshold): New API method.
(setTokenThreshold): New API method.
(getReader(int, int, int, HTML.Tag)): New API method, not implemented.
(HTMLReader): New API class, partially implemented.
(HTMLReader.BlockAction): New API class, not implemented.
(HTMLReader.CharacterAction): Likewise.
(HTMLReader.FormAction): Likewise.
(HTMLReader.HiddenAction): Likewise.
(HTMLReader.IsindexAction): Likewise.
(HTMLReader.ParagraphAction): Likewise.
(HTMLReader.PreAction): Likewise.
(HTMLReader.SpecialAction): Likewise.
(HTMLReader.TagAction): New API class, implemented.
* javax/swing/text/html/HTMLEditorKit.java:
(createDefaultDocument): Set the parser for the new HTMLDocument.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5799tr2=1.5800r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/html/HTMLDocument.java.diff?tr1=1.7tr2=1.8r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/html/HTMLEditorKit.java.diff?tr1=1.11tr2=1.12r1=textr2=text




[commit-cp] classpath ./ChangeLog javax/swing/text/html/HTM...

2005-12-13 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/13 21:52:12

Modified files:
.  : ChangeLog 
javax/swing/text/html: HTMLDocument.java 

Log message:
2005-12-13  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/html/HTMLDocument.java:
(HTMLReader.charAttr): Initialize this variable.
(HTMLReader.parseBuffer): Initialize this variable.
(HTMLReader.popDepth): New field.
(HTMLReader.pushDepth): Likewise.
(HTMLReader.offset): Likewise.
(HTMLReader.insertTag): Likewise.
(HTMLReader.insertTagEncountered): Likewise.
(HTMLReader.BlockAction.start): Implemented.
(HTMLReader.BlockAction.end): Implemented.
(HTMLReader.CharacterAction.start): Implemented.
(HTMLReader.CharacterAction.end): Implemented.
(HTMLReader(int)): Call other constructor with default arguments.
(HTMLReader(int, int, int, HTML.Tag)): Save the arguments.
(HTMLReader.flush): Implemented.
(HTMLReader.handleText): Implemented.
(HTMLReader.addContent): Implemented.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5805tr2=1.5806r1=textr2=text
http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/html/HTMLDocument.java.diff?tr1=1.11tr2=1.12r1=textr2=text




[cp-patches] RFC: HTMLDocument.HTMLReader partial implementation

2005-12-12 Thread Anthony Balkissoon
This is a partial implementation of HTMLDocument.HTMLReader.  I am still
working on this, so it will be more fully implemented soon.

I submit this as RFC because it has several methods that have nothing
more than FIXME: Implement as well as some debugging statements.
These are there so that Lillian and myself can work on the entire HTML
package.  Since some of the classes she's working on require
HTMLDocument.HTMLReader I want these methods to be available so her
classes can build even if they are not yet implemented, with the
understanding that I will implement them shortly.  The debugging
(System.out.println) statements are there so that as we run test apps we
can see how the different classes are linked together.

Since we are the only two people that I know of working on this
javax.swing.text.html package I don't think this should be a problem but
I'm still asking if anyone has objections to me checking in this patch
with stubs and println's.  Note that all of the stubs have FIXME notes
and that the println's can easily be taken out before the next release
if we haven't finished implementing the methods yet.

Objections?

2005-12-12  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/text/html/HTMLDocument.java:
(tokenThreshold): New field.
(parser): New field.
(getParser): New API method.
(setParser): New API method.
(getTokenThreshold): New API method.
(setTokenThreshold): New API method.
(HTMLReader): New API class, partially implemented.
(HTMLReader.BlockAction): New API class, not implemented.
(HTMLReader.CharacterAction): Likewise.
(HTMLReader.FormAction): Likewise.
(HTMLReader.HiddenAction): Likewise.
(HTMLReader.IsindexAction): Likewise.
(HTMLReader.ParagraphAction): Likewise.
(HTMLReader.PreAction): Likewise.
(HTMLReader.SpecialAction): Likewise.
(HTMLReader.TagAction): New API class, implemented.
* javax/swing/text/html/HTMLEditorKit.java:
(createDefaultDocument): Set the parser for the new HTMLDocument.

--Tony
Index: javax/swing/text/html/HTMLDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLDocument.java,v
retrieving revision 1.7
diff -u -r1.7 HTMLDocument.java
--- javax/swing/text/html/HTMLDocument.java	9 Dec 2005 17:52:54 -	1.7
+++ javax/swing/text/html/HTMLDocument.java	12 Dec 2005 22:25:59 -
@@ -39,12 +39,18 @@
 package javax.swing.text.html;
 
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Stack;
+import java.util.Vector;
 
 import javax.swing.text.AbstractDocument;
 import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
 import javax.swing.text.DefaultStyledDocument;
 import javax.swing.text.Element;
 import javax.swing.text.ElementIterator;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
 import javax.swing.text.html.HTML.Tag;
 
 /**
@@ -60,6 +66,49 @@
   public static final String AdditionalComments = AdditionalComments;
   URL baseURL = null;
   boolean preservesUnknownTags = true;
+  int tokenThreshold = Integer.MAX_VALUE;
+  HTMLEditorKit.Parser parser;
+  
+  /**
+   * Returns the parser used by this HTMLDocument to insert HTML.
+   * 
+   * @return the parser used by this HTMLDocument to insert HTML.
+   */
+  public HTMLEditorKit.Parser getParser()
+  {
+return parser; 
+  }
+  
+  /**
+   * Sets the parser used by this HTMLDocument to insert HTML.
+   * 
+   * @param p the parser to use
+   */
+  public void setParser (HTMLEditorKit.Parser p)
+  {
+parser = p;
+  }
+  /**
+   * Sets the number of tokens to buffer before trying to display the
+   * Document.
+   * 
+   * @param n the number of tokens to buffer
+   */
+  public void setTokenThreshold (int n)
+  {
+tokenThreshold = n;
+  }
+  
+  /**
+   * Returns the number of tokens that are buffered before the document
+   * is rendered.
+   * 
+   * @return the number of tokens buffered
+   */
+  public int getTokenThreshold ()
+  {
+return tokenThreshold;
+  }
   
   /**
* Returns the location against which to resolve relative URLs.
@@ -267,6 +316,769 @@
   }
   
   /**
+   * A reader to load an HTMLDocument with HTML structure.
+   * 
+   * @author Anthony Balkissoon abalkiss at redhat dot com
+   *
+   */
+  public class HTMLReader extends HTMLEditorKit.ParserCallback
+  {
+/** Holds the current character attribute set **/
+protected MutableAttributeSet charAttr;
+
+protected Vector parseBuffer;
+
+/** A stack for character attribute sets **/
+Stack charAttrStack = new Stack();
+
+/** A mapping between HTML.Tag objects and the actions that handle them **/
+HashMap tagToAction;
+
+/** Tells us whether we've received the '/html' tag yet **/
+boolean endHTMLEncountered = false;
+
+public class

[commit-cp] classpath ./ChangeLog javax/swing/JEditorPane.java

2005-12-09 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/09 19:28:38

Modified files:
.  : ChangeLog 
javax/swing: JEditorPane.java 

Log message:
2005-12-09  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JEditorPane.java:
(setText): Allow the EditorKit to read the text into the Document,
allowing for other than plain text.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5787tr2=1.5788r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/JEditorPane.java.diff?tr1=1.29tr2=1.30r1=textr2=text





[cp-patches] FYI: Patch for JEditorPane

2005-12-08 Thread Anthony Balkissoon
This patch accompanies the new tests in
gnu.testlet.javax.swing.JEditorPane.ContentType

This patch makes JEditorPane handle different content types properly,
using the appropriate EditorKit for different types.  This will allow
Lillian and myself to write test apps for html using JEditorPane because
now it will use HTMLEditorKit to display the content.

2005-12-08  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JEditorPane.java:
(registerMap): New field.
(editorMap): New field.
(JEditorPane()): Call init instead of setEditorKit.
(JEditorPane(String, String)): Likewise.
(init): New method.
(createEditorKitForContentType): Implemented and documented.
(getEditorKitClassNameForContentType): Likewise.
(getEditorKitForContentType): Likewise.
(registerEditorKitForContentType): Likewise.
(replaceSelection): Call super (this is temporary until the real
implementation happens.  There is already a TODO noting that this needs
to be implemented.
(setEditorKitForContentType): Implemented and documented.

--Tony
Index: javax/swing/JEditorPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JEditorPane.java,v
retrieving revision 1.27
diff -u -r1.27 JEditorPane.java
--- javax/swing/JEditorPane.java	22 Nov 2005 21:58:15 -	1.27
+++ javax/swing/JEditorPane.java	8 Dec 2005 19:49:41 -
@@ -45,6 +45,7 @@
 import java.io.Reader;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.HashMap;
 
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleHyperlink;
@@ -88,6 +89,7 @@
  *
  * @author original author unknown
  * @author Roman Kennke ([EMAIL PROTECTED])
+ * @author Anthony Balkissoon abalkiss at redhat dot com
  */
 public class JEditorPane extends JTextComponent
 {
@@ -507,10 +509,16 @@
   private EditorKit editorKit;
   
   boolean focus_root;
+  
+  // A mapping between content types and registered EditorKit types
+  static HashMap registerMap;
+  
+  // A mapping between content types and used EditorKits
+  HashMap editorMap;  
 
   public JEditorPane()
   {
-setEditorKit(createDefaultEditorKit());
+init(createDefaultEditorKit());
   }
 
   public JEditorPane(String url) throws IOException
@@ -520,7 +528,7 @@
 
   public JEditorPane(String type, String text)
   {
-setEditorKit(createEditorKitForContentType(type));
+init(createEditorKitForContentType(type));
 setText(text);
   }
 
@@ -529,15 +537,61 @@
 this();
 setPage(url);
   }
+  
+  /**
+   * Called by the constructors to set the EditorKit and set up the 
+   * default bindings for content types and EditorKits.
+   * 
+   * @param kit the initial EditorKit
+   */
+  void init(EditorKit kit)
+  {
+setEditorKit(kit);
+editorMap = new HashMap();
+registerMap = new HashMap();
+registerEditorKitForContentType(application/rtf,
+javax.swing.text.rtf.RTFEditorKit);
+registerEditorKitForContentType(text/plain,
+javax.swing.JEditorPane$PlainEditorKit);
+registerEditorKitForContentType(text/html,
+javax.swing.text.html.HTMLEditorKit);
+registerEditorKitForContentType(text/rtf,
+javax.swing.text.rtf.RTFEditorKit);
+  }
 
   protected EditorKit createDefaultEditorKit()
   {
 return new PlainEditorKit();
   }
 
+  /**
+   * Creates and returns an EditorKit that is appropriate for the given 
+   * content type.  This is created using the default recognized types
+   * plus any EditorKit types that have been registered.
+   * 
+   * @see #registerEditorKitForContentType(String, String)
+   * @see #registerEditorKitForContentType(String, String, ClassLoader)
+   * @param type the content type
+   * @return an EditorKit for use with the given content type
+   */
   public static EditorKit createEditorKitForContentType(String type)
   {
-return new PlainEditorKit();
+// TODO: Have to handle the case where a ClassLoader was specified
+// when the EditorKit was registered
+EditorKit e = null;
+String className = (String)registerMap.get(type);
+if (className != null)
+  {
+try
+{
+  e = (EditorKit) Class.forName(className).newInstance();
+}
+catch (Exception e2)
+{
+  // TODO: Not sure what to do here.
+}
+  }
+return e;
   }
 
   /**
@@ -586,14 +640,44 @@
 return editorKit;
   }
 
+  /**
+   * Returns the class name of the EditorKit associated with the given
+   * content type.
+   * 
+   * @since 1.3
+   * @param type the content type
+   * @return the class name of the EditorKit associated with this content type
+   */
   public static String getEditorKitClassNameForContentType(String type)
   {
-return text/plain

Re: [cp-patches] FYI: Patch for JEditorPane

2005-12-08 Thread Anthony Balkissoon
I wrote the functionality, but forgot to actually USE it.. so this new
patch actually makes JEditorPane by default use HTMLEditorKit when
needed.

This one is accompanied by
gnu.testlet.javax.swing.JEditorPane.ConstructorsAndTypes which
demonstrates the correct behaviour but which we do not pass yet because
of an AssertionError being thrown in the text classes.  This may be
happening because methods that should be overridden in the html packages
are not completed yet.

2005-12-08  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JEditorPane.java:
(init): Changed to no-argument instead of taking in an EditorKit and
passing it to setEditorKit.  Callers will have to call setEditorKit
themselves.
(JEditorPane()): Changed call to init to have no arguments, call
setEditorKit after init.
(JEditorPane(String, String)): Likewise.
(JEditorPane(URL)): Don't call default constructor, call init and then
setEditorKit using the appropriate EditorKit for text/html.

--Tony

On Thu, 2005-12-08 at 15:02 -0500, Anthony Balkissoon wrote:
 This patch accompanies the new tests in
 gnu.testlet.javax.swing.JEditorPane.ContentType
 
 This patch makes JEditorPane handle different content types properly,
 using the appropriate EditorKit for different types.  This will allow
 Lillian and myself to write test apps for html using JEditorPane because
 now it will use HTMLEditorKit to display the content.
 
 2005-12-08  Anthony Balkissoon  [EMAIL PROTECTED]
 
   * javax/swing/JEditorPane.java:
   (registerMap): New field.
   (editorMap): New field.
   (JEditorPane()): Call init instead of setEditorKit.
   (JEditorPane(String, String)): Likewise.
   (init): New method.
   (createEditorKitForContentType): Implemented and documented.
   (getEditorKitClassNameForContentType): Likewise.
   (getEditorKitForContentType): Likewise.
   (registerEditorKitForContentType): Likewise.
   (replaceSelection): Call super (this is temporary until the real
   implementation happens.  There is already a TODO noting that this needs
   to be implemented.
   (setEditorKitForContentType): Implemented and documented.
 
 --Tony
 ___
 Classpath-patches mailing list
 Classpath-patches@gnu.org
 http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/JEditorPane.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/JEditorPane.java,v
retrieving revision 1.28
diff -u -r1.28 JEditorPane.java
--- javax/swing/JEditorPane.java	8 Dec 2005 20:00:42 -	1.28
+++ javax/swing/JEditorPane.java	8 Dec 2005 20:12:54 -
@@ -518,7 +518,8 @@
 
   public JEditorPane()
   {
-init(createDefaultEditorKit());
+init();
+setEditorKit(createDefaultEditorKit());
   }
 
   public JEditorPane(String url) throws IOException
@@ -528,25 +529,24 @@
 
   public JEditorPane(String type, String text)
   {
-init(createEditorKitForContentType(type));
+init();
+setEditorKit(createEditorKitForContentType(type));
 setText(text);
   }
 
   public JEditorPane(URL url) throws IOException
   {
-this();
+init ();
+setEditorKit (createEditorKitForContentType(text/html));;
 setPage(url);
   }
   
   /**
-   * Called by the constructors to set the EditorKit and set up the 
-   * default bindings for content types and EditorKits.
-   * 
-   * @param kit the initial EditorKit
+   * Called by the constructors to set up the default bindings for content 
+   * types and EditorKits.
*/
-  void init(EditorKit kit)
+  void init()
   {
-setEditorKit(kit);
 editorMap = new HashMap();
 registerMap = new HashMap();
 registerEditorKitForContentType(application/rtf,
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[commit-cp] classpath ./ChangeLog javax/swing/JEditorPane.java

2005-12-08 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/08 20:00:43

Modified files:
.  : ChangeLog 
javax/swing: JEditorPane.java 

Log message:
2005-12-08  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JEditorPane.java:
(registerMap): New field.
(editorMap): New field.
(JEditorPane()): Call init instead of setEditorKit.
(JEditorPane(String, String)): Likewise.
(init): New method.
(createEditorKitForContentType): Implemented and documented.
(getEditorKitClassNameForContentType): Likewise.
(getEditorKitForContentType): Likewise.
(registerEditorKitForContentType): Likewise.
(replaceSelection): Call super (this is temporary until the real
implementation happens.  There is already a TODO noting that this needs
to be implemented.
(setEditorKitForContentType): Implemented and documented.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5780tr2=1.5781r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/JEditorPane.java.diff?tr1=1.27tr2=1.28r1=textr2=text





[commit-cp] classpath ./ChangeLog javax/swing/JEditorPane.java

2005-12-08 Thread Anthony Balkissoon
CVSROOT:/cvsroot/classpath
Module name:classpath
Branch: 
Changes by: Anthony Balkissoon [EMAIL PROTECTED]  05/12/08 20:16:37

Modified files:
.  : ChangeLog 
javax/swing: JEditorPane.java 

Log message:
2005-12-08  Anthony Balkissoon  [EMAIL PROTECTED]

* javax/swing/JEditorPane.java:
(init): Changed to no-argument instead of taking in an EditorKit and
passing it to setEditorKit.  Callers will have to call setEditorKit
themselves.
(JEditorPane()): Changed call to init to have no arguments, call
setEditorKit after init.
(JEditorPane(String, String)): Likewise.
(JEditorPane(URL)): Don't call default constructor, call init and then
setEditorKit using the appropriate EditorKit for text/html.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.5781tr2=1.5782r1=textr2=text
http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/javax/swing/JEditorPane.java.diff?tr1=1.28tr2=1.29r1=textr2=text





Re: Free Swing runs with JGoodies Forms

2005-12-07 Thread Anthony Balkissoon
On Tue, 2005-12-06 at 02:26 +0100, Robert Schuster wrote:
 Thanks to all Swing hackers!!!
 
Hey!  I'm a Swing Hacker!  You're welcome!  Took a look at the
screenshots, that's awesome!

--Tony



___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


[cp-patches] Patch: BoxLayout fix

2005-12-06 Thread Anthony Balkissoon
2005-12-06  Anthony Balkissoon  [EMAIL PROTECTED]

Fixes bug #25233
* javax/swing/BoxLayout.java:
(maximumLayoutSize): Don't add the Insets to the Dimension calculated 
in checkTotalRequirements().



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


  1   2   3   4   >