]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Restored Java 1.4 compatibility (Boolean.parseBoolean() is a Java 5 method).
authorJeremias Maerki <jeremias@apache.org>
Fri, 25 Apr 2008 15:03:17 +0000 (15:03 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 25 Apr 2008 15:03:17 +0000 (15:03 +0000)
Simplified the ExternalLink's string representation to follow the pattern used by Trait.Background.
Added a check to test for the effect of the show-destination property.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@651623 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/area/Trait.java
test/layoutengine/standard-testcases/basic-link_external-destination.xml

index 9599d8833d25f67fe848a166e4f9a75c2b4c384f..e7b39ad2b19b290c2ba98a6eac787fdff91918da 100644 (file)
@@ -461,21 +461,20 @@ public class Trait implements Serializable {
          * @return an <code>ExternalLink</code> instance corresponding to the given value
          */
         protected static ExternalLink makeFromTraitValue(String traitValue) {
-            if (traitValue.indexOf(ExternalLink.class.getName()) == -1
-                    || traitValue.indexOf("dest=") == -1) {
-                throw new IllegalArgumentException(
-                        "Malformed trait value for Trait.ExternalLink: " + traitValue);
-            }
-            int startIndex = traitValue.indexOf("dest=") + 5;
-            int endIndex = traitValue.indexOf(',', startIndex);
-            if (endIndex == -1) {
-                endIndex = traitValue.indexOf(']');
+            String dest = null;
+            boolean newWindow = false;
+            String[] values = traitValue.split(",");
+            for (int i = 0, c = values.length; i < c; i++) {
+                String v = values[i];
+                if (v.startsWith("dest=")) {
+                    dest = v.substring(5);
+                } else if (v.startsWith("newWindow=")) {
+                    newWindow = Boolean.valueOf(v.substring(10)).booleanValue();
+                } else {
+                    throw new IllegalArgumentException(
+                            "Malformed trait value for Trait.ExternalLink: " + traitValue);
+                }
             }
-            String dest = traitValue.substring(startIndex, endIndex);
-            startIndex = traitValue.indexOf("newWindow=", endIndex) + 10;
-            endIndex = traitValue.indexOf(']', startIndex);
-            boolean newWindow = Boolean.parseBoolean(
-                    traitValue.substring(startIndex, endIndex));
             return new ExternalLink(dest, newWindow);
         }
 
@@ -502,9 +501,8 @@ public class Trait implements Serializable {
          */
         public String toString() {
             StringBuffer sb = new StringBuffer(64);
-            sb.append(super.toString());
-            sb.append("[dest=").append(this.destination);
-            sb.append(",newWindow=").append(newWindow).append("]");
+            sb.append("newWindow=").append(newWindow);
+            sb.append(",dest=").append(this.destination);
             return sb.toString();
         }
     }
index 690248d19d6bff0133978620d062193c5702677b..4a1929a629f8c818c86b19ff528718279bb9db82 100644 (file)
         <fo:flow flow-name="xsl-region-body">
           <fo:block><fo:basic-link external-destination="http://xmlgraphics.apache.org/fop/">FOP</fo:basic-link></fo:block>
           <fo:block><fo:basic-link external-destination="url(http://xmlgraphics.apache.org/fop/)">FOP</fo:basic-link></fo:block>
+          <fo:block><fo:basic-link show-destination="replace" external-destination="url(http://xmlgraphics.apache.org/fop/)">FOP</fo:basic-link></fo:block>
+          <fo:block><fo:basic-link show-destination="new" external-destination="url(http://xmlgraphics.apache.org/fop/)">FOP</fo:basic-link></fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
-    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="substring-before(substring-after(//flow/block[1]/lineArea/inlineparent/@external-link,'dest='),';')"/>
-    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="substring-before(substring-after(//flow/block[2]/lineArea/inlineparent/@external-link,'dest='),';')"/>
+    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="substring-after(//flow/block[1]/lineArea/inlineparent/@external-link,'dest=')"/>
+    <eval expected="http://xmlgraphics.apache.org/fop/" xpath="substring-after(//flow/block[2]/lineArea/inlineparent/@external-link,'dest=')"/>
+    <eval expected="false" xpath="substring-before(substring-after(//flow/block[3]/lineArea/inlineparent/@external-link,'newWindow='), ',')"/>
+    <eval expected="true" xpath="substring-before(substring-after(//flow/block[4]/lineArea/inlineparent/@external-link,'newWindow='), ',')"/>
   </checks>
 </testcase>