diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-04-25 15:03:17 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-04-25 15:03:17 +0000 |
commit | 46ddb807a234655e106f4949d1474e857a025d17 (patch) | |
tree | b0ff72bec8018d44f91997abba7b3414cd91fb61 /src/java/org | |
parent | 417f880fb993de6302e5a9e1a51cbaf0ed7a61bc (diff) | |
download | xmlgraphics-fop-46ddb807a234655e106f4949d1474e857a025d17.tar.gz xmlgraphics-fop-46ddb807a234655e106f4949d1474e857a025d17.zip |
Restored Java 1.4 compatibility (Boolean.parseBoolean() is a Java 5 method).
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
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/fop/area/Trait.java | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 9599d8833..e7b39ad2b 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -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(); } } |