foray-commit Mailing List for FOray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
|
8
|
9
|
10
(10) |
11
(2) |
12
(16) |
13
(1) |
14
(23) |
|
15
(10) |
16
(5) |
17
(13) |
18
(3) |
19
(5) |
20
|
21
|
|
22
|
23
|
24
|
25
|
26
|
27
|
28
|
|
29
|
30
|
31
|
|
|
|
|
|
From: <vic...@us...> - 2009-03-19 17:27:37
|
Revision: 10719
http://foray.svn.sourceforge.net/foray/?rev=10719&view=rev
Author: victormote
Date: 2009-03-19 17:27:22 +0000 (Thu, 19 Mar 2009)
Log Message:
-----------
Remove unnecessary dependencies on FOray PDF.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 17:22:18 UTC (rev 10718)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 17:27:22 UTC (rev 10719)
@@ -38,7 +38,6 @@
import org.foray.common.ps.PsColor;
import org.foray.common.ps.PsUtil;
import org.foray.pdf.PDFGraphicsState;
-import org.foray.pdf.object.PDFAnnotList;
import org.foray.pdf.object.PDFDocument;
import org.foray.pdf.object.PDFString;
import org.foray.pdf.object.PDFXObject;
@@ -120,9 +119,6 @@
/** The current stream to add PDF commands to. */
private CharacterOutputStream currentStream;
- /** The current annotation list to add annotations to. */
- private PDFAnnotList currentAnnotList = null;
-
/** The override font. */
private org.axsl.font.FontUse overrideFont = null;
@@ -265,9 +261,6 @@
public void addLink(final PdfPage pdfPage, final Shape bounds,
final AffineTransform trans, final String dest,
final boolean externalLink) {
- if (this.currentAnnotList == null) {
- this.currentAnnotList = new PDFAnnotList(this.pdfDoc);
- }
final AffineTransform at = getTransform();
Shape b = at.createTransformedShape(bounds);
b = trans.createTransformedShape(b);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-19 17:22:28
|
Revision: 10718
http://foray.svn.sourceforge.net/foray/?rev=10718&view=rev
Author: victormote
Date: 2009-03-19 17:22:18 +0000 (Thu, 19 Mar 2009)
Log Message:
-----------
Remove unnecessary dependencies on FOray PDF.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 17:01:51 UTC (rev 10717)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 17:22:18 UTC (rev 10718)
@@ -40,8 +40,6 @@
import org.foray.pdf.PDFGraphicsState;
import org.foray.pdf.object.PDFAnnotList;
import org.foray.pdf.object.PDFDocument;
-import org.foray.pdf.object.PDFLink;
-import org.foray.pdf.object.PDFPage;
import org.foray.pdf.object.PDFString;
import org.foray.pdf.object.PDFXObject;
@@ -50,6 +48,7 @@
import org.axsl.font.FontUtility;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.output.GraphicOutputContext;
+import org.axsl.pdf.PdfPage;
import org.axsl.pdf.PdfPattern;
import org.apache.commons.logging.Log;
@@ -263,7 +262,7 @@
* @param dest The name of the destination.
* @param externalLink Set to true if the link is to an external document.
*/
- public void addLink(final PDFPage pdfPage, final Shape bounds,
+ public void addLink(final PdfPage pdfPage, final Shape bounds,
final AffineTransform trans, final String dest,
final boolean externalLink) {
if (this.currentAnnotList == null) {
@@ -275,14 +274,12 @@
final Rectangle2D.Float linkRectangle =
(Rectangle2D.Float) b.getBounds2D();
linkRectangle.height *= -1;
- PDFLink link = null;
if (externalLink) {
final String pdfdest = "/XYZ " + dest;
- link = new PDFLink(pdfPage, linkRectangle, pdfdest);
+ pdfPage.makeLink(linkRectangle, pdfdest, true);
} else {
- link = pdfPage.makeLink(linkRectangle, dest, false);
+ pdfPage.makeLink(linkRectangle, dest, false);
}
- this.currentAnnotList.addAnnotation(link);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-19 17:02:05
|
Revision: 10717
http://foray.svn.sourceforge.net/foray/?rev=10717&view=rev
Author: victormote
Date: 2009-03-19 17:01:51 +0000 (Thu, 19 Mar 2009)
Log Message:
-----------
Remove unnecessary dependency on PDFDocument.
Modified Paths:
--------------
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFLink.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 16:44:01 UTC (rev 10716)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 17:01:51 UTC (rev 10717)
@@ -278,7 +278,7 @@
PDFLink link = null;
if (externalLink) {
final String pdfdest = "/XYZ " + dest;
- link = new PDFLink(this.pdfDoc, pdfPage, linkRectangle, pdfdest);
+ link = new PDFLink(pdfPage, linkRectangle, pdfdest);
} else {
link = pdfPage.makeLink(linkRectangle, dest, false);
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFLink.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFLink.java 2009-03-19 16:44:01 UTC (rev 10716)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFLink.java 2009-03-19 17:01:51 UTC (rev 10717)
@@ -51,56 +51,48 @@
/**
* Create a PDFLink object.
- * @param doc The parent PDF document.
* @param page The page on which this link exists.
* @param rect The rectangle which outlines the link. All dimension in the
* rectangle should be expressed in 1/1000ths of a user space unit.
*/
- private PDFLink(final PDFDocument doc, final PDFPage page,
- final Rectangle2D rect) {
- super(doc, rect);
+ private PDFLink(final PDFPage page, final Rectangle2D rect) {
+ super(page.getPDFDocument(), rect);
}
/**
* Constructor for a link to a named destination.
- * @param doc The parent PDF document.
* @param page The page on which this link exists.
* @param rect The rectangle which outlines the link. All dimension in the
* rectangle should be expressed in 1/1000ths of a user space unit.
* @param destinationName The name of the destination to which this link
* points.
*/
- public PDFLink(final PDFDocument doc, final PDFPage page,
- final Rectangle2D rect, final String destinationName) {
- this(doc, page, rect);
- this.destinationName = new PDFTextString(doc, destinationName);
+ public PDFLink(final PDFPage page, final Rectangle2D rect, final String destinationName) {
+ this(page, rect);
+ this.destinationName = new PDFTextString(page.getPDFDocument(), destinationName);
}
/**
* Constructor for a link to a named destination.
- * @param doc The parent PDF document.
* @param page The page on which this link exists.
* @param rect The rectangle which outlines the link. All dimension in the
* rectangle should be expressed in 1/1000ths of a user space unit.
* @param destination The destination to which this link points.
*/
- public PDFLink(final PDFDocument doc, final PDFPage page,
- final Rectangle2D rect, final PDFDestination destination) {
- this(doc, page, rect);
+ public PDFLink(final PDFPage page, final Rectangle2D rect, final PDFDestination destination) {
+ this(page, rect);
this.destination = destination;
}
/**
* Constructor for a link to an action.
- * @param doc The parent PDF document.
* @param page The page on which this link exists.
* @param rect The rectangle which outlines the link. All dimension in the
* rectangle should be expressed in 1/1000ths of a user space unit.
* @param action The action to be activated by this link.
*/
- public PDFLink(final PDFDocument doc, final PDFPage page,
- final Rectangle2D rect, final PDFAction action) {
- this(doc, page, rect);
+ public PDFLink(final PDFPage page, final Rectangle2D rect, final PDFAction action) {
+ this(page, rect);
this.action = action;
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2009-03-19 16:44:01 UTC (rev 10716)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2009-03-19 17:01:51 UTC (rev 10717)
@@ -194,9 +194,9 @@
} else { // URI
action = new PDFUri(destination);
}
- link = new PDFLink(pdfDoc, this, rect, action);
+ link = new PDFLink(this, rect, action);
} else { // linkType is internal
- link = new PDFLink(pdfDoc, this, rect, destination);
+ link = new PDFLink(this, rect, destination);
}
getAnnotList().addAnnotation(link);
return link;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-19 16:44:16
|
Revision: 10716
http://foray.svn.sourceforge.net/foray/?rev=10716&view=rev
Author: victormote
Date: 2009-03-19 16:44:01 +0000 (Thu, 19 Mar 2009)
Log Message:
-----------
Conform to new aXSL requirements for Pdf gradients.
Modified Paths:
--------------
trunk/foray/foray-graphic/.classpath
trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java
Modified: trunk/foray/foray-graphic/.classpath
===================================================================
--- trunk/foray/foray-graphic/.classpath 2009-03-19 15:13:07 UTC (rev 10715)
+++ trunk/foray/foray-graphic/.classpath 2009-03-19 16:44:01 UTC (rev 10716)
@@ -30,5 +30,6 @@
<classpathentry kind="lib" path="/FOray Lib/xercesImpl-2.7.1.jar" sourcepath="/FOray Lib-Build/xerces/Xerces-J-src.2.7.1.zip"/>
<classpathentry kind="lib" path="/FOray Lib-Build/junit/junit-4.4.jar" sourcepath="/FOray Lib-Build/junit/junit-4.4-src.jar"/>
<classpathentry kind="lib" path="/FOray Lib/commons-io-1.4.jar" sourcepath="/FOray Lib-Build/commons-io/commons-io-1.4-sources.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/axslPdf"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java
===================================================================
--- trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 15:13:07 UTC (rev 10715)
+++ trunk/foray/foray-graphic/src/java/org/foray/graphic/batik/PDFGraphics2D.java 2009-03-19 16:44:01 UTC (rev 10716)
@@ -42,7 +42,6 @@
import org.foray.pdf.object.PDFDocument;
import org.foray.pdf.object.PDFLink;
import org.foray.pdf.object.PDFPage;
-import org.foray.pdf.object.PDFPattern;
import org.foray.pdf.object.PDFString;
import org.foray.pdf.object.PDFXObject;
@@ -51,6 +50,7 @@
import org.axsl.font.FontUtility;
import org.axsl.graphic.GraphicException;
import org.axsl.graphic.output.GraphicOutputContext;
+import org.axsl.pdf.PdfPattern;
import org.apache.commons.logging.Log;
@@ -584,9 +584,7 @@
final ColorSpace aColorSpace = ColorSpace.getInstance(
ColorSpace.CS_sRGB);
- final PDFPattern myPat = PDFPattern.createGradient(false,
- aColorSpace,
- someColors, null, theCoords, this.pdfDoc);
+ final PdfPattern myPat = this.pdfDoc.createGradient(false, aColorSpace, someColors, null, theCoords);
this.write(myPat.getSetterString(fill));
} else if (paint instanceof TexturePaint) { }
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2009-03-19 15:13:07 UTC (rev 10715)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2009-03-19 16:44:01 UTC (rev 10716)
@@ -36,11 +36,14 @@
package org.foray.pdf.object;
+import org.foray.common.ColorUtil;
+
import org.axsl.font.Font;
import org.axsl.font.FontUse;
import org.axsl.graphic.Graphic;
import org.axsl.pdf.PdfException;
import org.axsl.pdf.PdfPageLabelStyle;
+import org.axsl.pdf.PdfPattern;
import org.axsl.pdf.PdfVersion;
import org.axsl.ps.Encoding;
@@ -83,6 +86,10 @@
/** A bogus object added to the location list to ensure capacity. */
private static final Integer LOCATION_PLACEHOLDER = new Integer(0);
+ /** Constant indicating the number of components in a radial shading, that
+ * is, 6. */
+ private static final int QTY_RADIAL_SHADING_COMPONENTS = 6;
+
/** A binary comment as recommended by the PDF spec (3.4.1). */
private static final String BINARY_COMMENT = new String(new char[] {
(char) 0xAA,
@@ -775,4 +782,102 @@
this.getRoot().addPageLabel(startingPageIndex, newPageLabel);
}
+ /**
+ * {@inheritDoc}
+ */
+ public PdfPattern createGradient(final boolean radial, final ColorSpace theColorSpace, final List<Color> theColors,
+ final List<Double> theBounds, final List<Double> theCoords) {
+ PDFShading myShad;
+ PDFFunction myfunky;
+ PDFFunction myfunc;
+ List<Double> theCzero;
+ List<Double> theCone;
+ PDFPattern myPattern;
+ final double interpolation = 1.000;
+ final List<PDFFunction> theFunctions = new ArrayList<PDFFunction>();
+
+ int currentPosition;
+ final int lastPosition = theColors.size() - 1;
+
+
+ // if 5 elements, the penultimate element is 3.
+ // do not go beyond that, because you always need
+ // to have a next color when creating the function.
+
+ for (currentPosition = 0; currentPosition < lastPosition;
+ currentPosition++) { // for every consecutive color pair
+ Color currentColor = theColors.get(currentPosition);
+ Color nextColor = theColors.get(currentPosition + 1);
+ /* The colorspace must be consistent. */
+ if (theColorSpace.getType()
+ != currentColor.getColorSpace().getType()) {
+ currentColor = ColorUtil.convertColorSpace(currentColor,
+ theColorSpace);
+ }
+
+ if (theColorSpace.getType()
+ != nextColor.getColorSpace().getType()) {
+ nextColor = ColorUtil.convertColorSpace(nextColor,
+ theColorSpace);
+ }
+
+ theCzero = colorToDoubleList(currentColor);
+ theCone = colorToDoubleList(nextColor);
+
+ myfunc = new PDFFunction(this, 2, null, null,
+ theCzero, theCone, interpolation);
+
+ theFunctions.add(myfunc);
+
+ } // end of for every consecutive color pair
+
+ myfunky = new PDFFunction(this, PDFFunction.TYPE_STITCHING, null,
+ null, theFunctions, theBounds, null);
+ if (radial) {
+ if (theCoords.size() == PDFDocument.QTY_RADIAL_SHADING_COMPONENTS) {
+ myShad = new PDFShading(this, PDFShading.TYPE_RADIAL,
+ theColorSpace, null, null,
+ false, theCoords, null, myfunky,
+ null);
+ } else { // if the center x, center y, and radius specifiy
+ // the gradient, then assume the same center x, center y,
+ // and radius of zero for the other necessary component
+ final List<Double> newCoords = new ArrayList<Double>();
+ newCoords.add(theCoords.get(0));
+ newCoords.add(theCoords.get(1));
+ newCoords.add(theCoords.get(2));
+ newCoords.add(theCoords.get(0));
+ newCoords.add(theCoords.get(1));
+ newCoords.add(new Double(0.0));
+ myShad = new PDFShading(this, PDFShading.TYPE_RADIAL,
+ theColorSpace,
+ null, null, false, newCoords, null, myfunky,
+ null);
+ }
+ } else {
+ myShad = new PDFShading(this, 2, theColorSpace,
+ null, null, false, theCoords, null, myfunky, null);
+ }
+ myPattern = new PDFPattern(this, 2, myShad, null,
+ null, null);
+ return myPattern;
+ }
+
+ /**
+ * Convert a color to a list of its components.
+ * @param theColor The color to be converted.
+ * @return The list of the color components.
+ */
+ static List<Double> colorToDoubleList(final Color theColor) {
+ final List<Double> theColorVector = new ArrayList<Double>();
+ if (theColor == null) {
+ return theColorVector;
+ }
+ final float[] colorComponents = theColor.getColorComponents(null);
+ for (int i = 0; i < colorComponents.length; i++) {
+ theColorVector.add(new Double(colorComponents[i]));
+ }
+ return theColorVector;
+ }
+
}
Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java
===================================================================
--- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2009-03-19 15:13:07 UTC (rev 10715)
+++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPattern.java 2009-03-19 16:44:01 UTC (rev 10716)
@@ -28,12 +28,8 @@
package org.foray.pdf.object;
-import org.foray.common.ColorUtil;
import org.foray.common.ps.PsUtil;
-import java.awt.Color;
-import java.awt.color.ColorSpace;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -47,12 +43,8 @@
*
* All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.
*/
-public class PDFPattern extends PDFPathPaint {
+public class PDFPattern extends PDFPathPaint implements org.axsl.pdf.PdfPattern {
- /** Constant indicating the number of components in a radial shading, that
- * is, 6. */
- private static final int QTY_RADIAL_SHADING_COMPONENTS = 6;
-
/** The resources associated with this pattern. */
private PDFResources resources = null;
@@ -186,113 +178,6 @@
}
/**
- * Static method for creating a gradient pattern.
- * @param radial Indicates whether the gradient is a radial gradient.
- * @param theColorSpace The color space for the gradient.
- * @param theColors The colors for the gradient.
- * @param theBounds The bounds of the gradient.
- * @param theCoords The coordinates of the gradient.
- * @param document The parent PDF document.
- * @return The pattern for the gradient.
- */
- public static PDFPattern createGradient(final boolean radial,
- final ColorSpace theColorSpace, final List<Color> theColors,
- final List<Double> theBounds, final List<Double> theCoords,
- final PDFDocument document) {
- PDFShading myShad;
- PDFFunction myfunky;
- PDFFunction myfunc;
- List<Double> theCzero;
- List<Double> theCone;
- PDFPattern myPattern;
- final double interpolation = 1.000;
- final List<PDFFunction> theFunctions = new ArrayList<PDFFunction>();
-
- int currentPosition;
- final int lastPosition = theColors.size() - 1;
-
-
- // if 5 elements, the penultimate element is 3.
- // do not go beyond that, because you always need
- // to have a next color when creating the function.
-
- for (currentPosition = 0; currentPosition < lastPosition;
- currentPosition++) { // for every consecutive color pair
- Color currentColor = theColors.get(currentPosition);
- Color nextColor = theColors.get(currentPosition + 1);
- /* The colorspace must be consistent. */
- if (theColorSpace.getType()
- != currentColor.getColorSpace().getType()) {
- currentColor = ColorUtil.convertColorSpace(currentColor,
- theColorSpace);
- }
-
- if (theColorSpace.getType()
- != nextColor.getColorSpace().getType()) {
- nextColor = ColorUtil.convertColorSpace(nextColor,
- theColorSpace);
- }
-
- theCzero = colorToDoubleList(currentColor);
- theCone = colorToDoubleList(nextColor);
-
- myfunc = new PDFFunction(document, 2, null, null,
- theCzero, theCone, interpolation);
-
- theFunctions.add(myfunc);
-
- } // end of for every consecutive color pair
-
- myfunky = new PDFFunction(document, PDFFunction.TYPE_STITCHING, null,
- null, theFunctions, theBounds, null);
- if (radial) {
- if (theCoords.size() == PDFPattern.QTY_RADIAL_SHADING_COMPONENTS) {
- myShad = new PDFShading(document, PDFShading.TYPE_RADIAL,
- theColorSpace, null, null,
- false, theCoords, null, myfunky,
- null);
- } else { // if the center x, center y, and radius specifiy
- // the gradient, then assume the same center x, center y,
- // and radius of zero for the other necessary component
- final List<Double> newCoords = new ArrayList<Double>();
- newCoords.add(theCoords.get(0));
- newCoords.add(theCoords.get(1));
- newCoords.add(theCoords.get(2));
- newCoords.add(theCoords.get(0));
- newCoords.add(theCoords.get(1));
- newCoords.add(new Double(0.0));
- myShad = new PDFShading(document, PDFShading.TYPE_RADIAL,
- theColorSpace,
- null, null, false, newCoords, null, myfunky,
- null);
- }
- } else {
- myShad = new PDFShading(document, 2, theColorSpace,
- null, null, false, theCoords, null, myfunky, null);
- }
- myPattern = new PDFPattern(document, 2, myShad, null,
- null, null);
- return myPattern;
- }
-
- /**
- * Convert a color to a list of its components.
- * @param theColor The color to be converted.
- * @return The list of the color components.
- */
- static List<Double> colorToDoubleList(final Color theColor) {
- final List<Double> theColorVector = new ArrayList<Double>();
- if (theColor == null) {
- return theColorVector;
- }
- final float[] colorComponents = theColor.getColorComponents(null);
- for (int i = 0; i < colorComponents.length; i++) {
- theColorVector.add(new Double(colorComponents[i]));
- }
- return theColorVector;
- }
-
- /**
* represent as PDF. Whatever the FunctionType is, the correct
* representation spits out. The sets of required and optional
* attributes are different for each type, but if a required
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-19 15:13:20
|
Revision: 10715
http://foray.svn.sourceforge.net/foray/?rev=10715&view=rev
Author: victormote
Date: 2009-03-19 15:13:07 +0000 (Thu, 19 Mar 2009)
Log Message:
-----------
Before creating a new node, check for an overflow condition.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-18 16:25:51 UTC (rev 10714)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-19 15:13:07 UTC (rev 10715)
@@ -298,7 +298,7 @@
return currentNodeIndex;
} else {
/* This node is not a zero-terminated node. We need to create one to hold the value. */
- final char newNodeIndex = this.freenode ++;
+ final char newNodeIndex = createNode();
/* In addition to adding a node, we are adding a mapped pair here. */
this.length++;
/* We are interposing the new node between the parent and the current node. */
@@ -335,7 +335,7 @@
* @return The index to the newly-created node.
*/
private char createBranch(final CharSequence key, final int start, final int end, final char value) {
- final char currentNodeIndex = this.freenode++;
+ final char currentNodeIndex = createNode();
final int len = end - start;
/* Holds data. */
this.eq[currentNodeIndex] = value;
@@ -371,7 +371,7 @@
this.keyChar[nodeIndex] = this.compressedKeys.get(this.lo[nodeIndex]);
/* Create and initialize the new node. */
- final char newNodeIndex = this.freenode++;
+ final char newNodeIndex = createNode();
this.lo[newNodeIndex] = this.lo[nodeIndex];
this.eq[newNodeIndex] = this.eq[nodeIndex];
this.hi[newNodeIndex] = this.hi[nodeIndex];
@@ -539,11 +539,25 @@
* Returns the number of nodes in the tree.
* @return The number of nodes in the tree.
*/
- int getNodeCount() {
+ public int getNodeCount() {
return this.freenode;
}
/**
+ * Allocates an index for a new node, after first checking for an overflow.
+ * @return The index to the new node.
+ */
+ private char createNode() {
+ if (this.freenode >= Character.MAX_VALUE) {
+ throw new IllegalStateException("Node capacity of " + this.getClass().getName() + " is limited to "
+ + Character.MAX_VALUE);
+ }
+ final char newNode = this.freenode;
+ this.freenode ++;
+ return newNode;
+ }
+
+ /**
* {@inheritDoc}
*/
public TernaryTreeMap clone() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-18 17:22:45
|
Revision: 10714
http://foray.svn.sourceforge.net/foray/?rev=10714&view=rev
Author: victormote
Date: 2009-03-18 16:25:51 +0000 (Wed, 18 Mar 2009)
Log Message:
-----------
1. Clean up documentation a bit.
2. Add a bunch of to-do items.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-18 15:37:34 UTC (rev 10713)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-18 16:25:51 UTC (rev 10714)
@@ -38,11 +38,22 @@
import java.util.Stack;
/**
- * <p>A map whose key is always a {@link CharSequence} (usually a {@link String}), and whose value
- * is a char, usually used to store an index into some other data structure.
- * This class is intended to serve as a base class or helper class for natural-language dictionaries
- * and similar data structures.</p>
+ * <p>A map whose key is always a {@link CharSequence} (usually a {@link String}), and whose value is a char, usually
+ * used to store an index into some other data structure.
+ * This class is intended to serve as a base class or helper class for natural-language dictionaries and similar data
+ * structures.</p>
*
+ * <p>The values {@link Character#MIN_VALUE} (0x0000) and {@link Character#MAX_VALUE} (0xFFFF) have special significance
+ * to the internal structures in this class. Mapping strings that include these values will have unpredictable and
+ * probably horrible results.</p>
+ *
+ * <p>Ternary means "grouped in threes".
+ * Each node in the tree has up to three child nodes: a "high" branch for values greater than that in the node, a "low"
+ * branch for values less than that in the node, and an "equal" branch for the value that is equal to that in the node.
+ * This provides efficiency in both speed and memory for processing textual data.
+ * The memory benefits come from the fact that similar Strings are actually stored in the same location.
+ * A properly balances tree is fast because it does not need to traverse a large number of nodes to find a value.</p>
+ *
* <p>A ternary search tree is a hybrid between a binary tree and a digital search tree (trie).
* Ternary trees have some nice properties, including the following:
* <ul>
@@ -51,27 +62,52 @@
* <li>Retrieval of all keys within a given distance from the target is possible.</li>
* <li>The storage requirements are higher than a binary tree but a lot less than a trie.</li>
* <li>Performance is comparable with a hash table.
- * Sometimes it outperforms a hash function, and can usually determine a miss faster than a
- * hash.</li>
+ * Sometimes it outperforms a hash function, and can usually determine a miss faster than a hash.</li>
* </ul>
* </p>
*
- * <p>In this implementation the value is a char (think "unsigned short"), and is stored in the leaf
- * nodes of the tree.
+ * <p>In this implementation the value is a char (think "unsigned short"), and is stored in the leaf nodes of the tree.
* This limits the number of nodes to 65,536.
- * Branches that contain only one key are compressed to one node by storing a pointer to the trailer
- * substring of the key.
+ * Branches that contain only one key are compressed to one node by storing a pointer to the trailer substring of the
+ * key.
* A compressed branch needs only one node per key plus the size of the string key.
- * Compressed branches are decompressed as needed when another key with same prefix is inserted.
+ * Compressed branches are decompressed as needed when another key with same prefix is inserted.
* This saves a lot of space, especially for long keys.</p>
*
- * <p>This class could be extended to or embedded in a general map that would allow arbitrary
- * objects to be values in the map.
- * One scheme for doing so would be to create an array of the value Objects, and use this class to
- * store the indexes to that array.</p>
+ * <p>This class could be extended to or embedded in a general map that would allow arbitrary objects to be values in
+ * the map.
+ * One scheme for doing so would be to create an array of the value Objects, and use this class to store the indexes to
+ * that array.</p>
*/
public class TernaryTreeMap implements Cloneable, Serializable {
+ /*
+ * Some things to consider changing in this class:
+ * 1. TODO: The nodes containing values are currently zero-terminated.
+ * In other words, an extra node is created for the "zero" that marks the occurrence of a value node.
+ * It might make sense to add another array for the value, and skip the extra node for the zero-termination.
+ * The memory consumed by the extra array might well be offset by the memory saved by getting rid of the extra
+ * nodes.
+ * This tree would also be much shallower, presumably resulting in better performance.
+ * Another minor benefit is that 0x0000 could be included in the allowed content in strings mapped by this class.
+ * 2. TODO: 0xFFFF currently has special meaning, marking the compressed branches.
+ * It would be good to eliminate this limitation, possibly by adding a boolean array to the data structures that
+ * marks whether the data in that node is compressed or not.
+ * 3. TODO: The zero-termination in CharVector is probably not needed, as the ending index can probably be stored in
+ * the hi branch of the compressed node, just as the starting index is stored in the lo branch.
+ * 4. TODO: I think the "root" index will always be 0 or 1.
+ * It is a bit misleading to store it as an instance variable, as it seems then to have more significance than
+ * that.
+ * Probably just checking for the existence of a node at index 1 would be sufficient (is freenode > 1).
+ * 5. TODO: We miss an opportunity by using the branch compression.
+ * The good news is that it saves nodes, but the bad news is that it saves nodes.
+ * It might be useful, in addition to returning mapped values, to return the node number that contains the
+ * mapped value.
+ * This would allow client applications to incrementally traverse the tree, and might provide more flexibility
+ * for doing things like wildcard searches.
+ * Instead of removing branch compression, perhaps it would be sufficient to simply indicate whether a given
+ * node index represents a compressed node.
+ */
/** Allocation size for arrays. */
private static final int BLOCK_SIZE = 2048;
@@ -81,38 +117,34 @@
/*
* We use four arrays of equal size to represent the nodes in this tree.
- * A given node /n/ is represented by the values in the arrays lo, hi, eq, and sc.
- * It is tempting to group these four arrays into a private inner class, and the original author
- * of this class left documentation kind of apologizing for not doing so.
- * However, experimentation shows that the extra object references created when doing so more
- * than doubles the size of the serialized instance, and therefore presumably does approximately
- * the same to memory consumption.
- * Since a light memory footprint is one of the main design considerations for this class, we
- * will use the original parallel arrays instead.
+ * A given node /n/ is represented by the values in the arrays lo, hi, eq, and keyChar.
+ * It is tempting to group these four arrays into a private inner class, and the original author of this class left
+ * documentation kind of apologizing for not doing so.
+ * However, experimentation shows that the extra object references created when doing so more than double the size
+ * of the serialized instance, and therefore presumably does approximately the same to memory consumption.
+ * Since a light memory footprint is one of the main design considerations for this class, we will use the original
+ * parallel arrays instead.
*/
/**
- * If {@link #keyChar} is a valid Unicode character, this array contains the index to the node
- * containing the "low" branch, that is the branch that should be traversed to find a char
- * that is less than {@link #keyChar}.
- * If {@link #keyChar} is equal to U+FFFF, the compressed branch indicator, then this array
- * instead contains the index into {@link #compressedKeys} that contains the first char in the
- * compressed portion of the key.
+ * If {@link #keyChar} is a valid Unicode character, this array contains the index to the node containing the "low"
+ * branch, that is the branch that should be traversed to find a char that is less than {@link #keyChar}.
+ * If {@link #keyChar} is equal to U+FFFF, the compressed branch indicator, then this array instead contains the
+ * index into {@link #compressedKeys} that contains the first char in the compressed portion of the key.
*/
private char[] lo;
/**
- * The index to the node containing the "hi" branch, that is the branch that should be traversed
- * to find a char that is greater than {@link #keyChar}.
+ * The index to the node containing the "hi" branch, that is the branch that should be traversed to find a char that
+ * is greater than {@link #keyChar}.
*/
private char[] hi;
/**
- * If {@link #keyChar} is a valid Unicode character, this array contains the index to the node
- * containing the "equal" branch, that is the branch that should be traversed to find a char
- * that is equal to {@link #keyChar}.
- * If {@link #keyChar} is equal to U+0000, the string terminator, then this array instead
- * contains value for this map element.
+ * If {@link #keyChar} is a valid Unicode character, this array contains the index to the node containing the
+ * "equal" branch, that is the branch that should be traversed to find a char that is equal to {@link #keyChar}.
+ * If {@link #keyChar} is equal to U+0000, the string terminator, then this array instead contains value for this
+ * map element.
*/
private char[] eq;
@@ -120,20 +152,19 @@
* <P>The character, which is part of the key, stored in this node.
* Two special values are reserved:</P>
* <ul>
- * <li>0x0000 is the string terminator. If the node contains this value, then the search is
- * done and the value in {@link #eq} should be returned.</li>
+ * <li>0x0000 is the string terminator. If the node contains this value, then the search is done and the value in
+ * {@link #eq} should be returned.</li>
* <li>0xFFFF to indicate that the branch starting at this node is compressed.
- * This shouldn't be a problem if we give the usual semantics to strings since 0xFFFF is
- * guaranteed not to be a valid Unicode character.</li>
+ * This shouldn't be a problem if we give the usual semantics to strings since 0xFFFF is guaranteed not to be a
+ * valid Unicode character.</li>
* </ul>
*/
private char[] keyChar;
/** This vector holds the compressed portion of a key when the branch is compressed.
- * It is simply a series of word fragments, each followed by a
- * {@link StringUtil#NULL_TERMINATOR}.
- * The index to the start of the compressed portion of the key for a given node in the tree is
- * found in the {@link #lo} value for the node. */
+ * It is simply a series of word fragments, each followed by a {@link StringUtil#NULL_TERMINATOR}.
+ * The index to the start of the compressed portion of the key for a given node in the tree is found in the
+ * {@link #lo} value for the node. */
private CharVector compressedKeys;
/** The index of the root of the current branch?? */
@@ -143,9 +174,8 @@
private char freenode;
/** The number of key-value pairs mapped in the tree.
- * This is not necessarily the same as the number of nodes in the tree, because of branch
- * compression, and because it frequently takes more than one node to store the chars in a
- * key. */
+ * This is not necessarily the same as the number of nodes in the tree, because of branch compression, and because
+ * it frequently takes more than one node to store the chars in a key. */
private int length;
/**
@@ -257,7 +287,7 @@
}
if (this.keyChar[currentNodeIndex] == Character.MAX_VALUE) {
- uncompressNode(currentNodeIndex, len);
+ uncompressNode(currentNodeIndex);
}
if (len == 0) {
@@ -330,30 +360,29 @@
/**
* Uncompresses a node by creating a new one, moving all but the first character from it into the new node, and
* keeping the existing node pointing to the first character in the previously-compressed node.
- * @param currentNodeIndex Junk.
- * @param len Junk.
+ * @param nodeIndex The index to the node that should be uncompressed.
*/
- private void uncompressNode(final char currentNodeIndex, final int len) {
- if (this.keyChar[currentNodeIndex] != Character.MAX_VALUE) {
+ private void uncompressNode(final char nodeIndex) {
+ if (this.keyChar[nodeIndex] != Character.MAX_VALUE) {
throw new IllegalStateException("Trying to uncompress a node that is not compressed.");
}
/* Set the key character for the current node to be the first character in the previously-compressed data. */
- this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[currentNodeIndex]);
+ this.keyChar[nodeIndex] = this.compressedKeys.get(this.lo[nodeIndex]);
/* Create and initialize the new node. */
final char newNodeIndex = this.freenode++;
- this.lo[newNodeIndex] = this.lo[currentNodeIndex];
- this.eq[newNodeIndex] = this.eq[currentNodeIndex];
- this.hi[newNodeIndex] = this.hi[currentNodeIndex];
+ this.lo[newNodeIndex] = this.lo[nodeIndex];
+ this.eq[newNodeIndex] = this.eq[nodeIndex];
+ this.hi[newNodeIndex] = this.hi[nodeIndex];
this.keyChar[newNodeIndex] = Character.MAX_VALUE;
/* The low branch of the current node used to point to the compressed branch, but no longer should. Clear that
* value. */
- this.lo[currentNodeIndex] = 0;
+ this.lo[nodeIndex] = 0;
/* Point the equal branch of the current node to the new node. */
- this.eq[currentNodeIndex] = newNodeIndex;
- this.hi[currentNodeIndex] = 0;
+ this.eq[nodeIndex] = newNodeIndex;
+ this.hi[nodeIndex] = 0;
/* We just moved the first character in the compressed branch to this node. We now need to remove it
* from the compressed branch by incrementing that branch's starting point. */
@@ -499,8 +528,7 @@
/**
* Returns the number of key-value pairs in this map.
- * This can be different from the number of nodes in the tree because of the compressed
- * branches.
+ * This can be different from the number of nodes in the tree because of the compressed branches.
* @return The number of key-value pairs in this map.
*/
public int size() {
@@ -533,16 +561,13 @@
}
/**
- * Recursively insert the median first and then the median of the
- * lower and upper halves, and so on in order to get a balanced
- * tree. The array of keys is assumed to be sorted in ascending
- * order.
+ * Recursively insert the median first and then the median of the lower and upper halves, and so on in order to get
+ * a balanced tree.
+ * The array of keys is assumed to be sorted in ascending order.
* @param keys The array of keys to be processed.
* @param values The array of values to be processed.
- * @param offset The offset from the computed median at which the item
- * should be inserted.
- * @param upperBound The highest index which should be used in the new
- * median computation.
+ * @param offset The offset from the computed median at which the item should be inserted.
+ * @param upperBound The highest index which should be used in the new median computation.
*/
private void insertBalanced(final String[] keys, final char[] values,
final int offset, final int upperBound) {
@@ -583,21 +608,17 @@
}
/**
- * Allows the map to internally optimize itself for faster performance and possible memory
- * reduction.
+ * Allows the map to internally optimize itself for faster performance and possible memory reduction.
* This method should be run only once, immediately after the tree is completely built.
*/
public void optimize() {
- /* Each node stores a character which is part of
- * some key(s). In a compressed branch (one that only contain
- * a single string key) the trailer of the key which is not
+ /* Each node stores a character which is part of some key(s).
+ * In a compressed branch (one that only contain a single string key) the trailer of the key which is not
* already in nodes is stored externally in the kv array.
* As items are inserted, key substrings decrease.
- * Some substrings may completely disappear when the whole
- * branch is totally decompressed.
- * The tree is traversed to find the key substrings actually
- * used. In addition, duplicate substrings are removed using
- * a map (implemented with a TernaryTree!).
+ * Some substrings may completely disappear when the whole branch is totally decompressed.
+ * The tree is traversed to find the key substrings actually used.
+ * In addition, duplicate substrings are removed using a map (implemented with a TernaryTree!).
*/
/* First balance the tree for best performance. */
@@ -606,7 +627,7 @@
/* Redimension the node arrays. */
redimNodeArrays(this.freenode);
- // ok, compact kv array
+ /* Compact the compressedKeys. */
final CharVector kx = new CharVector();
final TernaryTreeMap map = new TernaryTreeMap();
compact(kx, map, this.root);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-18 15:38:32
|
Revision: 10713
http://foray.svn.sourceforge.net/foray/?rev=10713&view=rev
Author: victormote
Date: 2009-03-18 15:37:34 +0000 (Wed, 18 Mar 2009)
Log Message:
-----------
Refresh the hyphenation patterns.
Modified Paths:
--------------
trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
Modified: trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-18 15:25:15
|
Revision: 10712
http://foray.svn.sourceforge.net/foray/?rev=10712&view=rev
Author: victormote
Date: 2009-03-18 15:24:49 +0000 (Wed, 18 Mar 2009)
Log Message:
-----------
Get all of the tests working. For nodes that were not previously zero-terminated, and which now needed to contain data, we now properly add a zero-terminated node into the tree.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 21:25:51 UTC (rev 10711)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-18 15:24:49 UTC (rev 10712)
@@ -33,7 +33,6 @@
package org.foray.common;
-
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Stack;
@@ -262,10 +261,26 @@
}
if (len == 0) {
- /* Make the current node the zero-termination node and store the value in it. */
- this.keyChar[currentNodeIndex] = 0;
- this.eq[currentNodeIndex] = value;
- return currentNodeIndex;
+ if (this.keyChar[currentNodeIndex] == 0) {
+ /* This node is a zero-terminated node. This means that the key has already been mapped, and that we
+ * are overwriting it here. */
+ this.eq[currentNodeIndex] = value;
+ return currentNodeIndex;
+ } else {
+ /* This node is not a zero-terminated node. We need to create one to hold the value. */
+ final char newNodeIndex = this.freenode ++;
+ /* In addition to adding a node, we are adding a mapped pair here. */
+ this.length++;
+ /* We are interposing the new node between the parent and the current node. */
+ /* Since the "character" stored in the new node is 0x00, everything in the current node will be a
+ * sister of it, and will be greater than it. Therefore we reference the current node from the hi
+ * branch of the new node. */
+ this.hi[newNodeIndex] = currentNodeIndex;
+ this.eq[newNodeIndex] = value;
+ this.lo[newNodeIndex] = 0;
+ this.keyChar[newNodeIndex] = 0;
+ return newNodeIndex;
+ }
}
final char searchCharacter = key.charAt(start);
@@ -340,21 +355,15 @@
this.eq[currentNodeIndex] = newNodeIndex;
this.hi[currentNodeIndex] = 0;
- if (len > 0) {
- /* We just moved the first character in the compressed branch to this node. We now need to remove it
- * from the compressed branch by incrementing that branch's starting point. */
- this.lo[newNodeIndex]++;
- if (this.compressedKeys.get(this.lo[newNodeIndex]) == 0) {
- /* We are at the end of the compressed node. Mark the new node to indicate that it is NOT a
- * compressed node. */
- this.lo[newNodeIndex] = 0;
- this.keyChar[newNodeIndex] = 0;
- this.hi[newNodeIndex] = 0;
- }
- } else {
- /* Length is zero, so we are at the end of the String being added. */
- this.hi[currentNodeIndex] = newNodeIndex;
- this.length++;
+ /* We just moved the first character in the compressed branch to this node. We now need to remove it
+ * from the compressed branch by incrementing that branch's starting point. */
+ this.lo[newNodeIndex]++;
+ if (this.compressedKeys.get(this.lo[newNodeIndex]) == 0) {
+ /* We are at the end of the compressed node. Mark the new node to indicate that it is NOT a
+ * compressed node. */
+ this.lo[newNodeIndex] = 0;
+ this.keyChar[newNodeIndex] = 0;
+ this.hi[newNodeIndex] = 0;
}
}
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-17 21:25:51 UTC (rev 10711)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-18 15:24:49 UTC (rev 10712)
@@ -28,7 +28,6 @@
package org.foray.common;
-import org.junit.Ignore;
import org.junit.Test;
import junit.framework.TestCase;
@@ -153,7 +152,7 @@
TestCase.assertEquals(4, map.size());
/* TODO: We don't fully understand the node count here. */
- TestCase.assertEquals(10, map.getNodeCount());
+ TestCase.assertEquals(11, map.getNodeCount());
}
/**
@@ -175,10 +174,10 @@
}
/**
- * A test culled from a real-world failure.
+ * A test culled from a real-world failure. Add a compressed node. Add another node that should decompress the
+ * first one. Then add a node at the decompression point.
*/
@Test
- @Ignore
public void testPut01() {
final TernaryTreeMap map = new TernaryTreeMap();
map.put("40", '1');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 21:26:00
|
Revision: 10711
http://foray.svn.sourceforge.net/foray/?rev=10711&view=rev
Author: victormote
Date: 2009-03-17 21:25:51 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Add suppression for MagicNumber testing, to be used in tests.
Modified Paths:
--------------
trunk/foray/scripts/checkstyle-config.xml
Modified: trunk/foray/scripts/checkstyle-config.xml
===================================================================
--- trunk/foray/scripts/checkstyle-config.xml 2009-03-17 18:31:06 UTC (rev 10710)
+++ trunk/foray/scripts/checkstyle-config.xml 2009-03-17 21:25:51 UTC (rev 10711)
@@ -32,6 +32,15 @@
<property name="checkFormat" value="GenericIllegalRegexp"/>
</module>
+ <!-- Allow test methods to use magic numbers. -->
+ <!-- TODO: Write a custom checkstyle plugin that does the suppression in tests automatically.
+ -->
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="Checkstyle-MagicNumber-Off"/>
+ <property name="onCommentFormat" value="Checkstyle-MagicNumber-On"/>
+ <property name="checkFormat" value="MagicNumber"/>
+ </module>
+
<module name="TreeWalker">
<!-- Activate FileContentsHolder so that comments are visible to Checkstyle
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 18:31:15
|
Revision: 10710
http://foray.svn.sourceforge.net/foray/?rev=10710&view=rev
Author: victormote
Date: 2009-03-17 18:31:06 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Explicitly set some of the array values.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 18:14:06 UTC (rev 10709)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 18:31:06 UTC (rev 10710)
@@ -322,19 +322,23 @@
if (this.keyChar[currentNodeIndex] != Character.MAX_VALUE) {
throw new IllegalStateException("Trying to uncompress a node that is not compressed.");
}
- /* Create a new node. */
+
+ /* Set the key character for the current node to be the first character in the previously-compressed data. */
+ this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[currentNodeIndex]);
+
+ /* Create and initialize the new node. */
final char newNodeIndex = this.freenode++;
- /* Initialize the new node. */
this.lo[newNodeIndex] = this.lo[currentNodeIndex];
this.eq[newNodeIndex] = this.eq[currentNodeIndex];
+ this.hi[newNodeIndex] = this.hi[currentNodeIndex];
this.keyChar[newNodeIndex] = Character.MAX_VALUE;
+ /* The low branch of the current node used to point to the compressed branch, but no longer should. Clear that
+ * value. */
this.lo[currentNodeIndex] = 0;
- /* Recompress what is left of the compressed node. */
- /* Set the key character for this node to be the first character in the previously-compressed data. */
- this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[newNodeIndex]);
/* Point the equal branch of the current node to the new node. */
this.eq[currentNodeIndex] = newNodeIndex;
+ this.hi[currentNodeIndex] = 0;
if (len > 0) {
/* We just moved the first character in the compressed branch to this node. We now need to remove it
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 18:14:14
|
Revision: 10709
http://foray.svn.sourceforge.net/foray/?rev=10709&view=rev
Author: victormote
Date: 2009-03-17 18:14:06 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Throw an exception if the node is not compressed.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:50:54 UTC (rev 10708)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 18:14:06 UTC (rev 10709)
@@ -319,7 +319,9 @@
* @param len Junk.
*/
private void uncompressNode(final char currentNodeIndex, final int len) {
- /* This node is compressed. */
+ if (this.keyChar[currentNodeIndex] != Character.MAX_VALUE) {
+ throw new IllegalStateException("Trying to uncompress a node that is not compressed.");
+ }
/* Create a new node. */
final char newNodeIndex = this.freenode++;
/* Initialize the new node. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 17:51:04
|
Revision: 10708
http://foray.svn.sourceforge.net/foray/?rev=10708&view=rev
Author: victormote
Date: 2009-03-17 17:50:54 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Get more of the code into the common section.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:43:11 UTC (rev 10707)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:50:54 UTC (rev 10708)
@@ -322,17 +322,19 @@
/* This node is compressed. */
/* Create a new node. */
final char newNodeIndex = this.freenode++;
- /* Copy the data from the current node to the new node. */
+ /* Initialize the new node. */
this.lo[newNodeIndex] = this.lo[currentNodeIndex];
this.eq[newNodeIndex] = this.eq[currentNodeIndex];
+ this.keyChar[newNodeIndex] = Character.MAX_VALUE;
+
this.lo[currentNodeIndex] = 0;
- this.keyChar[newNodeIndex] = Character.MAX_VALUE;
+ /* Recompress what is left of the compressed node. */
+ /* Set the key character for this node to be the first character in the previously-compressed data. */
+ this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[newNodeIndex]);
+ /* Point the equal branch of the current node to the new node. */
+ this.eq[currentNodeIndex] = newNodeIndex;
+
if (len > 0) {
- /* Recompress what is left of the compressed node. */
- /* Set the key character for this node to be the first character in the previously-compressed data. */
- this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[newNodeIndex]);
- /* Point the equal branch of the current node to the new node. */
- this.eq[currentNodeIndex] = newNodeIndex;
/* We just moved the first character in the compressed branch to this node. We now need to remove it
* from the compressed branch by incrementing that branch's starting point. */
this.lo[newNodeIndex]++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 17:43:22
|
Revision: 10707
http://foray.svn.sourceforge.net/foray/?rev=10707&view=rev
Author: victormote
Date: 2009-03-17 17:43:11 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Simplify logic and make it less dependent on the len parameter.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:39:50 UTC (rev 10706)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:43:11 UTC (rev 10707)
@@ -326,6 +326,7 @@
this.lo[newNodeIndex] = this.lo[currentNodeIndex];
this.eq[newNodeIndex] = this.eq[currentNodeIndex];
this.lo[currentNodeIndex] = 0;
+ this.keyChar[newNodeIndex] = Character.MAX_VALUE;
if (len > 0) {
/* Recompress what is left of the compressed node. */
/* Set the key character for this node to be the first character in the previously-compressed data. */
@@ -341,13 +342,9 @@
this.lo[newNodeIndex] = 0;
this.keyChar[newNodeIndex] = 0;
this.hi[newNodeIndex] = 0;
- } else {
- /* The compressed node is not empty. Mark the new node to indicate that it IS a compressed node. */
- this.keyChar[newNodeIndex] = Character.MAX_VALUE;
}
} else {
/* Length is zero, so we are at the end of the String being added. */
- this.keyChar[newNodeIndex] = Character.MAX_VALUE;
this.hi[currentNodeIndex] = newNodeIndex;
this.length++;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 17:39:53
|
Revision: 10706
http://foray.svn.sourceforge.net/foray/?rev=10706&view=rev
Author: victormote
Date: 2009-03-17 17:39:50 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Remove extraneous statement.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:13:34 UTC (rev 10705)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:39:50 UTC (rev 10706)
@@ -349,7 +349,6 @@
/* Length is zero, so we are at the end of the String being added. */
this.keyChar[newNodeIndex] = Character.MAX_VALUE;
this.hi[currentNodeIndex] = newNodeIndex;
- this.keyChar[currentNodeIndex] = 0;
this.length++;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 17:13:44
|
Revision: 10705
http://foray.svn.sourceforge.net/foray/?rev=10705&view=rev
Author: victormote
Date: 2009-03-17 17:13:34 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Store the value using the standard (downstream) logic.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:06:30 UTC (rev 10704)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:13:34 UTC (rev 10705)
@@ -258,11 +258,9 @@
}
if (this.keyChar[currentNodeIndex] == Character.MAX_VALUE) {
- uncompressNode(value, currentNodeIndex, len);
- if (len == 0) {
- return currentNodeIndex;
- }
+ uncompressNode(currentNodeIndex, len);
}
+
if (len == 0) {
/* Make the current node the zero-termination node and store the value in it. */
this.keyChar[currentNodeIndex] = 0;
@@ -317,11 +315,10 @@
/**
* Uncompresses a node by creating a new one, moving all but the first character from it into the new node, and
* keeping the existing node pointing to the first character in the previously-compressed node.
- * @param value Junk.
* @param currentNodeIndex Junk.
* @param len Junk.
*/
- private void uncompressNode(final char value, final char currentNodeIndex, final int len) {
+ private void uncompressNode(final char currentNodeIndex, final int len) {
/* This node is compressed. */
/* Create a new node. */
final char newNodeIndex = this.freenode++;
@@ -353,7 +350,6 @@
this.keyChar[newNodeIndex] = Character.MAX_VALUE;
this.hi[currentNodeIndex] = newNodeIndex;
this.keyChar[currentNodeIndex] = 0;
- this.eq[currentNodeIndex] = value;
this.length++;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 17:06:47
|
Revision: 10704
http://foray.svn.sourceforge.net/foray/?rev=10704&view=rev
Author: victormote
Date: 2009-03-17 17:06:30 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Extract method that uncompresses a compressed node.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 16:55:26 UTC (rev 10703)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 17:06:30 UTC (rev 10704)
@@ -258,39 +258,8 @@
}
if (this.keyChar[currentNodeIndex] == Character.MAX_VALUE) {
- /* This node is compressed. */
- /* Create a new node. */
- final char newNodeIndex = this.freenode++;
- /* Copy the data from the current node to the new node. */
- this.lo[newNodeIndex] = this.lo[currentNodeIndex];
- this.eq[newNodeIndex] = this.eq[currentNodeIndex];
- this.lo[currentNodeIndex] = 0;
- if (len > 0) {
- /* Recompress what is left of the compressed node. */
- /* Set the key character for this node to be the first character in the previously-compressed data. */
- this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[newNodeIndex]);
- /* Point the equal branch of the current node to the new node. */
- this.eq[currentNodeIndex] = newNodeIndex;
- /* We just moved the first character in the compressed branch to this node. We now need to remove it
- * from the compressed branch by incrementing that branch's starting point. */
- this.lo[newNodeIndex]++;
- if (this.compressedKeys.get(this.lo[newNodeIndex]) == 0) {
- /* We are at the end of the compressed node. Mark the new node to indicate that it is NOT a
- * compressed node. */
- this.lo[newNodeIndex] = 0;
- this.keyChar[newNodeIndex] = 0;
- this.hi[newNodeIndex] = 0;
- } else {
- /* The compressed node is not empty. Mark the new node to indicate that it IS a compressed node. */
- this.keyChar[newNodeIndex] = Character.MAX_VALUE;
- }
- } else {
- /* Length is zero, so we are at the end of the String being added. */
- this.keyChar[newNodeIndex] = Character.MAX_VALUE;
- this.hi[currentNodeIndex] = newNodeIndex;
- this.keyChar[currentNodeIndex] = 0;
- this.eq[currentNodeIndex] = value;
- this.length++;
+ uncompressNode(value, currentNodeIndex, len);
+ if (len == 0) {
return currentNodeIndex;
}
}
@@ -346,6 +315,50 @@
}
/**
+ * Uncompresses a node by creating a new one, moving all but the first character from it into the new node, and
+ * keeping the existing node pointing to the first character in the previously-compressed node.
+ * @param value Junk.
+ * @param currentNodeIndex Junk.
+ * @param len Junk.
+ */
+ private void uncompressNode(final char value, final char currentNodeIndex, final int len) {
+ /* This node is compressed. */
+ /* Create a new node. */
+ final char newNodeIndex = this.freenode++;
+ /* Copy the data from the current node to the new node. */
+ this.lo[newNodeIndex] = this.lo[currentNodeIndex];
+ this.eq[newNodeIndex] = this.eq[currentNodeIndex];
+ this.lo[currentNodeIndex] = 0;
+ if (len > 0) {
+ /* Recompress what is left of the compressed node. */
+ /* Set the key character for this node to be the first character in the previously-compressed data. */
+ this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[newNodeIndex]);
+ /* Point the equal branch of the current node to the new node. */
+ this.eq[currentNodeIndex] = newNodeIndex;
+ /* We just moved the first character in the compressed branch to this node. We now need to remove it
+ * from the compressed branch by incrementing that branch's starting point. */
+ this.lo[newNodeIndex]++;
+ if (this.compressedKeys.get(this.lo[newNodeIndex]) == 0) {
+ /* We are at the end of the compressed node. Mark the new node to indicate that it is NOT a
+ * compressed node. */
+ this.lo[newNodeIndex] = 0;
+ this.keyChar[newNodeIndex] = 0;
+ this.hi[newNodeIndex] = 0;
+ } else {
+ /* The compressed node is not empty. Mark the new node to indicate that it IS a compressed node. */
+ this.keyChar[newNodeIndex] = Character.MAX_VALUE;
+ }
+ } else {
+ /* Length is zero, so we are at the end of the String being added. */
+ this.keyChar[newNodeIndex] = Character.MAX_VALUE;
+ this.hi[currentNodeIndex] = newNodeIndex;
+ this.keyChar[currentNodeIndex] = 0;
+ this.eq[currentNodeIndex] = value;
+ this.length++;
+ }
+ }
+
+ /**
* Returns the mapped "value" for a given char array.
* @param key The key whose value is needed.
* @return The mapped value.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 16:55:40
|
Revision: 10703
http://foray.svn.sourceforge.net/foray/?rev=10703&view=rev
Author: victormote
Date: 2009-03-17 16:55:26 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Extract a method for clarity.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 16:07:54 UTC (rev 10702)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 16:55:26 UTC (rev 10703)
@@ -253,27 +253,7 @@
char currentNodeIndex = startingNodeIndex;
final int len = end - start;
if (currentNodeIndex == 0) {
- // this means there is no branch, this node will start a new branch.
- // Instead of doing that, we store the key somewhere else and create
- // only one node with a pointer to the key
- currentNodeIndex = this.freenode++;
- /* Holds data. */
- this.eq[currentNodeIndex] = value;
- this.length++;
- this.hi[currentNodeIndex] = 0;
- if (len > 0) {
- /* Mark the branch as compressed */
- this.keyChar[currentNodeIndex] = Character.MAX_VALUE;
- /* Store the compressed data in the vector for that purpose. */
- final int startOfCompressedData = this.compressedKeys.add(key, start, len);
- /* Store the index to the compressed data in the "lo" value. */
- this.lo[currentNodeIndex] = (char) startOfCompressedData;
- /* Zero-terminate the compressed data. */
- this.compressedKeys.add(StringUtil.NULL_TERMINATOR);
- } else {
- this.keyChar[currentNodeIndex] = 0;
- this.lo[currentNodeIndex] = 0;
- }
+ currentNodeIndex = createBranch(key, start, end, value);
return currentNodeIndex;
}
@@ -335,6 +315,37 @@
}
/**
+ * Create a branch for the current word.
+ * @param key The key to be added.
+ * @param start The index to the first char in <code>key</code> to be added.
+ * @param end The index to the first char in <code>key</code>, after <code>start</code> that should NOT be added.
+ * @param value The value.
+ * @return The index to the newly-created node.
+ */
+ private char createBranch(final CharSequence key, final int start, final int end, final char value) {
+ final char currentNodeIndex = this.freenode++;
+ final int len = end - start;
+ /* Holds data. */
+ this.eq[currentNodeIndex] = value;
+ this.length++;
+ this.hi[currentNodeIndex] = 0;
+ if (len > 0) {
+ /* Mark the branch as compressed */
+ this.keyChar[currentNodeIndex] = Character.MAX_VALUE;
+ /* Store the compressed data in the vector for that purpose. */
+ final int startOfCompressedData = this.compressedKeys.add(key, start, len);
+ /* Store the index to the compressed data in the "lo" value. */
+ this.lo[currentNodeIndex] = (char) startOfCompressedData;
+ /* Zero-terminate the compressed data. */
+ this.compressedKeys.add(StringUtil.NULL_TERMINATOR);
+ } else {
+ this.keyChar[currentNodeIndex] = 0;
+ this.lo[currentNodeIndex] = 0;
+ }
+ return currentNodeIndex;
+ }
+
+ /**
* Returns the mapped "value" for a given char array.
* @param key The key whose value is needed.
* @return The mapped value.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 16:07:55
|
Revision: 10702
http://foray.svn.sourceforge.net/foray/?rev=10702&view=rev
Author: victormote
Date: 2009-03-17 16:07:54 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Rename some local variables for clarity.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 16:01:41 UTC (rev 10701)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 16:07:54 UTC (rev 10702)
@@ -321,13 +321,14 @@
return currentNodeIndex;
}
- final char s = key.charAt(start);
- if (s < this.keyChar[currentNodeIndex]) {
+ final char searchCharacter = key.charAt(start);
+ final char keyCharacter = this.keyChar[currentNodeIndex];
+ if (searchCharacter < keyCharacter) {
this.lo[currentNodeIndex] = put(this.lo[currentNodeIndex], key, start, end, value);
- } else if (s == this.keyChar[currentNodeIndex]) {
+ } else if (searchCharacter == keyCharacter) {
this.eq[currentNodeIndex] = put(this.eq[currentNodeIndex], key, start + 1, end, value);
} else {
- /* s is > the key character. */
+ assert searchCharacter > keyCharacter : "searchCharacter must be > keyCharacter.";
this.hi[currentNodeIndex] = put(this.hi[currentNodeIndex], key, start, end, value);
}
return currentNodeIndex;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 16:01:48
|
Revision: 10701
http://foray.svn.sourceforge.net/foray/?rev=10701&view=rev
Author: victormote
Date: 2009-03-17 16:01:41 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Since we now handle the length = 0 case above, simplify the branching logic.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 15:57:28 UTC (rev 10700)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 16:01:41 UTC (rev 10701)
@@ -325,14 +325,9 @@
if (s < this.keyChar[currentNodeIndex]) {
this.lo[currentNodeIndex] = put(this.lo[currentNodeIndex], key, start, end, value);
} else if (s == this.keyChar[currentNodeIndex]) {
- if (len > 0) {
- this.eq[currentNodeIndex] = put(this.eq[currentNodeIndex], key, start + 1, end, value);
- } else {
- /* Key is already in the tree -- overwrite the value. */
- this.eq[currentNodeIndex] = value;
- }
-
+ this.eq[currentNodeIndex] = put(this.eq[currentNodeIndex], key, start + 1, end, value);
} else {
+ /* s is > the key character. */
this.hi[currentNodeIndex] = put(this.hi[currentNodeIndex], key, start, end, value);
}
return currentNodeIndex;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 15:57:37
|
Revision: 10700
http://foray.svn.sourceforge.net/foray/?rev=10700&view=rev
Author: victormote
Date: 2009-03-17 15:57:28 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Fix the zero-termination logic a bit.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 14:40:49 UTC (rev 10699)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 15:57:28 UTC (rev 10700)
@@ -314,6 +314,13 @@
return currentNodeIndex;
}
}
+ if (len == 0) {
+ /* Make the current node the zero-termination node and store the value in it. */
+ this.keyChar[currentNodeIndex] = 0;
+ this.eq[currentNodeIndex] = value;
+ return currentNodeIndex;
+ }
+
final char s = key.charAt(start);
if (s < this.keyChar[currentNodeIndex]) {
this.lo[currentNodeIndex] = put(this.lo[currentNodeIndex], key, start, end, value);
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-17 14:40:49 UTC (rev 10699)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-17 15:57:28 UTC (rev 10700)
@@ -184,6 +184,10 @@
map.put("40", '1');
map.put("45", '2');
map.put("4", '3');
+
+ TestCase.assertEquals('1', (char) map.get("40"));
+ TestCase.assertEquals('2', (char) map.get("45"));
+ TestCase.assertEquals('3', (char) map.get("4"));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-17 14:41:14
|
Revision: 10699
http://foray.svn.sourceforge.net/foray/?rev=10699&view=rev
Author: victormote
Date: 2009-03-17 14:40:49 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
Rename some local variables.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-16 21:19:49 UTC (rev 10698)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-17 14:40:49 UTC (rev 10699)
@@ -392,15 +392,14 @@
* @return The mapped value, if <code>key</code> is in the map. Otherwise, returns -1;
*/
public int get(final CharSequence key, final int start, final int end) {
- int d;
- char p = this.root;
+ char currentNodeIndex = this.root;
int i = start;
char c;
- while (p != 0) {
- if (this.keyChar[p] == Character.MAX_VALUE) {
- if (this.compressedKeys.compareNullTerminated(this.lo[p], key, i, end) == 0) {
- return this.eq[p];
+ while (currentNodeIndex != 0) {
+ if (this.keyChar[currentNodeIndex] == Character.MAX_VALUE) {
+ if (this.compressedKeys.compareNullTerminated(this.lo[currentNodeIndex], key, i, end) == 0) {
+ return this.eq[currentNodeIndex];
}
return -1;
}
@@ -411,17 +410,17 @@
} else {
c = key.charAt(i);
}
- d = c - this.keyChar[p];
- if (d == 0) {
+ final int difference = c - this.keyChar[currentNodeIndex];
+ if (difference == 0) {
if (c == 0) {
- return this.eq[p];
+ return this.eq[currentNodeIndex];
}
i++;
- p = this.eq[p];
- } else if (d < 0) {
- p = this.lo[p];
+ currentNodeIndex = this.eq[currentNodeIndex];
+ } else if (difference < 0) {
+ currentNodeIndex = this.lo[currentNodeIndex];
} else {
- p = this.hi[p];
+ currentNodeIndex = this.hi[currentNodeIndex];
}
}
return -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-16 21:20:06
|
Revision: 10698
http://foray.svn.sourceforge.net/foray/?rev=10698&view=rev
Author: victormote
Date: 2009-03-16 21:19:49 +0000 (Mon, 16 Mar 2009)
Log Message:
-----------
Add some comments.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-16 18:42:56 UTC (rev 10697)
+++ trunk/foray/foray-common/src/java/org/foray/common/TernaryTreeMap.java 2009-03-16 21:19:49 UTC (rev 10698)
@@ -278,22 +278,34 @@
}
if (this.keyChar[currentNodeIndex] == Character.MAX_VALUE) {
+ /* This node is compressed. */
+ /* Create a new node. */
final char newNodeIndex = this.freenode++;
+ /* Copy the data from the current node to the new node. */
this.lo[newNodeIndex] = this.lo[currentNodeIndex];
this.eq[newNodeIndex] = this.eq[currentNodeIndex];
this.lo[currentNodeIndex] = 0;
if (len > 0) {
+ /* Recompress what is left of the compressed node. */
+ /* Set the key character for this node to be the first character in the previously-compressed data. */
this.keyChar[currentNodeIndex] = this.compressedKeys.get(this.lo[newNodeIndex]);
+ /* Point the equal branch of the current node to the new node. */
this.eq[currentNodeIndex] = newNodeIndex;
+ /* We just moved the first character in the compressed branch to this node. We now need to remove it
+ * from the compressed branch by incrementing that branch's starting point. */
this.lo[newNodeIndex]++;
if (this.compressedKeys.get(this.lo[newNodeIndex]) == 0) {
+ /* We are at the end of the compressed node. Mark the new node to indicate that it is NOT a
+ * compressed node. */
this.lo[newNodeIndex] = 0;
this.keyChar[newNodeIndex] = 0;
this.hi[newNodeIndex] = 0;
} else {
+ /* The compressed node is not empty. Mark the new node to indicate that it IS a compressed node. */
this.keyChar[newNodeIndex] = Character.MAX_VALUE;
}
} else {
+ /* Length is zero, so we are at the end of the String being added. */
this.keyChar[newNodeIndex] = Character.MAX_VALUE;
this.hi[currentNodeIndex] = newNodeIndex;
this.keyChar[currentNodeIndex] = 0;
@@ -309,7 +321,7 @@
if (len > 0) {
this.eq[currentNodeIndex] = put(this.eq[currentNodeIndex], key, start + 1, end, value);
} else {
- // key already in tree, overwrite data
+ /* Key is already in the tree -- overwrite the value. */
this.eq[currentNodeIndex] = value;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-16 18:43:19
|
Revision: 10697
http://foray.svn.sourceforge.net/foray/?rev=10697&view=rev
Author: victormote
Date: 2009-03-16 18:42:56 +0000 (Mon, 16 Mar 2009)
Log Message:
-----------
1. Partial conversion to JUnit 4 annotation-based syntax.
2. Add @Ignore annotation to TernaryTestMap test that is currently failing.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2009-03-16 18:08:49 UTC (rev 10696)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2009-03-16 18:42:56 UTC (rev 10697)
@@ -37,32 +37,26 @@
import org.foray.ps.TestFOrayPS;
import org.foray.render.TestFOrayRender;
-import junit.framework.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
import junit.framework.TestSuite;
/**
* Master Test harness for all FOray modules.
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TestFOrayCommon.class,
+ TestFOrayPS.class,
+ TestFOrayFont.class,
+ TestFOrayGraphic.class,
+ TestFOrayHyphen.class,
+ TestFOrayFOTree.class,
+ TestFOrayAreaTree.class,
+ TestFOrayRender.class,
+ TestFOrayApp.class,
+})
public class TestFOrayAll extends TestSuite {
- /**
- * Builds a test suite for modules in FOray.
- * @return The built test suite.
- */
- public static Test suite() {
- final TestSuite testSuite = new TestSuite("All FOray Tests");
-
- testSuite.addTest(TestFOrayCommon.suite());
- testSuite.addTest(TestFOrayPS.suite());
- testSuite.addTest(TestFOrayFont.suite());
- testSuite.addTest(TestFOrayGraphic.suite());
- testSuite.addTest(TestFOrayHyphen.suite());
- testSuite.addTest(TestFOrayFOTree.suite());
- testSuite.addTest(TestFOrayAreaTree.suite());
- testSuite.addTest(TestFOrayRender.suite());
- testSuite.addTest(TestFOrayApp.suite());
-
- return testSuite;
- }
-
}
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2009-03-16 18:08:49 UTC (rev 10696)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestFOrayCommon.java 2009-03-16 18:42:56 UTC (rev 10697)
@@ -28,17 +28,27 @@
package org.foray.common;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
import java.io.File;
import java.io.IOException;
import java.util.Properties;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
/**
* Handles testing for the FOrayCommon module.
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TestBit.class,
+ TestByteVectorPacked.class,
+ TestCharVector.class,
+ TestStringUtil.class,
+ TestTernaryTreeMap.class,
+ TestUnicodeChar.class,
+})
public class TestFOrayCommon extends TestCase {
/**
@@ -64,21 +74,4 @@
return new File(sandbox, "/resource/test/");
}
- /**
- * Builds a test suite for all classes in this module.
- * @return The built test suite.
- */
- public static Test suite() {
- final TestSuite testSuite = new TestSuite("FOray Common");
-
- testSuite.addTestSuite(TestBit.class);
- testSuite.addTestSuite(TestByteVectorPacked.class);
- testSuite.addTestSuite(TestCharVector.class);
- testSuite.addTestSuite(TestStringUtil.class);
- testSuite.addTestSuite(TestTernaryTreeMap.class);
- testSuite.addTestSuite(TestUnicodeChar.class);
-
- return testSuite;
- }
-
}
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-16 18:08:49 UTC (rev 10696)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-16 18:42:56 UTC (rev 10697)
@@ -28,16 +28,20 @@
package org.foray.common;
+import org.junit.Ignore;
+import org.junit.Test;
+
import junit.framework.TestCase;
/**
* JUnit test class for the class {@link TernaryTreeMap}.
*/
-public class TestTernaryTreeMap extends TestCase {
+public class TestTernaryTreeMap {
/**
* Functional test which adds some key-value pairs to a TernaryTree, then queries the tree, testing the output.
*/
+ @Test
public void testOutput01() {
/* Check the CharSequence putters for whole words. */
TernaryTreeMap map = new TernaryTreeMap();
@@ -100,61 +104,62 @@
*/
private void checkGetters(final TernaryTreeMap map) {
/* Check the CharSequence getters for whole words. */
- assertEquals('C', (char) map.get("Carlos"));
- assertEquals('r', (char) map.get("Car"));
- assertEquals('l', (char) map.get("palos"));
- assertEquals('p', (char) map.get("pa"));
- assertEquals(-1, map.get("alto"));
- assertEquals(-1, map.get("C"));
+ TestCase.assertEquals('C', (char) map.get("Carlos"));
+ TestCase.assertEquals('r', (char) map.get("Car"));
+ TestCase.assertEquals('l', (char) map.get("palos"));
+ TestCase.assertEquals('p', (char) map.get("pa"));
+ TestCase.assertEquals(-1, map.get("alto"));
+ TestCase.assertEquals(-1, map.get("C"));
/* Check the CharSequence getters for words starting in the middle of a string. */
- assertEquals('C', (char) map.get("ABCCarlos", 3));
- assertEquals('r', (char) map.get("ABCCar", 3));
- assertEquals('l', (char) map.get("ABCpalos", 3));
- assertEquals('p', (char) map.get("ABCpa", 3));
- assertEquals(-1, map.get("ABCalto", 3));
- assertEquals(-1, map.get("ABCC", 3));
+ TestCase.assertEquals('C', (char) map.get("ABCCarlos", 3));
+ TestCase.assertEquals('r', (char) map.get("ABCCar", 3));
+ TestCase.assertEquals('l', (char) map.get("ABCpalos", 3));
+ TestCase.assertEquals('p', (char) map.get("ABCpa", 3));
+ TestCase.assertEquals(-1, map.get("ABCalto", 3));
+ TestCase.assertEquals(-1, map.get("ABCC", 3));
/* Check the CharSequence getters for words starting and ending in the middle of a string. */
- assertEquals('C', (char) map.get("ABCCarlosXYZ", 3, 9));
- assertEquals('r', (char) map.get("ABCCarXYZ", 3, 6));
- assertEquals('l', (char) map.get("ABCpalosXYZ", 3, 8));
- assertEquals('p', (char) map.get("ABCpaABCXYZ", 3, 5));
- assertEquals(-1, map.get("ABCaltoXYZ", 3, 7));
- assertEquals(-1, map.get("ABCCXYZ", 3, 4));
+ TestCase.assertEquals('C', (char) map.get("ABCCarlosXYZ", 3, 9));
+ TestCase.assertEquals('r', (char) map.get("ABCCarXYZ", 3, 6));
+ TestCase.assertEquals('l', (char) map.get("ABCpalosXYZ", 3, 8));
+ TestCase.assertEquals('p', (char) map.get("ABCpaABCXYZ", 3, 5));
+ TestCase.assertEquals(-1, map.get("ABCaltoXYZ", 3, 7));
+ TestCase.assertEquals(-1, map.get("ABCCXYZ", 3, 4));
/* Check the char[] getters for whole words. */
- assertEquals('C', (char) map.get("Carlos".toCharArray()));
- assertEquals('r', (char) map.get("Car".toCharArray()));
- assertEquals('l', (char) map.get("palos".toCharArray()));
- assertEquals('p', (char) map.get("pa".toCharArray()));
- assertEquals(-1, map.get("alto".toCharArray()));
- assertEquals(-1, map.get("C".toCharArray()));
+ TestCase.assertEquals('C', (char) map.get("Carlos".toCharArray()));
+ TestCase.assertEquals('r', (char) map.get("Car".toCharArray()));
+ TestCase.assertEquals('l', (char) map.get("palos".toCharArray()));
+ TestCase.assertEquals('p', (char) map.get("pa".toCharArray()));
+ TestCase.assertEquals(-1, map.get("alto".toCharArray()));
+ TestCase.assertEquals(-1, map.get("C".toCharArray()));
/* Check the char[] getters for words starting in the middle of a string. */
- assertEquals('C', (char) map.get("ABCCarlos".toCharArray(), 3));
- assertEquals('r', (char) map.get("ABCCar".toCharArray(), 3));
- assertEquals('l', (char) map.get("ABCpalos".toCharArray(), 3));
- assertEquals('p', (char) map.get("ABCpa".toCharArray(), 3));
- assertEquals(-1, map.get("ABCalto".toCharArray(), 3));
- assertEquals(-1, map.get("ABCC".toCharArray(), 3));
+ TestCase.assertEquals('C', (char) map.get("ABCCarlos".toCharArray(), 3));
+ TestCase.assertEquals('r', (char) map.get("ABCCar".toCharArray(), 3));
+ TestCase.assertEquals('l', (char) map.get("ABCpalos".toCharArray(), 3));
+ TestCase.assertEquals('p', (char) map.get("ABCpa".toCharArray(), 3));
+ TestCase.assertEquals(-1, map.get("ABCalto".toCharArray(), 3));
+ TestCase.assertEquals(-1, map.get("ABCC".toCharArray(), 3));
/* Check the char[] getters for words starting and ending in the middle of a string. */
- assertEquals('C', (char) map.get("ABCCarlosXYZ".toCharArray(), 3, 9));
- assertEquals('r', (char) map.get("ABCCarXYZ".toCharArray(), 3, 6));
- assertEquals('l', (char) map.get("ABCpalosXYZ".toCharArray(), 3, 8));
- assertEquals('p', (char) map.get("ABCpaABCXYZ".toCharArray(), 3, 5));
- assertEquals(-1, map.get("ABCaltoXYZ".toCharArray(), 3, 7));
- assertEquals(-1, map.get("ABCCXYZ".toCharArray(), 3, 4));
+ TestCase.assertEquals('C', (char) map.get("ABCCarlosXYZ".toCharArray(), 3, 9));
+ TestCase.assertEquals('r', (char) map.get("ABCCarXYZ".toCharArray(), 3, 6));
+ TestCase.assertEquals('l', (char) map.get("ABCpalosXYZ".toCharArray(), 3, 8));
+ TestCase.assertEquals('p', (char) map.get("ABCpaABCXYZ".toCharArray(), 3, 5));
+ TestCase.assertEquals(-1, map.get("ABCaltoXYZ".toCharArray(), 3, 7));
+ TestCase.assertEquals(-1, map.get("ABCCXYZ".toCharArray(), 3, 4));
- assertEquals(4, map.size());
+ TestCase.assertEquals(4, map.size());
/* TODO: We don't fully understand the node count here. */
- assertEquals(10, map.getNodeCount());
+ TestCase.assertEquals(10, map.getNodeCount());
}
/**
* Test the case where we put a compressed node in, then later put in a node that goes past that compressed node.
*/
+ @Test
public void testOutput02() {
/* Check the CharSequence putters for whole words. */
final TernaryTreeMap map = new TernaryTreeMap();
@@ -162,16 +167,18 @@
map.put("Carlos", 'C');
map.optimize();
- assertEquals('C', (char) map.get("Carlos"));
- assertEquals('r', (char) map.get("Car"));
- assertEquals(-1, map.get("alto"));
- assertEquals(-1, map.get("C"));
- assertEquals(2, map.size());
+ TestCase.assertEquals('C', (char) map.get("Carlos"));
+ TestCase.assertEquals('r', (char) map.get("Car"));
+ TestCase.assertEquals(-1, map.get("alto"));
+ TestCase.assertEquals(-1, map.get("C"));
+ TestCase.assertEquals(2, map.size());
}
/**
* A test culled from a real-world failure.
*/
+ @Test
+ @Ignore
public void testPut01() {
final TernaryTreeMap map = new TernaryTreeMap();
map.put("40", '1');
Modified: trunk/foray/lib/foray-hyphen-0.4-rsrc.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-16 18:08:56
|
Revision: 10696
http://foray.svn.sourceforge.net/foray/?rev=10696&view=rev
Author: victormote
Date: 2009-03-16 18:08:49 +0000 (Mon, 16 Mar 2009)
Log Message:
-----------
Further simplify the test.
Modified Paths:
--------------
trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-16 18:05:55 UTC (rev 10695)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-16 18:08:49 UTC (rev 10696)
@@ -174,9 +174,9 @@
*/
public void testPut01() {
final TernaryTreeMap map = new TernaryTreeMap();
- map.put("000400", '0');
- map.put("000450", '0');
- map.put("0004", '0');
+ map.put("40", '1');
+ map.put("45", '2');
+ map.put("4", '3');
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2009-03-16 18:06:00
|
Revision: 10695
http://foray.svn.sourceforge.net/foray/?rev=10695&view=rev
Author: victormote
Date: 2009-03-16 18:05:55 +0000 (Mon, 16 Mar 2009)
Log Message:
-----------
Add test for real-world case that currently fails.
Modified Paths:
--------------
trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
Modified: trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java
===================================================================
--- trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-16 17:38:13 UTC (rev 10694)
+++ trunk/foray/foray-common/src/javatest/org/foray/common/TestTernaryTreeMap.java 2009-03-16 18:05:55 UTC (rev 10695)
@@ -169,4 +169,14 @@
assertEquals(2, map.size());
}
+ /**
+ * A test culled from a real-world failure.
+ */
+ public void testPut01() {
+ final TernaryTreeMap map = new TernaryTreeMap();
+ map.put("000400", '0');
+ map.put("000450", '0');
+ map.put("0004", '0');
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|