From e1a5893dc88fba1133cf87265191b8c59d4ca297 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Wed, 18 Sep 2002 14:02:02 +0000 Subject: [PATCH] Moved to org.apache.fop.datatypes. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195222 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/fo/expr/AbstractPropertyValue.java | 140 ---------- .../apache/fop/fo/expr/PropertyTriplet.java | 238 ---------------- src/org/apache/fop/fo/expr/PropertyValue.java | 85 ------ .../apache/fop/fo/expr/PropertyValueList.java | 253 ------------------ 4 files changed, 716 deletions(-) delete mode 100644 src/org/apache/fop/fo/expr/AbstractPropertyValue.java delete mode 100644 src/org/apache/fop/fo/expr/PropertyTriplet.java delete mode 100644 src/org/apache/fop/fo/expr/PropertyValue.java delete mode 100644 src/org/apache/fop/fo/expr/PropertyValueList.java diff --git a/src/org/apache/fop/fo/expr/AbstractPropertyValue.java b/src/org/apache/fop/fo/expr/AbstractPropertyValue.java deleted file mode 100644 index cdeee1b8a..000000000 --- a/src/org/apache/fop/fo/expr/AbstractPropertyValue.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.apache.fop.fo.expr; - -import org.apache.fop.fo.PropertyConsts; -import org.apache.fop.fo.PropNames; -import org.apache.fop.fo.Properties; -import org.apache.fop.fo.expr.PropertyException; -import org.apache.fop.fo.expr.PropertyValue; - -/* - * AbstractPropertyValue.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$ - */ -/** - * Base abstract class for all property value types. - */ - -public abstract class AbstractPropertyValue - implements PropertyValue, Cloneable - { - - /** - * An integer index to the type of property of which this is a value. - */ - protected int property; - - /** - * An integer property type. - */ - public final int type; - - /** - * @param index index of the property in the property arrays. - * @param type of this value - */ - public AbstractPropertyValue(int index, int type) - throws PropertyException - { - if (index < 1 || index > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + index); - if (type < 1 || type > PropertyValue.LAST_PROPERTY_TYPE) - throw new PropertyException("Invalid property type: " + type); - property = index; - this.type = type; - } - - /** - * @param propertyName a String containing the property name. - */ - public AbstractPropertyValue(String propertyName, int type) - throws PropertyException - { - property = PropertyConsts.getPropertyIndex(propertyName); - if (property < 1 || property > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + property); - if (type < 1 || type > PropertyValue.LAST_PROPERTY_TYPE) - throw new PropertyException("Invalid property type: " + type); - this.type = type; - } - - /** - * @return int property index. - */ - public int getProperty() { - return property; - } - - public void setProperty(int index) throws PropertyException { - if (index < 0 || index > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + index); - property = index; - } - - /** - * @return type field of the PropertyValue. - */ - public int getType() { - return type; - } - - /** - * In some circumstances, the property against which a type is to be - * validated may not be the same as the property against which this - * AbstractPropertyValue is defined. - * A specific property argument is then required. - * @param testProperty int property index of the property - * for which the type is to be validated. - * @param type int bitmap of data types to check for - * validity against this property. - */ - public void validate(int testProperty, int type) - throws PropertyException - { - // N.B. PROPERTY_SPECIFIC inheritance may require more specialized - // checks. Only line-height comes into this category. - - // N.B. The first commented-out condition means that I cannot validate - // unless the property is NOT inherited. - // I can't remember why I put this - // condition in here. Removing it. pbw 2002/02/18 - //if (PropertyConsts.inherited.get(testProperty) == Properties.NO - //&& (PropertyConsts.dataTypes.get(testProperty) & type) == 0) { - - if ((PropertyConsts.dataTypes.get(testProperty) & type) == 0) { - String pname = PropNames.getPropertyName(testProperty); - throw new PropertyException - ("Datatype(s) " + - Properties.listDataTypes(type) + - " not defined on " + pname); - } - } - - /** - * @param type int bitmap of data types to check for - * validity against this property. - */ - public void validate(int type) throws PropertyException { - // N.B. PROPERTY_SPECIFIC inheritance may require more specialized - // checks. Only line-height comes into this category. - validate(property, type); - } - - public String toString() { - try { - return "Property: " + PropNames.getPropertyName(property) - + " Index: " + property; - } catch (PropertyException e) { - throw new RuntimeException(e.getMessage()); - } - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/src/org/apache/fop/fo/expr/PropertyTriplet.java b/src/org/apache/fop/fo/expr/PropertyTriplet.java deleted file mode 100644 index e89cd3276..000000000 --- a/src/org/apache/fop/fo/expr/PropertyTriplet.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.apache.fop.fo.expr; - -import org.apache.fop.fo.PropertyConsts; -import org.apache.fop.fo.PropNames; -import org.apache.fop.fo.FONode; -import org.apache.fop.fo.expr.PropertyException; - -/** - * PropertyTriplet.java - * $Id$ - * - * Created: Tue Nov 20 22:18:11 2001 - * 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 PropertyTriplet is a set of possible values of an - * instance of a property at a given point in the FO tree. The three - * possible values are specified, computed and actual. All three values - * are represented by a subclass of PropertyValue. - *

- * Values may, and frequently will be, null, especially specified and actual. - */ - -public class PropertyTriplet { - - /** The property with which this triplet is associated. */ - private int property; - /** - * The specified property value. Note that this may be a - * reference to a value associated with another property, so its - * property index may be different from property. - * TODO - ensure that whenever a value is derived from another property, - * that the value is cloned and the property correctly set, rather than - * simply held here as a reference. This will render the above note - * obsolete. Same for computed and actual. - */ - private PropertyValue specified; - /** - * The computed property value. Note that this may be a - * reference to a value associated with another property, so its - * property index may be different from property. - */ - private PropertyValue computed; - /** - * The actual property value. Note that this may be a - * reference to a value associated with another property, so its - * property index may be different from property. - */ - private PropertyValue actual; - private boolean wasSpecified; - - /** - * The FONode that stacked this triplet. This is required in - * event that later a triplet is overriden by a higher priority property - * within the same FO; e.g. when the expansion of a shorthand is - * overriden by a direct assignment. - */ - private FONode stackedBy = null; - - public PropertyTriplet() { - // PropertyValues are null - } - - /** - * @param property an int property index. - * @param specified a PropertyValue. - * @param computed a PropertyValue. - * @param actual a PropertyValue. - * @exception PropertyException if property is not within the - * range of valid property indices. - */ - public PropertyTriplet(int property, PropertyValue specified, - PropertyValue computed, PropertyValue actual) - throws PropertyException - { - if (property < 0 || property > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index."); - - this.property = property; - this.specified = specified; - this.computed = computed; - this.actual = actual; - } - - /** - * @param propertyName a String containing property name. - * @param specified a PropertyValue. - * @param computed a PropertyValue. - * @param actual a PropertyValue. - * @exception PropertyException if property is not within the - * range of valid property indices. - */ - public PropertyTriplet(String propertyName, PropertyValue specified, - PropertyValue computed, PropertyValue actual) - throws PropertyException - { - this(PropertyConsts.getPropertyIndex(propertyName), - specified, computed, actual); - } - - /** - * @param property an int property index. - * @param specified a PropertyValue. - */ - public PropertyTriplet(int property, PropertyValue specified) - throws PropertyException - { - this(property, specified, null, null); - } - - /** - * @param property an int property index. - * @param specified a PropertyValue. - * @param computed a PropertyValue. - */ - public PropertyTriplet - (int property, PropertyValue specified, PropertyValue computed) - throws PropertyException - { - this(property, specified, computed, null); - } - - /** - * Set the specified value. - * @param value a PropertyValue. - */ - public void setSpecified(PropertyValue value) { - specified = value; - } - - /** - * Set the computed value. - * @param value a PropertyValue. - */ - public void setComputed(PropertyValue value) { - computed = value; - } - - /** - * Set the actual value. - * @param value a PropertyValue. - */ - public void setActual(PropertyValue value) { - actual = value; - } - - /** - * Get the specified value. - * @return the specified PropertyValue. - */ - public PropertyValue getSpecified() { - return specified; - } - - /** - * Get the computed value. - * @return the computed PropertyValue. - */ - public PropertyValue getComputed() { - return computed; - } - - /** - * Get the actual value. - * @return the actual PropertyValue. - */ - public PropertyValue getActual() { - return actual; - } - - /** - * Get the property index associated with this triplet. - * @return the property index. - */ - public int getProperty() { - return property; - } - - /** - * Get the property index associated with the specified value. - * @return the property index. - */ - public int getSpecifiedProperty() { - return specified.getProperty(); - } - - /** - * Get the property index associated with the computed value. - * @return the property index. - */ - public int getComputedProperty() { - return computed.getProperty(); - } - - /** - * Get the property index associated with the actual value. - * @return the property index. - */ - public int getActualProperty() { - return actual.getProperty(); - } - - /** - * Retrieve the FONode that stacked this PropertyTriplet. - */ - public FONode getStackedBy() { - return stackedBy; - } - - /** - * Record the FONode that stacked this PropertyTriplet. - */ - public void setStackedBy(FONode stackedBy) { - this.stackedBy = stackedBy; - } - - public String toString() { - String tmpstr = "Specified: "; - if (specified != null) tmpstr += specified.toString(); - else tmpstr += "null"; - tmpstr += "\nComputed: "; - if (computed != null) tmpstr += computed.toString(); - else tmpstr += "null"; - tmpstr += "\nActual: "; - if (actual != null) tmpstr += actual.toString(); - else tmpstr += "null"; - tmpstr += "\nStacked by: "; - if (stackedBy != null) tmpstr+= stackedBy.id; - else tmpstr += "null"; - tmpstr += "\n"; - return tmpstr; - } - -} diff --git a/src/org/apache/fop/fo/expr/PropertyValue.java b/src/org/apache/fop/fo/expr/PropertyValue.java deleted file mode 100644 index cca3bf7b4..000000000 --- a/src/org/apache/fop/fo/expr/PropertyValue.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.apache.fop.fo.expr; - -import org.apache.fop.fo.expr.PropertyException; - -/* - * PropertyValue.java - * $Id$ - * - * Created: Tue Nov 20 22:18:11 2001 - * 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$ - */ -/** - * Base interface for all property value types. - */ - -public interface PropertyValue { - - public static final int - NO_TYPE = 0 - ,ANGLE = 1 - ,AUTO = 2 - ,BOOL = 3 - ,COLOR_TYPE = 4 - ,COUNTRY = 5 - ,ENUM = 6 - ,FONT_FAMILY = 7 - ,FREQUENCY = 8 - ,FROM_NEAREST_SPECIFIED = 9 - ,FROM_PARENT = 10 - ,INHERIT = 11 - ,INTEGER = 12 - ,LANGUAGE = 13 - ,LITERAL = 14 - ,MAPPED_NUMERIC = 15 - ,MIME_TYPE = 16 - ,NCNAME = 17 - ,NONE = 18 - ,NUMERIC = 19 - ,SCRIPT = 20 - ,SHADOW_EFFECT = 21 - ,SLASH = 22 - ,TEXT_DECORATIONS = 23 - ,TEXT_DECORATOR = 24 - ,TIME = 25 - ,URI_TYPE = 26 - ,LIST = 27 - - ,LAST_PROPERTY_TYPE = LIST; - - /** - * @return int property index. - */ - public int getProperty(); - public void setProperty(int index) throws PropertyException; - - /** - * @return type field of the PropertyValue. - */ - public int getType(); - - /** - * In some circumstances, the property against which a type is to be - * validated may not be the same as the property against which this - * PropertyValue is defined. A specific property argument is - * then required. - * @param testProperty int property index of the property - * for which the type is to be validated. - * @param type int bitmap of data types to check for - * validity against this property. - */ - public void validate(int testProperty, int type) - throws PropertyException; - - /** - * @param type int bitmap of data types to check for - * validity against this property. - */ - public void validate(int type) throws PropertyException; - public Object clone() throws CloneNotSupportedException; - -} diff --git a/src/org/apache/fop/fo/expr/PropertyValueList.java b/src/org/apache/fop/fo/expr/PropertyValueList.java deleted file mode 100644 index b733741a2..000000000 --- a/src/org/apache/fop/fo/expr/PropertyValueList.java +++ /dev/null @@ -1,253 +0,0 @@ -package org.apache.fop.fo.expr; - -import java.util.LinkedList; -import java.util.Collection; -import java.util.Iterator; - -import org.apache.fop.fo.Properties; -import org.apache.fop.fo.PropertyConsts; -import org.apache.fop.fo.PropNames; -import org.apache.fop.fo.expr.PropertyValue; -import org.apache.fop.fo.expr.PropertyException; - -/* - * PropertyValueList.java - * $Id$ - * - * Created: Tue Dec 11 22:37:16 2001 - * 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 list of PropertyValue elements. - */ - -public class PropertyValueList extends LinkedList implements PropertyValue { - - /** - * An integer index to the type of property of which this is a value. - */ - protected int property; - - /** - * An integer property type. - */ - public final int type; - - /** - * @param property int index of the property. - */ - public PropertyValueList(int property) throws PropertyException { - super(); - if (property < 1 || property > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + property); - this.property = property; - type = PropertyValue.LIST; - } - - /** - * @param propertyName a String containing the property name. - */ - public PropertyValueList(String propertyName) - throws PropertyException - { - super(); - property = PropertyConsts.getPropertyIndex(propertyName); - if (property < 1 || property > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + property); - type = PropertyValue.LIST; - } - - /** - * Constructor with a Collection. Pass through to superclass - * only if the collection is another instance of a PropertyValueList. - * @param property int index of the property. - * @param c a Collection, which must be another - * PropertyValueList. - * @exception IllegalArgumentException if the Collection is - * not a PropertyValueList. - */ - public PropertyValueList(int property, Collection c) - throws PropertyException - { - super(c); - // This test only follows the super() call because that call must - // be the first in a constructor. - if (! (c instanceof PropertyValueList)) - throw new IllegalArgumentException - ("Collection is not a PropertyValueList."); - if (property < 1 || property > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + property); - this.property = property; - type = PropertyValue.LIST; - } - - /** - * Constructor with a Collection. Pass through to superclass - * only if the collection is another instance of a PropertyValueList. - * @param propertyName a String containing the property name. - * @param c a Collection, which must be another - * PropertyValueList. - * @exception IllegalArgumentException if the Collection is - * not a PropertyValueList. - */ - public PropertyValueList(String propertyName, Collection c) - throws PropertyException - { - super(c); - // This test only follows the super() call because that call must - // be the first in a constructor. - if (! (c instanceof PropertyValueList)) - throw new IllegalArgumentException - ("Collection is not a PropertyValueList."); - property = PropertyConsts.getPropertyIndex(propertyName); - if (property < 1 || property > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + property); - type = PropertyValue.LIST; - } - - /** - * Append a PropertyValue or PropertyValueList to the end of the list. - * @param o a PropertyValue or a ; - * the element to add. Defined as an - * Object to override the definition in LinkedList. - * @return a boolean success or failure(?). - * @exception IllegalArgumentException if the object is not a - * PropertyValue or PropertyValueList. - */ - public boolean add(Object o) { - if (! (o instanceof PropertyValue || o instanceof PropertyValueList)) - throw new IllegalArgumentException - ("Object is not a PropertyValue or a PropertyValueList."); - return super.add(o); - } - - /** - * Insert a PropertyValue or PropertyValueList - * at the beginning of the list. - * @param o a PropertyValue or a ; - * the element to add. Defined as an - * Object to override the definition in LinkedList. - * @exception IllegalArgumentException if the object is not a - * PropertyValue or PropertyValueList. - */ - public void addFirst(Object o) { - if (! (o instanceof PropertyValue || o instanceof PropertyValueList)) - throw new IllegalArgumentException - ("Object is not a PropertyValue or a PropertyValueList."); - super.addFirst(o); - } - - /** - * Append a PropertyValue to the end of the list. - * @param o a PropertyValue; the element to add. Defined as an - * Object to override the definition in LinkedList. - * @return a boolean success or failure(?). - * @exception IllegalArgumentException if the object is not a - * PropertyValue. - */ - public void addLast(Object o) { - add(o); - } - - /* - * Following fields and methods implement the PropertyValue interface - */ - - /** - * @return int property index. - */ - public int getProperty() { - return property; - } - - public void setProperty(int index) throws PropertyException { - if (index < 0 || index > PropNames.LAST_PROPERTY_INDEX) - throw new PropertyException("Invalid property index: " + index); - property = index; - } - - /** - * @return type field of the PropertyValue. - */ - public int getType() { - return type; - } - - /** - * In some circumstances, the property against which a type is to be - * validated may not be the same as the property against which this - * AbstractPropertyValue is defined. - * A specific property argument is then required. - * @param testProperty int property index of the property - * for which the type is to be validated. - * @param type int bitmap of data types to check for - * validity against this property. - */ - public void validate(int testProperty, int type) - throws PropertyException - { - // N.B. PROPERTY_SPECIFIC inheritance may require more specialized - // checks. Only line-height comes into this category. - - // N.B. The first commented-out condition means that I cannot validate - // unless the property is NOT inherited. - // I can't remember why I put this - // condition in here. Removing it. pbw 2002/02/18 - //if (PropertyConsts.inherited.get(testProperty) == Properties.NO - //&& (PropertyConsts.dataTypes.get(testProperty) & type) == 0) { - - if ((PropertyConsts.dataTypes.get(testProperty) & type) == 0) { - String pname = PropNames.getPropertyName(testProperty); - throw new PropertyException - ("Datatype(s) " + - Properties.listDataTypes(type) + - " not defined on " + pname); - } - } - - /** - * @param type int bitmap of data types to check for - * validity against this property. - */ - public void validate(int type) throws PropertyException { - // N.B. PROPERTY_SPECIFIC inheritance may require more specialized - // checks. Only line-height comes into this category. - validate(property, type); - } - - public String toString() { - String str, cstr; - try { - str = "Property: " + PropNames.getPropertyName(property) - + " Index: " + property + " List contents:\n"; - Iterator contents = iterator(); - while (contents.hasNext()) { - int i = 0, j = 0; - cstr = contents.next().toString(); - while (i < cstr.length() && j >= 0) { - j = cstr.indexOf('\n'); - if (j >= 0) { - str = str + ">" + cstr.substring(i, ++j); - i = j; - } else { - str = str + ">" + cstr.substring(i); - i = cstr.length(); - } - } - } - return str; - - } catch (PropertyException e) { - throw new RuntimeException(e.getMessage()); - } - } - - public Object clone() { - return super.clone(); - } - -}// PropertyValueList -- 2.39.5