+++ /dev/null
-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 <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
- * @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 <tt>String</tt> 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 <tt>int</tt> 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 <tt>PropertyValue</tt>.
- */
- 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
- * <i>AbstractPropertyValue</i> is defined.
- * A specific property argument is then required.
- * @param testProperty <tt>int</tt> property index of the property
- * for which the type is to be validated.
- * @param type <tt>int</tt> 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 <tt>int</tt> 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();
- }
-}
+++ /dev/null
-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 <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
- * @version $Revision$ $Name$
- */
-/**
- * A <tt><i>PropertyTriplet</i></tt> 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 <tt>PropertyValue</tt>.
- * <p>
- * 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 <i>specified</i> property value. Note that this may be a
- * reference to a value associated with another property, so its
- * property index may be different from <i>property</i>.
- * 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 <i>computed</i> and <i>actual</i>.
- */
- private PropertyValue specified;
- /**
- * The <i>computed</i> property value. Note that this may be a
- * reference to a value associated with another property, so its
- * property index may be different from <i>property</i>.
- */
- private PropertyValue computed;
- /**
- * The <i>actual</i> property value. Note that this may be a
- * reference to a value associated with another property, so its
- * property index may be different from <i>property</i>.
- */
- private PropertyValue actual;
- private boolean wasSpecified;
-
- /**
- * The <tt>FONode</tt> 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 <tt>int</tt> property index.
- * @param specified a <tt>PropertyValue</tt>.
- * @param computed a <tt>PropertyValue</tt>.
- * @param actual a <tt>PropertyValue</tt>.
- * @exception PropertyException if <i>property</i> 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 <tt>String</tt> containing property name.
- * @param specified a <tt>PropertyValue</tt>.
- * @param computed a <tt>PropertyValue</tt>.
- * @param actual a <tt>PropertyValue</tt>.
- * @exception PropertyException if <i>property</i> 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 <tt>int</tt> property index.
- * @param specified a <tt>PropertyValue</tt>.
- */
- public PropertyTriplet(int property, PropertyValue specified)
- throws PropertyException
- {
- this(property, specified, null, null);
- }
-
- /**
- * @param property an <tt>int</tt> property index.
- * @param specified a <tt>PropertyValue</tt>.
- * @param computed a <tt>PropertyValue</tt>.
- */
- public PropertyTriplet
- (int property, PropertyValue specified, PropertyValue computed)
- throws PropertyException
- {
- this(property, specified, computed, null);
- }
-
- /**
- * Set the <i>specified</i> value.
- * @param value a <tt>PropertyValue</tt>.
- */
- public void setSpecified(PropertyValue value) {
- specified = value;
- }
-
- /**
- * Set the <i>computed</i> value.
- * @param value a <tt>PropertyValue</tt>.
- */
- public void setComputed(PropertyValue value) {
- computed = value;
- }
-
- /**
- * Set the <i>actual</i> value.
- * @param value a <tt>PropertyValue</tt>.
- */
- public void setActual(PropertyValue value) {
- actual = value;
- }
-
- /**
- * Get the <i>specified</i> value.
- * @return the <i>specified</i> <tt>PropertyValue</tt>.
- */
- public PropertyValue getSpecified() {
- return specified;
- }
-
- /**
- * Get the <i>computed</i> value.
- * @return the <i>computed</i> <tt>PropertyValue</tt>.
- */
- public PropertyValue getComputed() {
- return computed;
- }
-
- /**
- * Get the <i>actual</i> value.
- * @return the <i>actual</i> <tt>PropertyValue</tt>.
- */
- 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 <tt>FONode</tt> that stacked this <tt>PropertyTriplet</tt>.
- */
- public FONode getStackedBy() {
- return stackedBy;
- }
-
- /**
- * Record the <tt>FONode</tt> that stacked this <tt>PropertyTriplet</tt>.
- */
- 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;
- }
-
-}
+++ /dev/null
-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 <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
- * @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 <tt>int</tt> property index.
- */
- public int getProperty();
- public void setProperty(int index) throws PropertyException;
-
- /**
- * @return type field of the <tt>PropertyValue</tt>.
- */
- 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
- * <i>PropertyValue</i> is defined. A specific property argument is
- * then required.
- * @param testProperty <tt>int</tt> property index of the property
- * for which the type is to be validated.
- * @param type <tt>int</tt> bitmap of data types to check for
- * validity against this property.
- */
- public void validate(int testProperty, int type)
- throws PropertyException;
-
- /**
- * @param type <tt>int</tt> bitmap of data types to check for
- * validity against this property.
- */
- public void validate(int type) throws PropertyException;
- public Object clone() throws CloneNotSupportedException;
-
-}
+++ /dev/null
-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 <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
- * @version $Revision$ $Name$
- */
-/**
- * A list of <tt>PropertyValue</tt> 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 <tt>int</tt> 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 <tt>String</tt> 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 <tt>Collection</tt>. Pass through to superclass
- * only if the collection is another instance of a PropertyValueList.
- * @param property <tt>int</tt> index of the property.
- * @param c a <tt>Collection</tt>, which must be another
- * <i>PropertyValueList</i>.
- * @exception IllegalArgumentException if the <tt>Collection</tt> is
- * not a <i>PropertyValueList</i>.
- */
- 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 <tt>Collection</tt>. Pass through to superclass
- * only if the collection is another instance of a PropertyValueList.
- * @param propertyName a <tt>String</tt> containing the property name.
- * @param c a <tt>Collection</tt>, which must be another
- * <i>PropertyValueList</i>.
- * @exception IllegalArgumentException if the <tt>Collection</tt> is
- * not a <i>PropertyValueList</i>.
- */
- 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 <tt>PropertyValue</tt> or a <PropertyValueList</tt>;
- * the element to add. Defined as an
- * <tt>Object</tt> to override the definition in <tt>LinkedList</tt>.
- * @return a <tt>boolean</tt> success or failure(?).
- * @exception IllegalArgumentException if the object is not a
- * <tt>PropertyValue</tt> or <tt>PropertyValueList</tt>.
- */
- 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 <tt>PropertyValue</tt> or <tt>PropertyValueList</tt>
- * at the beginning of the list.
- * @param o a <tt>PropertyValue</tt> or a <PropertyValueList</tt>;
- * the element to add. Defined as an
- * <tt>Object</tt> to override the definition in <tt>LinkedList</tt>.
- * @exception IllegalArgumentException if the object is not a
- * <tt>PropertyValue</tt> or <tt>PropertyValueList</tt>.
- */
- 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 <tt>PropertyValue</tt>; the element to add. Defined as an
- * <tt>Object</tt> to override the definition in <tt>LinkedList</tt>.
- * @return a <tt>boolean</tt> success or failure(?).
- * @exception IllegalArgumentException if the object is not a
- * <tt>PropertyValue</tt>.
- */
- public void addLast(Object o) {
- add(o);
- }
-
- /*
- * Following fields and methods implement the PropertyValue interface
- */
-
- /**
- * @return <tt>int</tt> 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 <tt>PropertyValue</tt>.
- */
- 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
- * <i>AbstractPropertyValue</i> is defined.
- * A specific property argument is then required.
- * @param testProperty <tt>int</tt> property index of the property
- * for which the type is to be validated.
- * @param type <tt>int</tt> 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 <tt>int</tt> 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