--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+
+/*
+ * Angle.java
+ * $Id$
+ * Created: Wed Nov 21 15:39:30 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.
+ */
+/**
+ * Constructor class for Angle datatype. Constructs a <tt>Numeric</tt>.
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+
+public class Angle {
+ /*
+ * Constants for UnitNames
+ */
+ public static final int NOUNIT = 0;
+ public static final int DEG = 1;
+ public static final int GRAD = 2;
+ public static final int RAD = 3;
+
+ /**
+ * Array of constant conversion factors from unit to milliseconds,
+ * indexed by integer unit constant. Keep this array in sync with
+ * the integer constants or bear the consequences.
+ */
+ public static final double[] degPerUnit = {
+ 0.0
+ ,1.0
+ ,57.29578 // Degrees per grade
+ ,63.661977 // Degrees per radian
+ };
+
+ /**
+ * Private constructor - don't instantiate a <i>Time</i> object.
+ */
+ private Angle() {}
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is
+ * assumed as 1. The base unit is degrees.
+ * @param property <tt>int</tt> index of the property.
+ * @param value the number of units.
+ * @param unit an integer value representing the unit of definition.
+ */
+ public static Numeric makeAngle(int property, double value, int unit)
+ throws PropertyException
+ {
+ return new Numeric(property, value * degPerUnit[unit],
+ Numeric.DEGREES, 1, unit);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is
+ * assumed as 1. The base unit is degrees.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param value the number of units.
+ * @param unit an integer value representing the unit of definition.
+ */
+ public static Numeric makeAngle
+ (String propertyName, double value, int unit)
+ throws PropertyException
+ {
+ return new Numeric(propertyName, value * degPerUnit[unit],
+ Numeric.DEGREES, 1, unit);
+ }
+
+ /**
+ * @param unit an <tt>int</tt> encoding an <i>Angle</i>.
+ * @return the <tt>String</tt> name of the unit in which this
+ * <i>Numeric</i> was defined.
+ */
+ public static String getUnitName(int unit) {
+ switch (unit) {
+ case DEG:
+ return "deg";
+ case GRAD:
+ return "grad";
+ case RAD:
+ return "rad";
+ default:
+ return "";
+ }
+ }
+
+ /**
+ * Normalize the angle value in the range 0 <= angle <= 360
+ * @param numeric a <tt>Numeric</tt> representing the value to be
+ * normalized.
+ * @return a <tt>double</tt> containing the normalized value.
+ */
+ public static double normalize(Numeric numeric) {
+ if (numeric.power == 1)
+ return numeric.value % 360; // Negative angles still negative
+ return numeric.value;
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+
+/*
+ * Auto.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$
+ */
+/**
+ * Class for "auto" objects.
+ */
+
+public class Auto extends AbstractPropertyValue {
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public Auto(int property)
+ throws PropertyException
+ {
+ super(property);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public Auto(String propertyName)
+ throws PropertyException
+ {
+ super(propertyName);
+ }
+
+ /**
+ * validate the <i>Auto</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.AUTO);
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.Properties;
+
+/*
+ * Bool.java
+ * $Id$
+ *
+ * Created: Fri Nov 23 15:21:37 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.
+ */
+/**
+ * Boolean property value. May take values of "true" or "false".
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+
+public class Bool extends AbstractPropertyValue {
+
+ /**
+ * The boolean value of the property
+ */
+ private boolean bool = false;
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param bool the <tt>boolean</tt> value.
+ * @exception PropertyException
+ */
+ public Bool (int property, boolean bool)
+ throws PropertyException
+ {
+ super(property);
+ this.bool = bool;
+ }
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param boolStr a <tt>String</tt> containing the boolean value. It
+ * must be either "true" or "false".
+ * @exception PropertyException
+ */
+ public Bool (int property, String boolStr)
+ throws PropertyException
+ {
+ super(property);
+ if (boolStr.equals("true")) bool = true;
+ else if (boolStr.equals("false")) bool = false;
+ else throw new PropertyException
+ ("Attempt to set Bool to " + boolStr);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt< name of the property on which
+ * this value is being defined.
+ * @param boolStr a <tt>String</tt> containing the boolean value. It
+ * must be either "true" or "false".
+ * @exception PropertyException
+ */
+ public Bool (String propertyName, String boolStr)
+ throws PropertyException
+ {
+ super(propertyName);
+ if (boolStr.equals("true")) bool = true;
+ else if (boolStr.equals("false")) bool = false;
+ else throw new PropertyException
+ ("Attempt to set Bool to " + boolStr);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt< name of the property on which
+ * this value is being defined.
+ * @param bool the <tt>boolean</tt> value.
+ * @exception PropertyException
+ */
+ public Bool (String propertyName, boolean bool)
+ throws PropertyException
+ {
+ super(propertyName);
+ this.bool = bool;
+ }
+
+ /**
+ * @return the String.
+ */
+ public boolean getBoolean() {
+ return bool;
+ }
+
+ /**
+ * validate the <i>Bool</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.BOOL);
+ }
+
+ public String toString() {
+ return bool ? "true" : "false" + "\n" + super.toString();
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+/*
+ * $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.
+ */
+/**
+ * Marker interface for compound property lists
+ */
+
+public interface Compound {
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.configuration.Configuration;
+
+/*
+ * $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$
+ */
+/**
+ * A class for <tt>country</tt> specifiers.
+ */
+
+public class Country extends NCName {
+
+ public Country(int property, String countryCode) throws PropertyException
+ {
+ super(property, countryCode);
+ // Validate the code
+ if (Configuration.getHashMapEntry("countriesMap", countryCode)
+ == null) throw new PropertyException
+ ("Invalid country code: " + countryCode);
+ }
+
+ public Country(String propertyName, String countryCode)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), countryCode);
+ }
+
+ /**
+ * @return the <tt>String</tt> country code.
+ */
+ public String getCountry() {
+ return string;
+ }
+
+ /**
+ * Validate the <i>Country</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.COUNTRY_T);
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.PropertyConsts;
+
+/*
+ * Ems.java
+ * $Id$
+ * Created: Wed Nov 21 15:39:30 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.
+ */
+/**
+ * Constructor class for relative lengths measured in <i>ems</i>. Constructs
+ * a <tt>Numeric</tt>.
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+
+public class Ems {
+
+ /**
+ * Private constructor - don't instantiate a <i>Ems</i> object.
+ */
+ private Ems() {}
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is assumed as 1. The base unit is millipoints.
+ * @param property the index of the property with which this value
+ * is associated.
+ * @param value the number of units.
+ * @return a <tt>Numeric</tt> representing this <i>Ems</i>.
+ */
+ public static Numeric makeEms(int property, double value)
+ throws PropertyException
+ {
+ return new Numeric(property, value, Numeric.EMS, 0, 0);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is assumed as 1. The base unit is millipoints.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param value the number of units.
+ * @return a <tt>Numeric</tt> representing this <i>Ems</i>.
+ */
+ public static Numeric makeEms (String propertyName, double value)
+ throws PropertyException
+ {
+ return makeEms(PropertyConsts.getPropertyIndex(propertyName), value);
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.messaging.MessageHandler;
+
+/*
+ * EnumType.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.
+ */
+/**
+ * Base class for representing enumerated values. The value is maintained as
+ * an <tt>int</tt> constant value.
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+
+public class EnumType extends AbstractPropertyValue {
+
+ /**
+ * An integer enumeration value.
+ */
+ protected int enumValue;
+
+ /**
+ * @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>.
+ * @exception PropertyException
+ */
+ public EnumType(int property, String enumText)
+ throws PropertyException
+ {
+ super(property);
+ // Get the enum integer or mapped enum integer
+ enumValue = PropertyConsts.getEnumIndex(property, enumText);
+ }
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param enum the <tt>int</tt> enumeration constant.
+ * @exception PropertyException
+ */
+ public EnumType(int property, int enum)
+ throws PropertyException
+ {
+ super(property);
+ enumValue = enum;
+ // Validate the text; getEnumText will throw a PropertyException
+ // if the enum integer is invalid
+ String enumText = PropertyConsts.getEnumText(property, enum);
+ }
+
+ /**
+ * @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>.
+ * @exception PropertyException
+ */
+ public EnumType(String propertyName, String enumText)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), enumText);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @param enum the <tt>int</tt> enumeration constant.
+ * @exception PropertyException
+ */
+ public EnumType(String propertyName, int enum)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), enum);
+ }
+
+ /**
+ * @return the <tt>int</tt> ENUM value.
+ */
+ public int getEnumValue() {
+ return enumValue;
+ }
+
+ /**
+ * @return the <tt>String</tt> enumeration token.
+ */
+ public String getEnumToken() throws PropertyException {
+ return PropertyConsts.getEnumText(property, enumValue);
+ }
+
+ /**
+ * validate the <i>EnumType</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.ENUM);
+ }
+
+ public String toString() {
+ String enumText;
+ try {
+ enumText = PropertyConsts.getEnumText(property, enumValue);
+ } catch (PropertyException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ return enumText + " " + enumValue + "\n" + super.toString();
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+
+/*
+ * FontFamilySet.java
+ * $Id$
+ *
+ * Created: Mon Nov 26 22:46:05 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 base class for representing a set of font family names.
+ */
+
+public class FontFamilySet extends AbstractPropertyValue {
+
+ /**
+ * An array of <tt>String</tt>s containing a prioritized list of
+ * font family or generic font family names.
+ */
+ private String[] fontFamilyNames;
+
+ /**
+ * @param property <tt>int</tt> index of the property.
+ * @param fontNames an array of <tt>String</tt>s containing a
+ * prioritized list of font names, as literals or <tt>NCName</tt>s,
+ * being either the full name of a font, or an enumeration token
+ * representing a font family.
+ * @exception PropertyException.
+ */
+ public FontFamilySet(int property, String[] fontFamilyNames)
+ throws PropertyException
+ {
+ super(property);
+ this.fontFamilyNames = fontFamilyNames;
+ }
+
+ /**
+ * @param propertyName <tt>String</tt> name of the property.
+ * @param fontNames an array of <tt>String</tt>s containing a
+ * prioritized list of font names, as literals or <tt>NCName</tt>s,
+ * being either the full name of a font, or an enumeration token
+ * representing a font family.
+ * @exception PropertyException.
+ */
+ public FontFamilySet(String propertyName, String[] fontFamilyNames)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), fontFamilyNames);
+ }
+
+ /**
+ * Validate the <i>FontFamilySet</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.FONTSET);
+ }
+
+ /**
+ * An <tt>Iterator</tt> implementing member class of FontFamilySet.
+ */
+ class Traverser implements Iterator {
+
+ /**
+ * The index for the iteration across the fontFamilyNames array.
+ */
+ private int index = 0;
+
+ public Traverser() {}
+
+ public boolean hasNext() {
+ return index < fontFamilyNames.length;
+ }
+
+ public Object next() {
+ if (hasNext()) return (Object)fontFamilyNames[index++];
+ throw new NoSuchElementException();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+
+/*
+ * Frequency.java
+ *
+ * Created: Wed Nov 21 15:39:30 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.
+ */
+/**
+ * Constructor class for Frequency datatype. Constructs a <tt>Numeric</tt>.
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+
+public class Frequency {
+
+ /*
+ * Constants for UnitNames
+ */
+ public static final int NOUNIT = 0;
+ public static final int HZ = 1;
+ public static final int KHZ = 2;
+
+ /**
+ * Array of constant conversion factors from unit to Hertz,
+ * indexed by integer unit constant. Keep this array in sync with
+ * the integer constants or bear the consequences.
+ */
+ public static final double[] hzPerUnit = {
+ 0.0
+ ,1.0
+ ,1000.0
+ };
+
+ /**
+ * Private constructor - don't instantiate a <i>Frequency</i> object.
+ */
+ private Frequency() {}
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is assumed as 1. The base unit is Hertz.
+ * @param property the index of the property with which this value
+ * is associated.
+ * @param value the number of units.
+ * @param unit an integer constant representing the unit
+ * @return a <tt>Numeric</tt> representing this <i>Frequency</i>.
+ */
+ public static Numeric makeFrequency(int property, double value, int unit)
+ throws PropertyException
+ {
+ return new Numeric(property, value * hzPerUnit[unit],
+ Numeric.HERTZ, 1, unit);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is assumed as 1. The base unit is Hertz.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param value the number of units.
+ * @param unit an integer constant representing the unit
+ * @return a <tt>Numeric</tt> representing this <i>Frequency</i>.
+ */
+ public static Numeric makeFrequency
+ (String propertyName, double value, int unit)
+ throws PropertyException
+ {
+ return new Numeric(propertyName, value * hzPerUnit[unit],
+ Numeric.HERTZ, 1, unit);
+ }
+
+ /**
+ * @param unit an <tt>int</tt> encoding a <i>Frequency</i> unit.
+ * @return the <tt>String</tt> name of the unit in which this
+ * <i>Numeric</i> was defined.
+ */
+ public static String getUnitName(int unit) {
+ switch (unit) {
+ case HZ:
+ return "Hz";
+ case KHZ:
+ return "kHz";
+ default:
+ return "";
+ }
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+
+/*
+ * FromNearestSpecified.java
+ * <br/>
+ * $Id$
+ * <br/>
+ * 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.
+ */
+/**
+ * <p>
+ * A pseudo-class to represent a call to the core property value function
+ * from-nearest-specified-value(), <i>only</i> in the cases where the property
+ * assigned to is identical to the <tt>NCName</tt> argument, and this is a
+ * shorthand.
+ * <p>
+ * Further, the function call must be the only component of the expression
+ * in which it occurs. (See Rec. Section 5.10.4 Property Value Functions.)
+ * In these circumstances, the function call resolves to a
+ * from-nearest-specified-value() function call on each of the properties to
+ * which the shorthand resolves.
+ * <p>
+ * The use of the pseudo-property should ensure that the function call is not
+ * involved in any arithmetic components of a more complex expression. I.e,
+ * the function evaluator in the parser must check to see whether the
+ * property for which the from-nearest-specified-value() function is being
+ * evaluated is a shorthand. If not, the function is normally evaluated.
+ * If so, the parser must further check that the property assigned to (i.e.
+ * the property against which this function is being evaluated) is the same
+ * as the <tt>NCName</tt> argument. If not, it is an error. If so, the
+ * property evaluates to an instance of this class. The value must itself
+ * be later resolved before the property value can be utilised in the fo
+ * node, but, in the meantime, any attempt to involve the function call in
+ * any more complex expression will throw an exception.
+ * <p>
+ * This mechanism ensures, without greatly complicating the parser,
+ * that the constraint on the from-nearest-specified-value() function, with
+ * respect to shorthands, is met.
+ * <p>
+ * See also <tt>FromParent</tt> pseudo-class.
+ *
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+
+public class FromNearestSpecified extends AbstractPropertyValue {
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined. In this case, a shorthand property.
+ * @exception PropertyException
+ */
+ public FromNearestSpecified(int property)
+ throws PropertyException
+ {
+ super(property);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined. In this case, a shorthand property.
+ * @exception PropertyException
+ */
+ public FromNearestSpecified(String propertyName)
+ throws PropertyException
+ {
+ super(propertyName);
+ }
+
+ /**
+ * validate the <i>FromNearestSpecified</i> against the associated
+ * property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.SHORTHAND);
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+
+/*
+ * FromParent.java
+ * <br/>
+ * $Id$
+ * <br/>
+ * 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.
+ */
+/**
+ * <p>
+ * A pseudo-class to represent a call to the core property value function
+ * from-parent(), <i>only</i> in the cases where the property assigned to
+ * is identical to the <tt>NCName</tt> argument, and this is a shorthand.
+ * <p>
+ * Further, the function call must be the only component of the expression
+ * in which it occurs. (See Rec. Section 5.10.4 Property Value Functions.)
+ * In these circumstances, the function call resolves to a
+ * from-parent() function call on each of the properties to
+ * which the shorthand resolves.
+ * <p>
+ * The use of the pseudo-property should ensure that the function call is not
+ * involved in any arithmetic components of a more complex expression. I.e,
+ * the function evaluator in the parser must check to see whether the
+ * property for which the from-parent() function is being
+ * evaluated is a shorthand. If not, the function is normally evaluated.
+ * If so, the parser must further check that the property assigned to (i.e.
+ * the property against which this function is being evaluated) is the same
+ * as the <tt>NCName</tt> argument. If not, it is an error. If so, the
+ * property evaluates to an instance of this class. The value must itself
+ * be later resolved before the property value can be utilised in the fo
+ * node, but, in the meantime, any attempt to involve the function call in
+ * any more complex expression will throw an exception.
+ * <p>
+ * This mechanism ensures, without greatly complicating the parser,
+ * that the constraint on the from-parent() function, with
+ * respect to shorthands, is met.
+ * <p>
+ * See also <tt>FromNearestSpecified</tt> pseudo-class.
+ * </p>
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */
+
+public class FromParent extends AbstractPropertyValue {
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined. In this case, a shorthand property.
+ * @exception PropertyException
+ */
+ public FromParent(int property)
+ throws PropertyException
+ {
+ super(property);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined. In this case, a shorthand property.
+ * @exception PropertyException
+ */
+ public FromParent(String propertyName)
+ throws PropertyException
+ {
+ super(propertyName);
+ }
+
+ /**
+ * validate the <i>FromParent</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.SHORTHAND);
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.PropertyConsts;
+
+/*
+ * Inherit.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 class representing the <tt>inherit</tt> keyword.
+ */
+
+public class Inherit extends AbstractPropertyValue {
+
+ /**
+ * The property from which the inherited value is to be derived. This
+ * may be different from the target property.
+ */
+ private int sourceProperty;
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param sourceProperty the <tt>int</tt> index of the property from
+ * which the inherited value is derived.
+ * @exception PropertyException
+ */
+ public Inherit(int property, int sourceProperty)
+ throws PropertyException
+ {
+ super(property);
+ this.sourceProperty = sourceProperty;
+ }
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public Inherit(int property)
+ throws PropertyException
+ {
+ this(property, property);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @param sourcePropertyName the <tt>String</tt> name of the property
+ * from which the inherited value is derived.
+ * @exception PropertyException
+ */
+ public Inherit(String propertyName, String sourcePropertyName)
+ throws PropertyException
+ {
+ super(propertyName);
+ property = PropertyConsts.getPropertyIndex(propertyName);
+ sourceProperty = PropertyConsts.getPropertyIndex(sourcePropertyName);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public Inherit(String propertyName)
+ throws PropertyException
+ {
+ this(propertyName, propertyName);
+ }
+
+ /**
+ * @return <tt>int</tt> containing the source property index.
+ */
+ public int getSourceProperty() {
+ return sourceProperty;
+ }
+
+ /**
+ * validate the <i>Inherit</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(sourceProperty, Properties.INHERIT);
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.datatypes.Inherit;
+
+/*
+ * Inherit.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 class used to indicate that a value in a compound sub-property
+ * should be inherited as a result of the 'inherit' keyword being specified
+ * on the compound shorthand.
+ */
+
+public class InheritCompound extends Inherit {
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param sourceProperty the <tt>int</tt> index of the property from
+ * which the inherited value is derived.
+ * @exception PropertyException
+ */
+ public InheritCompound(int property, int sourceProperty)
+ throws PropertyException
+ {
+ super(property);
+ this.sourceProperty = sourceProperty;
+ }
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public InheritCompound(int property)
+ throws PropertyException
+ {
+ this(property, property);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @param sourcePropertyName the <tt>String</tt> name of the property
+ * from which the inherited value is derived.
+ * @exception PropertyException
+ */
+ public InheritCompound(String propertyName, String sourcePropertyName)
+ throws PropertyException
+ {
+ super(propertyName);
+ property = PropertyConsts.getPropertyIndex(propertyName);
+ sourceProperty = PropertyConsts.getPropertyIndex(sourcePropertyName);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public InheritCompound(String propertyName)
+ throws PropertyException
+ {
+ this(propertyName, propertyName);
+ }
+
+ /**
+ * validate the <i>Inherit</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(sourceProperty, Properties.INHERIT_COMPOUND);
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+
+/*
+ * IntegerType.java
+ *
+ * Created: Wed Nov 21 15:39:30 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$
+ */
+/**
+ * Constructor for Integer datatype. Constructs a <tt>Numeric</tt>.
+ */
+
+public class IntegerType {
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given quantity.
+ * The unit power is assumed as 0. The base unit is NUMERIC.
+ * @param property the index of the property with which this value
+ * is associated.
+ * @param value the integer value.
+ * @return a <tt>Numeric</tt> representing this <i>IntegerType</i>.
+ */
+ public static Numeric makeInteger(int property, long value)
+ throws PropertyException
+ {
+ return new Numeric(property, (double)value, Numeric.NUMBER, 0, 0);
+ }
+
+ /**
+ * Construct a numeric with a given unit and quantity.
+ * The unit power is assumed as 0. The base unit is NUMERIC.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param value the integer value.
+ * @return a <tt>Numeric</tt> representing this <i>IntegerType</i>.
+ */
+ public static Numeric makeInteger(String propertyName, long value)
+ throws PropertyException
+ {
+ return new Numeric(propertyName, (double)value, Numeric.NUMBER, 0, 0);
+ }
+
+}
--- /dev/null
+/*
+ * Ints.java
+ * $Id$
+ *
+ * Created: Sun Nov 4 13:24:25 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$
+ */
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.PropNames;
+import org.apache.fop.fo.FObjectNames;
+import org.apache.fop.datastructs.ROIntegerArray;
+
+/**
+ * Data class of pre-initialised Integer objects.
+ */
+
+public class Ints {
+ /**
+ * An <tt>ROIntegerArray</tt> of Integer object constants corresponding
+ * to the set of property index values.
+ * @see org.apache.fop.fo.PropNames
+ */
+ public static final ROIntegerArray consts;
+ /**
+ * An <tt>ROIntegerArray</tt> of Integer object constants corresponding
+ * to the set of flow object index values.
+ * @see org.apache.fop.fo.FObjectNames
+ */
+ public static final ROIntegerArray foconsts;
+ private static final Integer[] constsAr;
+ private static final Integer[] foconstsAr;
+ static {
+ int range = PropNames.LAST_PROPERTY_INDEX >= FObjectNames.LAST_FO ?
+ PropNames.LAST_PROPERTY_INDEX : FObjectNames.LAST_FO;
+ constsAr = new Integer[PropNames.LAST_PROPERTY_INDEX + 1];
+ for (int i = 0; i <= PropNames.LAST_PROPERTY_INDEX; i++) {
+ constsAr[i] = new Integer(i);
+ }
+ consts = new ROIntegerArray(constsAr);
+ foconstsAr = new Integer[FObjectNames.LAST_FO + 1];
+ if (PropNames.LAST_PROPERTY_INDEX >= FObjectNames.LAST_FO) {
+ System.arraycopy(constsAr, 0, foconstsAr, 0,
+ FObjectNames.LAST_FO + 1);
+ }
+ else {
+ System.arraycopy(constsAr, 0, foconstsAr, 0,
+ PropNames.LAST_PROPERTY_INDEX + 1);
+ for (int i = PropNames.LAST_PROPERTY_INDEX + 1;
+ i <= FObjectNames.LAST_FO; i++) {
+ foconstsAr[i] = new Integer(i);
+ }
+ }
+ foconsts = new ROIntegerArray(foconstsAr);
+ }
+
+ private Ints (){}
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.configuration.Configuration;
+
+/*
+ * Language.java
+ * $Id$
+ *
+ * Created: Mon Nov 26 22:46:05 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 class for <tt>language</tt> specifiers.
+ */
+
+public class Language extends NCName {
+
+ public Language(int property, String languageCode) throws PropertyException
+ {
+ super(property, languageCode);
+ // Validate the code
+ if (Configuration.getHashMapEntry("languagesMap", languageCode)
+ == null) throw new PropertyException
+ ("Invalid language code: " + languageCode);
+ }
+
+ public Language(String propertyName, String languageCode)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), languageCode);
+ }
+
+ /**
+ * Validate the <i>Language</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.LANGUAGE_T);
+ }
+
+ /**
+ * @return the <tt>String</tt> language code.
+ */
+ public String getLanguage() {
+ return string;
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.PropertyConsts;
+
+/*
+ * Literal.java
+ * $Id$
+ * Created: Wed Nov 21 15:39:30 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$
+ */
+/**
+ * Class to represent Literal values. Subclass of <tt>StringType</tt>.
+ */
+
+public class Literal extends StringType {
+
+ /**
+ * Construct a <i>Literal</i> with a given <tt>String</tt>.
+ * @param property the index of the property with which this value
+ * is associated.
+ * @param string the <tt>String</tt> value.
+ */
+ public Literal(int property, String string)
+ throws PropertyException
+ {
+ super(property, string);
+ }
+
+ /**
+ * Construct a <i>Literal</i> with a given <tt>String</tt>.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param string the <tt>String</tt> value.
+ */
+ public Literal(String propertyName, String string)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), string);
+ }
+
+ /**
+ * Validate this <i>Literal</i>. Check that it is allowed on the
+ * associated property. A <i>Literal</i> may also encode a single
+ * character; i.e. a <tt><character></tt> type. If the
+ * validation against <i>LITERAL</i> fails, try <i>CHARACTER_T</i>.
+ */
+ public void validate() throws PropertyException {
+ try {
+ super.validate(Properties.LITERAL);
+ } catch (PropertyException e) {
+ if (string.length() == 1) {
+ super.validate(Properties.CHARACTER_T);
+ } else {
+ throw new PropertyException(e.getMessage());
+ }
+ }
+ }
+
+}
--- /dev/null
+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;
+
+/*
+ * MappedEnumType.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$
+ */
+/**
+ * Class to represent an enumerated type whose values map onto another
+ * <tt>String</tt>.
+ */
+
+public class MappedEnumType extends EnumType {
+
+ /**
+ * The String value to which the associated ENUM token maps.
+ * It expresses some underlying type other than an ENUM.
+ */
+ private String mappedEnum;
+
+ /**
+ * @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>.
+ * @exception PropertyException
+ */
+ public MappedEnumType(int property, String enumText)
+ throws PropertyException
+ {
+ // Set property index in AbstractPropertyValue
+ // and enumValue enum constant in EnumType
+ super(property, enumText);
+ mappedEnum = PropertyConsts.getMappedEnumValue(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>.
+ * @exception PropertyException
+ */
+ public MappedEnumType(String propertyName, String enumText)
+ throws PropertyException
+ {
+ // Set property index in AbstractPropertyValue
+ // and enumValue enum constant in EnumType
+ super(propertyName, enumText);
+ mappedEnum = PropertyConsts.getMappedEnumValue(property, enumValue);
+ }
+
+ /**
+ * @return a <tt>String</tt> containing the text of the value to which
+ * this ENUM token is mapped.
+ */
+ public String getMappedEnumValue() {
+ return mappedEnum;
+ }
+
+ /**
+ * validate the <i>MappedEnumType</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.MAPPED_ENUM);
+ }
+
+ public String toString() {
+ return mappedEnum + " " + super.toString();
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.Properties;
+
+/*
+ * MimeType.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$
+ */
+/**
+ * Class for mime-type subset of <tt>content-type</tt>.
+ */
+
+public class MimeType extends AbstractPropertyValue {
+
+ /**
+ * A mimetype; one of the possible types of value for
+ * <i>content-type</i>.
+ */
+ private String mimetype;
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param mimetype the <tt>String</tt> containing the mimetype
+ * extracted from <tt>url(...)</tt>.
+ * @exception PropertyException
+ */
+ public MimeType(int property, String mimetype)
+ throws PropertyException
+ {
+ super(property);
+ this.mimetype = mimetype;
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @param mimetype the <tt>String</tt> containing the mimetype
+ * extracted from <tt>url(...)</tt>.
+ * @exception PropertyException
+ */
+ public MimeType(String propertyName, String mimetype)
+ throws PropertyException
+ {
+ super(propertyName);
+ this.mimetype = mimetype;
+ }
+
+ /**
+ * @return a <tt>String</tt> containing the MIMETYPE.
+ */
+ public String getMimetype() {
+ return mimetype;
+ }
+
+ /**
+ * validate the <i>MimeType</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.MIMETYPE);
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.datatypes.StringType;
+
+/*
+ * NCName.java
+ * $Id$
+ *
+ * Created: Fri Nov 23 15:21:37 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$
+ */
+/**
+ * An NCName.
+ */
+
+public class NCName extends StringType {
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param string the <tt>String</tt>.
+ * @exception PropertyException
+ */
+ public NCName (int property, String string)
+ throws PropertyException
+ {
+ super(property, string);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt< name of the property on which
+ * this value is being defined.
+ * @param string the <tt>String</tt>.
+ * @exception PropertyException
+ */
+ public NCName (String propertyName, String string)
+ throws PropertyException
+ {
+ super(propertyName, string);
+ }
+
+ /**
+ * @return the String.
+ */
+ public String getNCName() {
+ return string;
+ }
+
+ /**
+ * validate the <i>NCName</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.NCNAME);
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+
+/*
+ * None.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$
+ */
+/**
+ * Class for property values of "none".
+ */
+
+public class None extends AbstractPropertyValue {
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public None(int property)
+ throws PropertyException
+ {
+ super(property);
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public None(String propertyName)
+ throws PropertyException
+ {
+ super(propertyName);
+ }
+
+ /**
+ * validate the <i>None</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.NONE);
+ }
+
+}
--- /dev/null
+/*
+ * $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$
+ */
+
+package org.apache.fop.datatypes;
+
+import java.lang.Number;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.Properties;
+
+
+/**
+ * An abstraction of "numeric" values as defined by the XSL FO Specification.
+ * Numerics include absolute numbers, absolute lengths, relative lengths
+ * (percentages and ems), angle, time and frequency.
+ *
+ * Relative lengths are converted immediately to a pure numeric factor, i.e.
+ * an absolute number (a number with unit power zero.) They retain a
+ * baseunit of PERCENTAGE or EMS respectively.
+ *
+ * Relative lengths resolve to absolute lengths as soon as they are involved
+ * in a multop with any Numeric with a baseunit of MILLIPOINTS. It is illegal
+ * for them to be involved in multops with Numerics of other baseunits.
+ *
+ * Therefore, only a number, its power and its baseunit need be provided for
+ * in this class.
+ *
+ * All numeric values are represented as a value and a unit raised to a
+ * power. For absolute numbers, including relative lengths, the unit power is
+ * zero.
+ *
+ * Whenever the power associated with a number is non-zero, it is a length,
+ * angle, time or frequency.
+ *
+ * It is an error for the end result of an expression to be a numeric with
+ * a power other than 0 or 1. (Rec. 5.9.6)
+ *
+ * Operations defined on combinations of the types are (where
+ * unit = ( MILLIPOINTS | HERTZ | MILLISECS | DEGREES )
+ * length = MILLIPOINTS
+ * number = NUMBER
+ * relunit = ( PERCENTAGE | EMS )
+ * notnumber = ( unit | relunit )
+ * absunit = ( number | unit )
+ * notlength = ( HERTZ | MILLISECS | DEGREES )
+ * numeric = ( number | notnumber )
+ * )
+ * numeric^n addop numeric^m = Illegal
+ * numeric1 addop numeric2 = Illegal
+ * numeric1^n addop numeric1^n = numeric1^n includes number + number
+ *
+ * number multop anyunit = anyunit universal multiplier
+ * includes number * relunit
+ * unit1 multop unit2 = Illegal
+ * relunit multop notlength = Illegal
+ * relunit multop relunit = Illegal
+ *
+ * unit1^n multop unit1^m = unit1^(n+m) includes number * number
+ * excludes relunit* relunit
+ * relunit multop length = length
+ *
+ * <i>Numeric</i>s are changeable, as the above table shows. A numeric
+ * created as a <i>Time</i> in seconds to power 1, e.g., if divided by another
+ * <i>Time</i> in seconds to power 1 becomes a number. if it is then
+ * multiplied by a <i>Length</i> in points to power 1, it becomes a
+ * <i>Length</i> in points.
+ *
+ * In fact, all lengths are maintained internally
+ * in millipoints. Each of the non-number <i>Numeric</i> types is maintained
+ * internally in a single baseunit. These are:<br/>
+ * MILLIPOINTS<br/>
+ * HERTZ<br/>
+ * MILLISECS<br/>
+ * DEGREES<br/>
+ */
+public class Numeric extends AbstractPropertyValue implements Cloneable {
+
+ /**
+ * Integer constant encoding a valid Numeric subclass
+ * base unit
+ */
+ public static final int
+ NUMBER = 1
+ ,PERCENTAGE = 2
+ ,EMS = 4
+ ,MILLIPOINTS = 8
+ ,HERTZ = 16
+ ,MILLISECS = 32
+ ,DEGREES = 64
+
+ ,LAST_BASEUNIT = DEGREES
+ ;
+
+ /**
+ * Integer constants for the subunits of numbers.
+ */
+ public static final int NUMERIC = NUMBER | PERCENTAGE | EMS;
+
+ /**
+ * Integer constants for the subunits of relative lengths.
+ */
+ public static final int REL_LENGTH = PERCENTAGE | EMS;
+
+ /**
+ * Integer constants for the named units.
+ */
+ public static final int UNIT = MILLIPOINTS | HERTZ | MILLISECS | DEGREES;
+
+ /**
+ * Integer constants for the named units not a length.
+ */
+ public static final int NOT_LENGTH = HERTZ | MILLISECS | DEGREES;
+
+ /**
+ * Integer constants for the absolute-valued units.
+ */
+ public static final int ABS_UNIT = NUMBER | UNIT;
+
+ /**
+ * Integer constants for non-numbers.
+ */
+ public static final int NOT_NUMBER = UNIT | REL_LENGTH;
+
+ /**
+ * The numerical contents of this instance.
+ */
+ protected double value;
+
+ /**
+ * The power to which the UNIT (not the number) is raised
+ */
+ protected int power;
+
+ /**
+ * The current baseunit of this instance.
+ * One of the constants defined here. Defaults to millipoints.
+ */
+ private int baseunit = MILLIPOINTS;
+
+ /**
+ * The baseunit in which this <tt>Numeric</tt> was originally defined.
+ */
+ private int originalBaseUnit = MILLIPOINTS;
+
+ /**
+ * The actual unit in which this <tt>Numeric</tt> was originally defined.
+ * This is a constant defined in each of the original unit types.
+ */
+ private int originalUnit = Length.PT;
+
+ /**
+ * Construct a fully specified <tt>Numeric</tt> object.
+ * @param property <tt>int</tt> index of the property.
+ * @param value the actual value.
+ * @param baseunit the baseunit for this <tt>Numeric</tt>.
+ * @param power The dimension of the value. 0 for a Number, 1 for a Length
+ * (any type), >1, <0 if Lengths have been multiplied or divided.
+ * @param unit <tt>int</tt> enumeration of the subtype of the
+ * <i>baseunit</i> in which this <i>Numeric</i> is being defined.
+ */
+ protected Numeric
+ (int property, double value, int baseunit, int power, int unit)
+ throws PropertyException
+ {
+ super(property);
+ // baseunit must be a power of 2 <= the LAST_BASEUNIT
+ if ((baseunit & (baseunit - 1)) != 0
+ || baseunit > LAST_BASEUNIT)
+ throw new PropertyException
+ ("Invalid baseunit: " + baseunit);
+ if ((baseunit & NUMERIC) != 0 && power != 0)
+ throw new PropertyException
+ ("Invalid power for NUMERIC: " + power);
+
+ this.value = value;
+ this.power = power;
+ this.baseunit = baseunit;
+ originalBaseUnit = baseunit;
+ originalUnit = unit;
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ }
+
+ /**
+ * Construct a fully specified <tt>Numeric</tt> object.
+ * @param propertyName <tt>String</tt> name of the property.
+ * @param value the actual value.
+ * @param baseunit the baseunit for this <tt>Numeric</tt>. Because a
+ * <i>power</i> is being specified, <i>NUMBER</i> baseunits are invalid.
+ * @param power The dimension of the value. 0 for a Number, 1 for a Length
+ * (any type), >1, <0 if Lengths have been multiplied or divided.
+ * @param unit <tt>int</tt> enumeration of the subtype of the
+ * <i>baseunit</i> in which this <i>Numeric</i> is being defined.
+ */
+ protected Numeric (String propertyName, double value, int baseunit,
+ int power, int unit)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName),
+ value, baseunit, power, unit);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> object of dimension 0 from a
+ * <tt>double</tt>.
+ * @param propertyName <tt>String</tt> property name.
+ * @param value the number as a <tt>double</tt>.
+ */
+ public Numeric(String propertyName, double value)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), value);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> object of dimension 0 from a
+ * <tt>double</tt>.
+ * @param property <tt>int</tt> property index.
+ * @param value the number as a <tt>double</tt>.
+ */
+ public Numeric(int property, double value) throws PropertyException {
+ this(property, value, NUMBER, 0, 0);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> object of dimension 0 from a
+ * <tt>long</tt>.
+ * @param propertyName <tt>String</tt> property name.
+ * @param value the number as a <tt>long</tt>.
+ */
+ public Numeric(String propertyName, long value)
+ throws PropertyException
+ {
+ this(propertyName, (double)value);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> object of dimension 0 from a
+ * <tt>long</tt>.
+ * @param property <tt>int</tt> property index.
+ * @param value the number as a <tt>long</tt>.
+ */
+ public Numeric(int property, long value)throws PropertyException {
+ this(property, (double)value);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> object from a Number.
+ * @param propertyName <tt>String</tt> property name.
+ * @param num an absolute number.
+ */
+ public Numeric(String propertyName, Number num)
+ throws PropertyException
+ {
+ this(propertyName, num.doubleValue());
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> object from a Number.
+ * @param property <tt>int</tt> property index.
+ * @param num an absolute number.
+ */
+ public Numeric(int property, Number num) throws PropertyException {
+ this(property, num.doubleValue());
+ }
+
+ /**
+ * @return <tt>double</tt> value of the <i>Numeric</i>.
+ */
+ public double getValue() {
+ return value;
+ }
+
+ /**
+ * @return <tt>int</tt> unit power of this <i>Numeric</i>.
+ */
+ public int getPower() {
+ return power;
+ }
+
+ /**
+ * @return <tt>int</tt> current baseunit of this <i>Numeric</i>.
+ */
+ public int getBaseunit() {
+ return baseunit;
+ }
+
+ /**
+ * @return <tt>int</tt> original base unit of this <i>Numeric</i>.
+ */
+ public int getOriginalBaseUnit() {
+ return originalBaseUnit;
+ }
+
+ /**
+ * @return <tt>int</tt> original unit in which this <i>Numeric</i> was
+ * defined. Value is defined in terms of the originalBaseUnit type.
+ */
+ public int getOriginalUnit() {
+ return originalUnit;
+ }
+
+ /**
+ * Validate this <i>Numeric</i>.
+ * @exception PropertyException if this numeric is invalid for
+ * the associated property.
+ */
+ public void validate() throws PropertyException {
+ switch (baseunit) {
+ case NUMBER:
+ if (power != 0)
+ throw new PropertyException
+ ("Attempt to validate Numeric with unit power of "
+ + power);
+ super.validate(Properties.NUMBER);
+ break;
+ case PERCENTAGE:
+ if (power != 0)
+ throw new PropertyException
+ ("Attempt to validate Percentage with unit power of "
+ + power);
+ super.validate(Properties.PERCENTAGE);
+ break;
+ case MILLIPOINTS:
+ super.validate(Properties.LENGTH);
+ if (power != 1)
+ throw new PropertyException
+ ("Length with unit power " + power);
+ break;
+ case HERTZ:
+ super.validate(Properties.FREQUENCY);
+ if (power != 1)
+ throw new PropertyException
+ ("Frequency with unit power " + power);
+ break;
+ case MILLISECS:
+ super.validate(Properties.TIME);
+ if (power != 1)
+ throw new PropertyException
+ ("Time with unit power " + power);
+ break;
+ case DEGREES:
+ super.validate(Properties.ANGLE);
+ if (power != 1)
+ throw new PropertyException
+ ("Angle with unit power " + power);
+ break;
+ default:
+ throw new PropertyException
+ ("Unrecognized baseunit type: " + baseunit);
+ }
+ }
+
+ /**
+ * This object has a NUMERIC type if it is a NUMBER, EMS or PERCENTAGE
+ * type.
+ */
+ public boolean isNumeric() {
+ return (baseunit & NUMERIC) != 0;
+ }
+
+ /**
+ * This object is a number if the baseunit is NUMBER. Power is
+ * guaranteed to be zero for NUMBER baseunit.
+ */
+ public boolean isNumber() {
+ return (baseunit == NUMBER);
+ }
+
+ /**
+ * This object is an EMS factor is the baseunit is EMS. Power is
+ * guaranteed to be zero for EMS baseunit.
+ */
+ public boolean isEms() {
+ return (baseunit == EMS);
+ }
+
+ /**
+ * This object is a percentage factor if the baseunit is PERCENTAGE.
+ * Power is guaranteed to be zero for PERCENTAGE baseunit.
+ */
+ public boolean isPercentage() {
+ return (baseunit == PERCENTAGE);
+ }
+
+ /**
+ * This object is a length in millipoints.
+ */
+ public boolean isLength() {
+ return (baseunit == MILLIPOINTS && power == 1);
+ }
+
+ /**
+ * This object is a time in milliseconds.
+ */
+ public boolean isTime() {
+ return (baseunit == MILLISECS && power == 1);
+ }
+
+ /**
+ * This object is a frequency in hertz.
+ */
+ public boolean isFrequency() {
+ return (baseunit == HERTZ && power == 1);
+ }
+
+ /**
+ * This object is an angle in degrees.
+ */
+ public boolean isAngle() {
+ return (baseunit == DEGREES && power == 1);
+ }
+
+ /**
+ * Return this <tt>Numeric</tt> converted (if necessary) to a
+ * <tt>double</tt>. The
+ * <i>value</i> field, a double, is returned unchanged. To check
+ * whether this is a good thing to do, call <i>isNumber()</i>.
+ * @return a <tt>double</tt> primitive type.
+ */
+ public double asDouble() {
+ return value;
+ }
+
+ /**
+ * Return the current value as a <tt>long</tt>.
+ * The <tt>double</tt> <i>value</i> is converted to an <tt>long</tt> and
+ * returned. No other checking or conversion occurs.
+ */
+ public long asLong() {
+ return (long)value;
+ }
+
+ /**
+ * Return the current value as an <tt>int</tt>.
+ * The <tt>double</tt> <i>value</i> is converted to an <tt>int</tt> and
+ * returned. No other checking or conversion occurs.
+ */
+ public int asInt() {
+ return (int)value;
+ }
+
+ /**
+ * Subtract the operand from the current value.
+ * @param op The value to subtract.
+ * @return <i>Numeric</i>; this object.
+ * @throws PropertyException If the unit power of the operands is different
+ */
+ public Numeric subtract(Numeric op) throws PropertyException {
+ // Check of same dimension
+ if (power != op.power)
+ throw new PropertyException
+ ("Can't subtract Numerics of different unit powers.");
+ if (baseunit != op.baseunit) {
+ throw new PropertyException
+ ("Can't subtract Numerics of different baseunits: "
+ + getBaseunitString() + " " + op.getBaseunitString());
+ }
+
+ // Subtract each type of value
+ value -= op.value;
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Add the operand to the current value.
+ * @param op The value to add.
+ * @return <i>Numeric</i>; this object.
+ * @throws PropertyException
+ * if the unit power of the operands is different.
+ */
+ public Numeric add(Numeric op) throws PropertyException {
+ // Check of same powerension
+ if (power != op.power)
+ throw new PropertyException
+ ("Can't add Numerics of different unit powers.");
+ if (baseunit != op.baseunit) {
+ throw new PropertyException
+ ("Can't add Numerics of different baseunits: "
+ + getBaseunitString() + " " + op.getBaseunitString());
+ }
+
+ // Add each type of value
+ value += op.value;
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Derive the remainder from a truncating division (mod). As with
+ * additive operators, the values must be absolute <tt>Numeric</tt>s
+ * of the same unit value. (5.9.6)
+ * @param op a <tt>Numeric</tt> representing the divisor
+ * @return <i>Numeric</i>; this object.
+ * @throws PropertyException If the unit power of the operands is
+ * different or if the operands have different baseunits.
+ */
+ public Numeric mod(Numeric op) throws PropertyException {
+ if (power != op.power)
+ throw new PropertyException
+ ("Can't mod Numerics of different unit powers.");
+ if (baseunit != op.baseunit) {
+ throw new PropertyException
+ ("Can't mod Numerics of different baseunits: "
+ + getBaseunitString() + " " + op.getBaseunitString());
+ }
+ if ((baseunit & REL_LENGTH) != 0) {
+ throw new PropertyException
+ ("Can't mod relative lengths."
+ + getBaseunitString() + " " + op.getBaseunitString());
+ }
+
+ value %= op.value;
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Derive the remainder from a truncating division (mod). As with
+ * additive operators, the values must be absolute <tt>Numeric</tt>s
+ * of the same unit value. (5.9.6)
+ * In this case, the argument is a <tt>double</tt>, i.e., an absolute
+ * Numeric with a unit value of zero.
+ * <p> Originally the restriction for this method was lifted as noted
+ * here. There is no indication of why. The restriction is now in place.
+ * <p>In this case only, the restriction
+ * on the same unit power is lifted.
+ * @param op a <tt>double</tt> containing the divisor
+ * @return <i>Numeric</i>; this object.
+ */
+ public Numeric mod(double op) throws PropertyException {
+ if (power != 0)
+ throw new PropertyException
+ ("Can't mod Numerics of different unit powers.");
+ if (baseunit != NUMBER) {
+ throw new PropertyException
+ ("Can't mod Numerics of different baseunits: "
+ + getBaseunitString() + " literal double");
+ }
+ if ((baseunit & REL_LENGTH) != 0) {
+ throw new PropertyException
+ ("Can't mod relative lengths."
+ + getBaseunitString());
+ }
+
+ value %= op;
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Multiply the the current value by the operand.
+ * @param op The multiplier.
+ * @return <i>Numeric</i>; this object.
+ * @throws PropertyException for invalid combinations.
+ */
+ public Numeric multiply(Numeric op) throws PropertyException {
+ if (baseunit == NUMBER) {
+ // NUMBER is the universal multiplier
+ // Multiply and convert to the basetype and power of the arg
+ value *= op.value;
+ power = op.power;
+ baseunit = op.baseunit;
+ } else { // this is not a NUMBER - must be unit or relative length
+ if (op.baseunit == NUMBER) {
+ // NUMBER is the universal multiplier
+ value *= op.value;
+ } else { // op not a NUMBER - must be UNIT or REL_LENGTH
+ if ((baseunit & UNIT ) != 0) { // this is a unit
+ if ((op.baseunit & UNIT) != 0) { // op is a unit
+ if (baseunit != op.baseunit) { // not same unit
+ throw new PropertyException
+ ("Can't multiply Numerics of different "
+ + "baseunits: " + getBaseunitString()
+ + " " + op.getBaseunitString());
+ } else { // same unit- multiply OK
+ value *= op.value;
+ power += op.power;
+ }
+ } else { // op is a REL_LENGTH; this is a UNIT
+ if (baseunit == MILLIPOINTS) { // this is a LENGTH
+ // Result is a length * numeric relative factor
+ value *= op.value;
+ } else { // this is a UNIT not a LENGTH
+ throw new PropertyException
+ ("Can't multiply a unit other than a "
+ + "length by a relative length: "
+ + getBaseunitString()
+ + " " + op.getBaseunitString());
+ }
+ }
+ } else { // this is a REL_LENGTH op is UNIT or REL_LENGTH
+ // only valid if op is a LENGTH
+ if (op.baseunit == MILLIPOINTS) {
+ value *= op.value;
+ power = op.power;
+ baseunit = op.baseunit;
+ } else { // Can't be done
+ throw new PropertyException
+ ("Can't multiply a unit other than a "
+ + "length by a relative length: "
+ + getBaseunitString()
+ + " " + op.getBaseunitString());
+ }
+ }
+ }
+ } // end of this == unit or relative length
+ // Perfom some validity checks
+ if (isNumeric() && power != 0)
+ throw new PropertyException
+ ("Number, Ems or Percentage with non-zero power");
+ // if the operation has resulted in a non-NUMERIC reducing to
+ // a unit power of 0, change the type to NUMBER
+ if (power == 0 && ! this.isNumeric()) baseunit = NUMBER;
+ // Always normalize if we are dealing with degrees.
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Multiply the the current value by the <tt>double</tt> operand.
+ * @param op The multiplier.
+ * @return <i>Numeric</i>; this object.
+ */
+ public Numeric multiply(double op) {
+ value *= op;
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Divide the the current value by the operand.
+ * @param op the divisor.
+ * @return <i>Numeric</i>; this object.
+ * @throws PropertyException for invalid combinations.
+ */
+ public Numeric divide(Numeric op) throws PropertyException {
+ if (baseunit == NUMBER) {
+ // NUMBER is the universal multiplier
+ // Divide and convert to the basetype and power of the arg
+ value /= op.value;
+ power = op.power;
+ baseunit = op.baseunit;
+ } else { // this is not a NUMBER - must be unit or relative length
+ if (op.baseunit == NUMBER) {
+ // NUMBER is the universal multiplier
+ value /= op.value;
+ } else { // op not a NUMBER - must be UNIT or REL_LENGTH
+ if ((baseunit & UNIT ) != 0) { // this is a unit
+ if ((op.baseunit & UNIT) != 0) { // op is a unit
+ if (baseunit != op.baseunit) { // not same unit
+ throw new PropertyException
+ ("Can't divide Numerics of different "
+ + "baseunits: " + getBaseunitString()
+ + " " + op.getBaseunitString());
+ } else { // same unit- divide OK
+ value /= op.value;
+ power -= op.power;
+ }
+ } else { // op is a REL_LENGTH; this is a UNIT
+ if (baseunit == MILLIPOINTS) { // this is a LENGTH
+ // Result is a length * numeric relative factor
+ value /= op.value;
+ } else { // this is a UNIT not a LENGTH
+ throw new PropertyException
+ ("Can't multiply a unit other than a "
+ + "length by a relative length: "
+ + getBaseunitString()
+ + " " + op.getBaseunitString());
+ }
+ }
+ } else { // this is a REL_LENGTH op is UNIT or REL_LENGTH
+ // only valid if op is a LENGTH
+ if (op.baseunit == MILLIPOINTS) {
+ value /= op.value;
+ power = op.power;
+ baseunit = op.baseunit;
+ } else { // Can't be done
+ throw new PropertyException
+ ("Can't multiply a unit other than a "
+ + "length by a relative length: "
+ + getBaseunitString()
+ + " " + op.getBaseunitString());
+ }
+ }
+ }
+ } // end of this == unit or relative length
+ // Perfom some validity checks
+ if (isNumeric() && power != 0)
+ throw new PropertyException
+ ("Number, Ems or Percentage with non-zero power");
+ // if the operation has resulted in a non-NUMERIC reducing to
+ // a unit power of 0, change the type to NUMBER
+ if (power == 0 && ! this.isNumeric()) baseunit = NUMBER;
+ // Always normalize if we are dealing with degrees.
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Divide the the current value by the <tt>double</tt> operand.
+ * @param op The divisor.
+ * @return <i>Numeric</i>; this object.
+ */
+ public Numeric divide(double op) {
+ value /= op;
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Negate the value of the property.
+ * @return <i>Numeric</i>; this object.
+ */
+ public Numeric negate() {
+ value = -value;
+ // I think this is OK
+ if (baseunit == DEGREES) this.value = Angle.normalize(this);
+ return this;
+ }
+
+ /**
+ * Return the absolute value of this <tt>Numeric</tt>. This is an
+ * implementation of the core function library <tt>abs</tt> function.
+ * It is only valid on an absolute numeric of unit power zero.
+ * @return A <tt>double</tt> containing the absolute value.
+ * @exception PropertyException if <i>value</i> is not unit power zero.
+ */
+ public double abs() throws PropertyException {
+ if (power != 0)
+ throw new PropertyException
+ ("abs requires absolute numeric of unit power zero");
+ return Math.abs(value);
+ }
+
+ /**
+ * Return a <tt>double</tt> which is the maximum of the current value and
+ * the operand. This is an implementation of the core function library
+ * <tt>max</tt> function. It is only valid for comparison of two
+ * absolute <tt>Numeric</tt> values.
+ * @param op a <tt>Numeric</tt> representing the comparison value.
+ * @return a <tt>double</tt> representing the <i>max</i> of
+ * <i>this.value</i> and the <i>value</i> of <i>op</i>.
+ * @throws PropertyException If the power of this
+ * object and the operand are different or not 0.
+ */
+ public double max(Numeric op) throws PropertyException {
+ // Only compare if both have unit power 0
+ if (power == op.power && power == 0) {
+ return Math.max(value, op.value);
+ }
+ throw new PropertyException
+ ("max() must compare numerics of unit power 0.");
+ }
+
+ /**
+ * Return a <tt>double</tt> which is the minimum of the current value and
+ * the operand. This is an implementation of the core function library
+ * <tt>min</tt> function. It is only valid for comparison of two
+ * absolute <tt>Numeric</tt> values.
+ * @param op a <tt>Numeric</tt> representing the comparison value.
+ * @return a <tt>double</tt> representing the <i>min</i> of
+ * <i>this.value</i> and the <i>value</i> of <i>op</i>.
+ * @throws PropertyException If the power of this
+ * object and the operand are different or not 0.
+ */
+ public double min(Numeric op) throws PropertyException {
+ // Only compare if both have unit power 0
+ if (power == op.power && power == 0) {
+ return Math.min(value, op.value);
+ }
+ throw new PropertyException
+ ("min() must compare numerics of unit power 0.");
+ }
+
+ /**
+ * Return a <tt>double</tt> which is the ceiling of the current value.
+ * This is an implementation of the core function library
+ * <tt>ceiling</tt> function. It is only valid for an absolute
+ * numeric value of unit power 0.
+ * @return a <tt>double</tt> representing the <i>ceiling</i> value.
+ * @throws PropertyException If the unit power of the
+ * object is not 0.
+ */
+ public double ceiling() throws PropertyException {
+
+ if (power == 0) {
+ return Math.ceil(value);
+ }
+ throw new PropertyException
+ ("ceiling() requires unit power 0.");
+ }
+
+ /**
+ * Return a <tt>double</tt> which is the floor of the current value.
+ * This is an implementation of the core function library
+ * <tt>floor</tt> function. It is only valid for an absolute
+ * numeric value of unit power 0.
+ * @return a <tt>double</tt> representing the <i>floor</i> value.
+ * @throws PropertyException If the unit power of the
+ * object is not 0.
+ */
+ public double floor() throws PropertyException {
+
+ if (power == 0) {
+ return Math.floor(value);
+ }
+ throw new PropertyException
+ ("floor() requires unit power 0.");
+ }
+
+ /**
+ * Return a <tt>long</tt> which is the rounded current value.
+ * This is an implementation of the core function library
+ * <tt>round</tt> function. It is only valid for an absolute
+ * numeric value of unit power 0.
+ * @return a <tt>long</tt> representing the <i>round</i>ed value.
+ * Note that although the method returns a <tt>long</tt>,
+ * the XSL funtion is expressed in terms of a <i>numeric</i>.
+ * @throws PropertyException If the unit power of the
+ * object is not 0.
+ */
+ public long round() throws PropertyException {
+
+ if (power == 0) {
+ return Math.round(value);
+ }
+ throw new PropertyException
+ ("round() requires unit power 0.");
+ }
+
+ /**
+ * @param baseunit an <tt>init</tt> encoding the base unit.
+ * @return a String containing the text name of the <i>baseunit</i>
+ * type or notification of an unrecognized baseunit/
+ */
+ public String getUnitTypeString(int baseunit) {
+ switch (baseunit) {
+ case NUMBER:
+ return "numeric";
+ case PERCENTAGE:
+ return "percentage";
+ case MILLIPOINTS:
+ return "millipoints";
+ case HERTZ:
+ return "Hertz";
+ case MILLISECS:
+ return "milliseconds";
+ case DEGREES:
+ return "degrees";
+ default:
+ return "Unrecognized baseunit type: " + baseunit;
+ }
+
+ }
+
+ /**
+ * @return a String containing the text name of the current <i>baseunit</i>
+ * type or notification of an unrecognized baseunit/
+ */
+ public String getBaseunitString() {
+ return getUnitTypeString(baseunit);
+ }
+
+ /**
+ * @return a String containing the text name of the original
+ * <i>baseunit</i> type or notification of an unrecognized baseunit/
+ */
+ public String getOriginalBaseunitString() {
+ return getUnitTypeString(originalBaseUnit);
+ }
+
+ /**
+ * @return a String containing the text name of the original
+ * <i>unit</i> type or notification of an unrecognized unit.
+ * Defined relative to the <i>originalBaseUnit</i>.
+ */
+ public String getOriginalUnitString() {
+ switch (originalBaseUnit) {
+ case NUMBER:
+ return "";
+ case PERCENTAGE:
+ return "%";
+ case MILLIPOINTS:
+ return Length.getUnitName(originalUnit);
+ case HERTZ:
+ return Frequency.getUnitName(originalUnit);
+ case MILLISECS:
+ return Time.getUnitName(originalUnit);
+ case DEGREES:
+ return Angle.getUnitName(originalUnit);
+ default:
+ return "Unrecognized original baseunit type: " + originalBaseUnit;
+ }
+
+ }
+
+ /**
+ * @param unit an <tt>int</tt> encoding a <i>Time</i> unit.
+ * @return the <tt>String</tt> name of the unit.
+ */
+ public static String getUnitName(int unit) {
+ switch (unit) {
+ case NUMBER:
+ return "";
+ case PERCENTAGE:
+ return "%";
+ default:
+ return "";
+ }
+ }
+
+ public String toString() {
+ return "" + value + getBaseunitString()
+ + (power != 0 ? "^" + power : "")
+ + "\n" + super.toString();
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+
+/*
+ * Percentage.java
+ *
+ *
+ * Created: Wed Nov 21 15:39:30 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$
+ */
+/**
+ * Constructor class for Percentage datatype. Constructs a <tt>Numeric</tt>.
+ */
+
+public class Percentage {
+
+ /**
+ * Private constructor - don't instantiate a <i>Percentage</i> object.
+ */
+ private Percentage() {}
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given quantity.
+ * The unit power is assumed as 0. The base unit is PERCENTAGE.
+ * @param property the index of the property with which this value
+ * is associated.
+ * @param percentage. This value will be normalized.
+ * @return a <tt>Numeric</tt> representing this <i>Percentage</i>.
+ */
+ public static Numeric makePercentage(int property, double percentage)
+ throws PropertyException
+ {
+ return new Numeric(property, percentage / 100.0,
+ Numeric.PERCENTAGE, 0, 0);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given quantity.
+ * The unit power is assumed as 0. The base unit is PERCENTAGE.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param percentage. This value will be normalized.
+ * @return a <tt>Numeric</tt> representing this <i>Percentage</i>.
+ */
+ public static Numeric makePercentage
+ (String propertyName, double percentage)
+ throws PropertyException
+ {
+ return new Numeric(propertyName, percentage / 100.0,
+ Numeric.PERCENTAGE, 0, 0);
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.configuration.Configuration;
+
+/*
+ * Script.java
+ * $Id$
+ *
+ * Created: Mon Nov 26 22:46:05 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 class for <tt>script</tt> specifiers.
+ */
+
+public class Script extends NCName {
+
+ public Script(int property, String scriptCode) throws PropertyException
+ {
+ super(property, scriptCode);
+ // Validate the code
+ if (Configuration.getHashMapEntry("scriptsMap", scriptCode)
+ == null) throw new PropertyException
+ ("Invalid script code: " + scriptCode);
+ }
+
+ public Script(String propertyName, String scriptCode)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), scriptCode);
+ }
+
+ /**
+ * @return the <tt>String</tt> script code.
+ */
+ public String getScript() {
+ return string;
+ }
+
+ /**
+ * Validate the <i>Script</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.SCRIPT_T);
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyValueList;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.PropertyConsts;
+import org.apache.fop.fo.PropNames;
+
+import java.util.Iterator;
+
+/*
+ * ShadowEffect.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 ShadowEffect values. This class is a holder for a
+ * set of PropertyValue objects, and will be placed in a PropertyValueList,
+ * as text shadow effects are specified in a list. See 7.16.5.
+ */
+
+public class ShadowEffect extends AbstractPropertyValue {
+
+ /**
+ * The shadow's "horizontal distance to the right of the text" (mandatory).
+ */
+ private Numeric inlineOffset;
+
+ /**
+ * The shadow's "vertical distance below the text" (mandatory).
+ */
+ private Numeric blockOffset;
+
+ /**
+ * The shadow's blur radius (optional)
+ */
+ private Numeric blurRadius;
+
+ /**
+ * The shadow's color (optional)
+ */
+ private ColorType color;
+
+ /**
+ * Construct a <i>ShadowEffect</i> from a given <tt>PropertyValueList</tt>.
+ * An individual shadow effect is specified as a list comprising a
+ * mandatory pair of <tt>Length</tt>s, the inline-progression offset and
+ * the block-progression offset, with an otpional third <tt>Length</tt>
+ * for the blur radius. The shadow effect may optionally include a
+ * color value, specified as a <tt>ColorType</tt>. The <tt>ColorType</tt>
+ * may precede or follow the <tt>Length</tt> specifiers.
+ * @param property the index of the property with which this value
+ * is associated.
+ * @param list the <tt>PropertyValueList</tt> containing details of one
+ * shadow effect
+ */
+ public ShadowEffect(int property, PropertyValueList list)
+ throws PropertyException
+ {
+ super(property);
+ Object entry;
+ Iterator entries = list.iterator();
+ switch (list.size()) {
+ case 2:
+ // Must be the inline and block offsets
+ setInlineAndBlock(entries);
+ break;
+ case 3:
+ // Must have inline and block offsets; may have blur radius or
+ // a colour specifier
+ if (list.getFirst() instanceof Numeric) {
+ if (list.getLast() instanceof Numeric) {
+ setInlineBlockAndBlur(entries);
+ } else { // last element must be a color
+ setInlineAndBlock(entries);
+ setColor(entries);
+ }
+ }
+ else { // First entry is not Numeric; has to be color
+ setColor(entries);
+ setInlineAndBlock(entries);
+ }
+ break;
+ case 4:
+ // Must have inline and block offsets, blur radius and colour
+ // specifier
+ if (list.getFirst() instanceof Numeric) {
+ setInlineBlockAndBlur(entries);
+ setColor(entries);
+ }
+ else { // First entry is not Numeric; has to be color
+ setColor(entries);
+ setInlineBlockAndBlur(entries);
+ }
+ break;
+ default:
+ throw new PropertyException
+ ("Invalid number of elements in ShadowEffect: "
+ + list.size());
+ }
+ }
+
+ /**
+ * Construct a <i>ShadowEffect</i> from a given <tt>PropertyValueList</tt>.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param list the <tt>PropertyValueList</tt> containing details of one
+ * shadow effect
+ */
+ public ShadowEffect(String propertyName, PropertyValueList list)
+ throws PropertyException
+ {
+ this(PropertyConsts.getPropertyIndex(propertyName), list);
+ }
+
+ /**
+ * Pick up two <tt>Numeric</tt> entries through the <tt>Iterator</tt>
+ * and assign them to the inlineOffset and blockOffset
+ * @param entries an <tt>Iterator</tt> already initialised elsewhere
+ */
+ private void setInlineAndBlock(Iterator entries)
+ throws PropertyException
+ {
+ Object entry;
+ entry = entries.next();
+ if (! (entry instanceof Numeric))
+ throw new PropertyException
+ ("Numeric value expected for text-shadow");
+ inlineOffset = (Numeric)entry;
+ entry = entries.next();
+ if (! (entry instanceof Numeric))
+ throw new PropertyException
+ ("Numeric value expected for text-shadow");
+ blockOffset = (Numeric)entry;
+ }
+
+ /**
+ * Pick up three <tt>Numeric</tt> entries through the <tt>Iterator</tt>
+ * and assign them to the inlineOffset, blockOffset and blurRadius
+ * @param entries an <tt>Iterator</tt> already initialised elsewhere
+ */
+ private void setInlineBlockAndBlur(Iterator entries)
+ throws PropertyException
+ {
+ Object entry;
+ setInlineAndBlock(entries);
+ entry = entries.next();
+ if (! (entry instanceof Numeric))
+ throw new PropertyException
+ ("Numeric blur radius value expected for text-shadow");
+ blurRadius = (Numeric)entry;
+ }
+
+ /**
+ * Set the shadow color from the next entry returned by the entries
+ * iterator. A color entry must be either a <tt>ColorType</tt> already,
+ * or an <tt>NCName</tt> containing one of the standard XSL color
+ * keywords.
+ * @param entries an <tt>Iterator</tt>.
+ */
+ private void setColor(Iterator entries) throws PropertyException {
+ Object entry;
+ entry = entries.next();
+ if (entry instanceof ColorType) {
+ color = (ColorType)entry;
+ } else if (entry instanceof NCName) {
+ color = new ColorType
+ (property,
+ PropertyConsts.getEnumIndex
+ (PropNames.TEXT_SHADOW, ((NCName)entry).getNCName()));
+ }
+ }
+
+ /**
+ * Validate this <i>ShadowEffect</i>. Check that it is allowed on the
+ * associated property. A <i>ShadowEffect</i> may also encode a single
+ * character; i.e. a <tt><character></tt> type. If the
+ * validation against <i>LITERAL</i> fails, try <i>CHARACTER_T</i>.
+ */
+ public void validate() throws PropertyException {
+ if (property != PropNames.TEXT_SHADOW)
+ throw new PropertyException
+ ("ShadowEffects only valid for text-shadow'");
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.Properties;
+
+/*
+ * StringType.java
+ * $Id$
+ *
+ * Created: Fri Nov 23 15:21:37 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$
+ */
+/**
+ * The base class for most datatypes which resolve to a <tt>String</tt>.
+ */
+
+public class StringType extends AbstractPropertyValue {
+
+ protected String string;
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param string the <tt>String</tt>.
+ * @exception PropertyException
+ */
+ public StringType (int property, String string)
+ throws PropertyException
+ {
+ super(property);
+ this.string = string;
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt< name of the property on which
+ * this value is being defined.
+ * @param string the <tt>String</tt>.
+ * @exception PropertyException
+ */
+ public StringType (String propertyName, String string)
+ throws PropertyException
+ {
+ super(propertyName);
+ this.string = string;
+ }
+
+ /**
+ * @return the String.
+ */
+ public String getString() {
+ return string;
+ }
+
+ /**
+ * validate the <i>StringType</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.STRING_TYPE);
+ }
+
+ public String toString() {
+ return string + "\n" + super.toString();
+ }
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.PropNames;
+import org.apache.fop.datatypes.TextDecorator;
+
+/*
+ * TextDecorations.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 for
+ */
+
+public class TextDecorations
+ extends AbstractPropertyValue implements Cloneable
+{
+
+ /**
+ * The decorations specified by this object
+ */
+ private byte decorations;
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public TextDecorations(int property, byte decorations)
+ throws PropertyException
+ {
+ super(property);
+ this.decorations = decorations;
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public TextDecorations(String propertyName)
+ throws PropertyException
+ {
+ super(propertyName);
+ this.decorations = decorations;
+ }
+
+ /**
+ * @return <tt>byte</tt> decorations value
+ */
+ public byte getDecorations() {
+ return decorations;
+ }
+
+ public byte maskDecorations(TextDecorator decorator) {
+ decorations |= decorator.onMask;
+ decorations &= ( ~ decorator.offMask );
+ return decorations;
+ }
+
+ /**
+ * validate the <i>TextDecorations</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ if (property != PropNames.TEXT_DECORATION)
+ throw new PropertyException
+ ("TextDecorations only valid for 'text-decoration'");
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+import org.apache.fop.fo.PropNames;
+
+/*
+ * TextDecorator.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 for "text-decoration" specification. This class specifies the
+ * text decoration modifiers which are to be applied to the current
+ * text-decoration value.
+ * <p>It is applied to a TextDecorations object, to modify the decorations
+ * by applying these values.
+ */
+
+public class TextDecorator extends AbstractPropertyValue {
+
+ /**
+ * OR mask to turn decorations on
+ */
+ public final byte onMask;
+
+ /**
+ * NAND mask to turn decorations off
+ */
+ public final byte offMask;
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public TextDecorator(int property, byte onMask, byte offMask)
+ throws PropertyException
+ {
+ super(property);
+ this.onMask = onMask;
+ this.offMask = offMask;
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @exception PropertyException
+ */
+ public TextDecorator(String propertyName, byte onMask, byte offMask)
+ throws PropertyException
+ {
+ super(propertyName);
+ this.onMask = onMask;
+ this.offMask = offMask;
+ }
+
+ /**
+ * validate the <i>TextDecorator</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ if (property != PropNames.TEXT_DECORATION)
+ throw new PropertyException
+ ("TextDecorator only valid for 'text-decoration'");
+ }
+
+}
--- /dev/null
+
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.PropertyException;
+//import org.apache.fop.fo.Properties;
+//import org.apache.fop.fo.PropertyConsts;
+//import org.apache.fop.fo.PropNames;
+
+/*
+ * Time.java
+ * $Id$
+ * Created: Wed Nov 21 15:39:30 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$
+ */
+/**
+ * Time is a front for the manufacture of <tt>Numeric</tt> objects.
+ * Because Numerics are so malleable, it makes no sense to tie
+ * a Numeric object to any particular type by subclassing <tt>Numeric</tt>.
+ * Instead, each of the Numeric types provides static methods to generate
+ * a Numeric representing, as originally created, a particular type of
+ * number or measure. The constructor for this class is <tt>private</tt>.
+ */
+
+public class Time {
+ /*
+ * Constants for UnitNames
+ */
+ public static final int NOUNIT = 0;
+ public static final int MSEC = 1;
+ public static final int SEC = 2;
+
+ /**
+ * Array of constant conversion factors from unit to milliseconds,
+ * indexed by integer unit constant. Keep this array in sync with
+ * the integer constants or bear the consequences.
+ */
+ public static final double[] msPerUnit = {
+ 0.0
+ ,1.0
+ ,1000.0
+ };
+
+ /**
+ * Private constructor - don't instantiate a <i>Time</i> object.
+ */
+ private Time() {}
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is assumed as 1. The base unit is milliseconds.
+ * @param property the index of the property with which this value
+ * is associated.
+ * @param value the number of units.
+ * @param unit an integer constant representing the unit
+ * @return a <tt>Numeric</tt> representing this <i>Time</i>.
+ */
+ public static Numeric makeTime(int property, double value, int unit)
+ throws PropertyException
+ {
+ return new Numeric(property, value * msPerUnit[unit],
+ Numeric.MILLISECS, 1, unit);
+ }
+
+ /**
+ * Construct a <tt>Numeric</tt> with a given unit and quantity.
+ * The unit power is assumed as 1. The base unit is milliseconds.
+ * @param propertyName the name of the property with which this value
+ * is associated.
+ * @param value the number of units.
+ * @param unit an integer constant representing the unit
+ * @return a <tt>Numeric</tt> representing this <i>Time</i>.
+ */
+ public static Numeric makeTime(String propertyName, double value, int unit)
+ throws PropertyException
+ {
+ return new Numeric(propertyName, value * msPerUnit[unit],
+ Numeric.MILLISECS, 1, unit);
+ }
+
+ /**
+ * @param unit an <tt>int</tt> encoding a <i>Time</i> unit.
+ * @return the <tt>String</tt> name of the unit.
+ */
+ public static String getUnitName(int unit) {
+ switch (unit) {
+ case MSEC:
+ return "ms";
+ case SEC:
+ return "s";
+ default:
+ return "";
+ }
+ }
+
+}
--- /dev/null
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.expr.AbstractPropertyValue;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.Properties;
+
+/*
+ * UriType.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$
+ */
+/**
+ * Class for URLs specified with <tt>uri()</tt> function.
+ */
+
+public class UriType extends AbstractPropertyValue {
+
+ /**
+ * A URI Specification
+ */
+ private String uri;
+
+ /**
+ * @param property the <tt>int</tt> index of the property on which
+ * this value is being defined.
+ * @param uri the <tt>String</tt> containing the uri extracted from
+ * <tt>url(...)</tt>.
+ * @exception PropertyException
+ */
+ public UriType(int property, String uri)
+ throws PropertyException
+ {
+ super(property);
+ this.uri = uri;
+ }
+
+ /**
+ * @param propertyName the <tt>String</tt> name of the property on which
+ * this value is being defined.
+ * @param uri the <tt>String</tt> containing the uri extracted from
+ * <tt>url(...)</tt>.
+ * @exception PropertyException
+ */
+ public UriType(String propertyName, String uri)
+ throws PropertyException
+ {
+ super(propertyName);
+ this.uri = uri;
+ }
+
+ /**
+ * @return a <tt>String</tt> containing the URI.
+ */
+ public String getUri() {
+ return uri;
+ }
+
+ /**
+ * validate the <i>UriType</i> against the associated property.
+ */
+ public void validate() throws PropertyException {
+ super.validate(Properties.URI_SPECIFICATION);
+ }
+
+}