From 787cabfde9fdddd3c53d4b890643f54183a93dd6 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Sun, 30 Jun 2002 16:49:26 +0000 Subject: [PATCH] Change from MappedEnumType to MappedNumeric git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@194935 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/datatypes/MappedNumeric.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/org/apache/fop/datatypes/MappedNumeric.java diff --git a/src/org/apache/fop/datatypes/MappedNumeric.java b/src/org/apache/fop/datatypes/MappedNumeric.java new file mode 100644 index 000000000..1412ce5c4 --- /dev/null +++ b/src/org/apache/fop/datatypes/MappedNumeric.java @@ -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 Peter B. West + * @version $Revision$ $Name$ + */ +/** + * Class to represent an enumerated type whose values map onto a + * Numeric. This is a rethinking of the MappedEnumType, because + * all mapped enums mapped to one form or other of Numeric. + */ + +public class MappedNumeric extends EnumType { + + private static final String tag = "$Name$"; + private static final String revision = "$Revision$"; + + /** + * The Numeric value to which the associated ENUM token maps. + */ + private Numeric mappedNum; + + /** + * @param property the int index of the property on which + * this value is being defined. + * @param enumText the String containing the enumeration text. + * An NCName. + * @param foTree the FOTree 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 String name of the property on which + * this value is being defined. + * @param enumText the String containing the enumeration text. + * An NCName. + * @param foTree the FOTree 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 Numeric containing the value to which + * this ENUM token is mapped. + */ + public Numeric getMappedNumValue() { + return mappedNum; + } + + /** + * validate the MappedNumeric against the associated property. + */ + public void validate() throws PropertyException { + super.validate(Properties.MAPPED_NUMERIC); + } + + public String toString() { + return mappedNum.toString() + " " + super.toString(); + } + +} -- 2.39.5