]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added convenience method to get a trait as an int.
authorJeremias Maerki <jeremias@apache.org>
Mon, 27 Jan 2003 09:24:04 +0000 (09:24 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 27 Jan 2003 09:24:04 +0000 (09:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195899 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/area/Area.java

index 00daf045f5522ba4bf8b1d35a8ce064fa70ef171..0fd4082f4ae83b0fa466bc02d56358ca2e886f58 100644 (file)
@@ -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");
+        }
+    }
 }