diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-01-27 09:24:04 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-01-27 09:24:04 +0000 |
commit | 53634f8f77f14b1a6274f9d5e9fb3cbb6da9c775 (patch) | |
tree | e8da44356c1014f8f32a4551d6fc65a1c8a6d2eb | |
parent | d3b17dd87de11f229a242ee110dbd0edf668cd3b (diff) | |
download | xmlgraphics-fop-53634f8f77f14b1a6274f9d5e9fb3cbb6da9c775.tar.gz xmlgraphics-fop-53634f8f77f14b1a6274f9d5e9fb3cbb6da9c775.zip |
Added convenience method to get a trait as an int.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195899 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/org/apache/fop/area/Area.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/org/apache/fop/area/Area.java b/src/org/apache/fop/area/Area.java index 00daf045f..0fd4082f4 100644 --- a/src/org/apache/fop/area/Area.java +++ b/src/org/apache/fop/area/Area.java @@ -201,5 +201,22 @@ public class Area implements Serializable { public Object getTrait(Object oTraitCode) { return (props != null ? props.get(oTraitCode) : null); } + + /** + * Get a trait from this area as an integer. + * + * @param oTraitCode the trait key + * @return the trait value + */ + public int getTraitAsInteger(Object oTraitCode) { + final Object obj = getTrait(oTraitCode); + if (obj instanceof Integer) { + return ((Integer)obj).intValue(); + } else { + throw new IllegalArgumentException("Trait " + + oTraitCode.getClass().getName() + + " could not be converted to an integer"); + } + } } |