From 5752e3e60ca395e1e325c1d26851ec9226055367 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Sun, 15 Sep 2002 05:47:50 +0000 Subject: [PATCH] Class for unresolved inherited-property-value() calls. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195189 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/datatypes/InheritedValue.java | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/org/apache/fop/datatypes/InheritedValue.java diff --git a/src/org/apache/fop/datatypes/InheritedValue.java b/src/org/apache/fop/datatypes/InheritedValue.java new file mode 100644 index 000000000..574bed94d --- /dev/null +++ b/src/org/apache/fop/datatypes/InheritedValue.java @@ -0,0 +1,126 @@ +package org.apache.fop.datatypes; + +import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.fo.expr.PropertyValue; +import org.apache.fop.fo.expr.PropertyTriplet; +import org.apache.fop.fo.Properties; +import org.apache.fop.datatypes.IndirectValue; + +/* + * $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$ + */ +/** + * A class representing an unresolved inherited value. It may be created as + * in the process of resolving "normal" default inheritance, when no value is + * specified for an inheritable property, or it may be created in the process + * of resolving a call to the core function + * inherited-property-value(). In both cases, it will only be + * necessary when the inherited property cannot otherwise be resolved into a + * PropertyValue immediately. + *

Strictly speaking, a distinction should be made between these two + * cases, because the latter may derive from a property other than the + * target property whose value ist is resolving. This is never true of + * default inheritance. + *

InheritedValue differs from Inherit in that it only + * applies to properties which support default inheritance, and there is at + * least one case - that of line-height defined as a <number> - + * in which the specified value is inherited. + */ + +public class InheritedValue extends IndirectValue { + + private static final String tag = "$Name$"; + private static final String revision = "$Revision$"; + + /** + * @param property the int index of the property on which + * this value is being defined. + * @param sourceProperty the int index of the property from + * which the inherited value is derived. + * @exception PropertyException + */ + public InheritedValue(int property, int sourceProperty) + throws PropertyException + { + super(property, PropertyValue.INHERIT, sourceProperty); + } + + /** + * @param property the int index of the property on which + * this value is being defined. + * @exception PropertyException + */ + public InheritedValue(int property) + throws PropertyException + { + this(property, property); + } + + /** + * @param propertyName the String name of the property on which + * this value is being defined. + * @param sourcePropertyName the String name of the property + * from which the inherited value is derived. + * @exception PropertyException + */ + public InheritedValue(String propertyName, String sourcePropertyName) + throws PropertyException + { + super(propertyName, PropertyValue.INHERIT, sourcePropertyName); + } + + /** + * @param propertyName the String name of the property on which + * this value is being defined. + * @exception PropertyException + */ + public InheritedValue(String propertyName) + throws PropertyException + { + this(propertyName, propertyName); + } + + /** + * validate the InheritedValue against the associated property. + */ + public void validate(int property) throws PropertyException { + String propStr = "Unknown"; + String spropStr = "Unknown"; + int sprop = getSourceProperty(); + if (property != sprop) { + try { + propStr = PropNames.getPropertyName(this.property); + spropStr = PropNames.getPropertyName(sprop); + } catch (PropertyException e) {} + throw new PropertyException + ("InheritedValue for property " + this.property + + " (" + propStr + ") can only be validated against its " + + "source property " + sprop + " (" + spropStr + ")."); + } + // Property must be inheritable + if (PropertyConsts.inheritance(sprop) == Properties.NO) { + try { + propStr = PropNames.getPropertyName(this.property); + spropStr = PropNames.getPropertyName(sprop); + } catch (PropertyException e) {} + throw new PropertyException + ("Source property " + sprop + " (" + spropStr + ") for " + + this.property + " (" + propStr + + ") is not inheritable."); + } + } + + /** + * validate the InheritedValue against the source property. + */ + public void validate() throws PropertyException { + validate(getSourceProperty()); + } + +} -- 2.39.5