]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Change from MappedEnumType to MappedNumeric
authorPeter Bernard West <pbwest@apache.org>
Sun, 30 Jun 2002 16:49:26 +0000 (16:49 +0000)
committerPeter Bernard West <pbwest@apache.org>
Sun, 30 Jun 2002 16:49:26 +0000 (16:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@194935 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/datatypes/MappedNumeric.java [new file with mode: 0644]

diff --git a/src/org/apache/fop/datatypes/MappedNumeric.java b/src/org/apache/fop/datatypes/MappedNumeric.java
new file mode 100644 (file)
index 0000000..1412ce5
--- /dev/null
@@ -0,0 +1,88 @@
+package org.apache.fop.datatypes;
+
+import org.apache.fop.datatypes.EnumType;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.FOTree;
+
+/*
+ * MappedEnumType.java
+ * $Id$
+ *
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+/**
+ * Class to represent an enumerated type whose values map onto a
+ * <tt>Numeric</tt>.  This is a rethinking of the MappedEnumType, because
+ * all mapped enums mapped to one form or other of <tt>Numeric</tt>.
+ */
+
+public class MappedNumeric extends EnumType {
+
+    private static final String tag = "$Name$";
+    private static final String revision = "$Revision$";
+
+    /**
+     * The <tt>Numeric</tt> value to which the associated ENUM token maps.
+     */
+    private Numeric mappedNum;
+
+    /**
+     * @param property the <tt>int</tt> index of the property on which
+     * this value is being defined.
+     * @param enumText the <tt>String</tt> containing the enumeration text.
+     * An <i>NCName</i>.
+     * @param foTree the <tt>FOTree</tt> which is being built.
+     * @exception PropertyException
+     */
+    public MappedNumeric(int property, String enumText, FOTree foTree)
+        throws PropertyException
+    {
+        // Set property index in AbstractPropertyValue
+        // and enumValue enum constant in EnumType
+        super(property, enumText);
+        mappedNum = foTree.getMappedNumValue(property, enumValue);
+    }
+
+    /**
+     * @param propertyName the <tt>String</tt> name of the property on which
+     * this value is being defined.
+     * @param enumText the <tt>String</tt> containing the enumeration text.
+     * An <i>NCName</i>.
+     * @param foTree the <tt>FOTree</tt> which is being built.
+     * @exception PropertyException
+     */
+    public MappedNumeric(String propertyName, String enumText, FOTree foTree)
+        throws PropertyException
+    {
+        // Set property index in AbstractPropertyValue
+        // and enumValue enum constant in EnumType
+        super(propertyName, enumText);
+        mappedNum = foTree.getMappedNumValue(property, enumValue);
+    }
+
+    /**
+     * @return a <tt>Numeric</tt> containing the value to which
+     * this ENUM token is mapped.
+     */
+    public Numeric getMappedNumValue() {
+        return mappedNum;
+    }
+
+    /**
+     * validate the <i>MappedNumeric</i> against the associated property.
+     */
+    public void validate() throws PropertyException {
+        super.validate(Properties.MAPPED_NUMERIC);
+    }
+
+    public String toString() {
+        return mappedNum.toString() + " " + super.toString();
+    }
+
+}