]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added error checking for getEnumIndex() and getEnumText().
authorPeter Bernard West <pbwest@apache.org>
Wed, 27 Nov 2002 02:43:58 +0000 (02:43 +0000)
committerPeter Bernard West <pbwest@apache.org>
Wed, 27 Nov 2002 02:43:58 +0000 (02:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195630 13f79535-47bb-0310-9956-ffa450edef68

22 files changed:
src/org/apache/fop/fo/properties/ActiveState.java
src/org/apache/fop/fo/properties/AlignmentAdjust.java
src/org/apache/fop/fo/properties/AlignmentBaseline.java
src/org/apache/fop/fo/properties/BorderCommonStyle.java
src/org/apache/fop/fo/properties/BreakCommon.java
src/org/apache/fop/fo/properties/CaptionSide.java
src/org/apache/fop/fo/properties/Clear.java
src/org/apache/fop/fo/properties/ColorNonTransparent.java
src/org/apache/fop/fo/properties/ColorTransparent.java
src/org/apache/fop/fo/properties/DominantBaseline.java
src/org/apache/fop/fo/properties/Float.java
src/org/apache/fop/fo/properties/FontStretch.java
src/org/apache/fop/fo/properties/ForcePageCount.java
src/org/apache/fop/fo/properties/PageBreakCommon.java
src/org/apache/fop/fo/properties/RegionName.java
src/org/apache/fop/fo/properties/RenderingIntent.java
src/org/apache/fop/fo/properties/RuleStyle.java
src/org/apache/fop/fo/properties/TextAlign.java
src/org/apache/fop/fo/properties/TextAlignLast.java
src/org/apache/fop/fo/properties/VerticalAlign.java
src/org/apache/fop/fo/properties/WhiteSpaceTreatment.java
src/org/apache/fop/fo/properties/WritingMode.java

index 04fce63a55e28327d460e046f3a352cc36cc1c74..480dd3e3decd1cffb3d677d54d1f571662ce3b27 100644 (file)
@@ -38,10 +38,19 @@ public class ActiveState extends Property  {
        }
     }
 
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
index df60ffdcf4b63c4fcf1677d0870df991beb58a65..146fb3ff9e600cea09759658548f3de219b14ad5 100644 (file)
@@ -51,10 +51,19 @@ public class AlignmentAdjust extends Property  {
        }
     }
 
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
index 9fad8be624f9396301fdce9dea07a1d0dcdc60a4..b2ab29bae27c7f1c3ad16e0cd270492000f151ac 100644 (file)
@@ -50,10 +50,19 @@ public class AlignmentBaseline extends Property  {
        }
     }
 
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
index 2edbc00add5413a357f1d7dad4f5d0c98a0fa440..da0f406fdc6e147bf652b7ff4a42f18a6d0466ac 100644 (file)
@@ -43,10 +43,19 @@ public class BorderCommonStyle extends Property  {
        }
     }
 
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
index 154f3e7decf0e2925a53d119684fa7723c604b5b..888ea347e501a6d6d1c52fe7fa58af5cd541013e 100644 (file)
@@ -29,10 +29,19 @@ public class BreakCommon extends Property  {
         }
     }
 
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
index 04f8a0a57f241223e29b9a62cd13028c29bd4abf..75af3dc09a949d33bb5d3ac37535f133cd259723 100644 (file)
@@ -53,10 +53,19 @@ public class CaptionSide extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index d57844eca120e07b5a540af4d146c9b02d6409f9..273ab8610a4ca45aa653344a6a5b9c257cc718b0 100644 (file)
@@ -38,10 +38,19 @@ public class Clear extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 03c169170b60a482c383344af85c8cb8eecaabdc..f5d0057f875f5c5a3f5b4b2f756270c3db2cd37a 100644 (file)
@@ -25,10 +25,19 @@ public class ColorNonTransparent extends ColorCommon  {
        }
     }
 
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
index 8ce7283255f415bfee2258ffeebea54749994496..ac476fb91b0cbc8640cf81ff504599d5eba2305c 100644 (file)
@@ -25,10 +25,20 @@ public class ColorTransparent extends ColorCommon  {
        }
     }
 
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
index 4746401ee4895b0af325a82ab4a172ff0192ef10..5505321deaeea7fb180371d8f7b75557cb7c5e35 100644 (file)
@@ -47,10 +47,19 @@ public class DominantBaseline extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 7d7c6376928bfbc502e8a2fccc01ee6a0187b73e..64c0e483d3606457698a4a4d4b135bbc65fdc6d4 100644 (file)
@@ -36,10 +36,19 @@ public class Float extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 77a01fb4dad28e30158f7478d8bd1a1763f5edf5..5c41ca912f9076cc3c43cd555384e81132acaa3b 100644 (file)
@@ -58,10 +58,19 @@ public class FontStretch extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index e71d200b8330f2a4f4ddd6d5cd23dbe9810ac5be..10f4c1eb0ca8acaa92091d360d1ffce6a167144f 100644 (file)
@@ -37,10 +37,19 @@ public class ForcePageCount extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 1f9cf448f1660c37bbf74cace7e4441338d267c5..6f43c4e72b06fe9f4046213815facf1e126be5f8 100644 (file)
@@ -42,10 +42,19 @@ public class PageBreakCommon extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 
@@ -73,8 +82,7 @@ public class PageBreakCommon extends Property  {
            previousNext = PropNames.KEEP_WITH_NEXT;
            break;
        default:
-           throw new PropertyException
-               ("Unknown property in PageBreakCommon: "
+           throw new PropertyException("Unknown property in PageBreakCommon: "
                    + PropNames.getPropertyName(property));
        }
         if (value instanceof Inherit |
@@ -91,8 +99,7 @@ public class PageBreakCommon extends Property  {
             try {
                 enum = new EnumType(value.getProperty(), ncname);
             } catch (PropertyException e) {
-                throw new PropertyException
-                ("Unrecognized NCName in page-break-after: " + ncname);
+                throw new PropertyException                ("Unrecognized NCName in page-break-after: " + ncname);
             }
             PropertyValueList list = new PropertyValueList(property);
             switch (enum.getEnumValue()) {
@@ -115,8 +122,7 @@ public class PageBreakCommon extends Property  {
             }
         }
 
-        throw new PropertyException
-            ("Invalid value for '" + PropNames.getPropertyName(property)
+        throw new PropertyException            ("Invalid value for '" + PropNames.getPropertyName(property)
                 + "': " + value.getClass().getName());
     }
 }
index 616e42bb4134ed4b203e08dcedaf222963dcd1ea..e991ecdb92d3f1184a8ca64f1400c3df3fe3fb9f 100644 (file)
@@ -40,10 +40,19 @@ public class RegionName extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 9492714d0f41572ec2fe92a217c1c77fcdb47848..4386e64112bd0abfe2bcc0609b5c1f6d31e8ace1 100644 (file)
@@ -34,10 +34,19 @@ public class RenderingIntent extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index b34cc15f3610d7881585004b675d724d4ca732b1..fcf68416971d193dcd4d862448a3bdbd24ccb81c 100644 (file)
@@ -46,10 +46,19 @@ public class RuleStyle extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 92d6a3d73abab4ba7a0d373689a8bacde3e5a0cf..6f450c2878814cef10f52776098455e6858f181d 100644 (file)
@@ -51,10 +51,19 @@ public class TextAlign extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 842f310176aad2442a9f09fd39ea56ab5806e3a4..7cab9b94be087f99d3f58ea7f14b54de95eacc89 100644 (file)
@@ -53,10 +53,19 @@ public class TextAlignLast extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 0bee65bf81b64e78189277e6f5169b0a3e46afd8..7a98a1bb4b7e4af74660941357be439c19d63901 100644 (file)
@@ -50,10 +50,19 @@ public class VerticalAlign extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 8871799da714fb7457286d477cb832ae19c7f60f..47598d4b50d23f71be5ae83f9d8afcbb32f8c6e0 100644 (file)
@@ -43,10 +43,19 @@ public class WhiteSpaceTreatment extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }
index 88885ea6087b505ece22243797dfc1c9b75cbd1d..5d7bbc51cc05387230a373d919493bb7fa0d5329 100644 (file)
@@ -45,10 +45,19 @@ public class WritingMode extends Property  {
                                 (Object) Ints.consts.get(i));
         }
     }
-    public int getEnumIndex(String enum) {
-        return ((Integer)(rwEnumHash.get(enum))).intValue();
+    public int getEnumIndex(String enum)
+        throws PropertyException
+    {
+        Integer ii = (Integer)(rwEnumHash.get(enum));
+        if (ii == null)
+            throw new PropertyException("Unknown enum value: " + enum);
+        return ii.intValue();
     }
-    public String getEnumText(int index) {
+    public String getEnumText(int index)
+        throws PropertyException
+    {
+        if (index < 1 || index >= rwEnums.length)
+            throw new PropertyException("index out of range: " + index);
         return rwEnums[index];
     }
 }