package org.apache.fop.fo.properties;
+import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.fo.expr.PropertyException;
+
/**
* A number quantity in XSL which is specified as an enum, such as "no-limit".
*/
-public class EnumNumber extends NumberProperty {
+public final class EnumNumber extends Property implements Numeric {
/** cache holding all canonical EnumNumber instances */
private static final PropertyCache cache = new PropertyCache();
* @param enumProperty the base EnumProperty
*/
private EnumNumber(Property enumProperty) {
- super(null);
this.enumProperty = (EnumProperty) enumProperty;
}
/**
* Returns the canonical EnumNumber instance corresponding
* to the given Property
+ *
* @param enumProperty the base EnumProperty
* @return the canonical instance
*/
new EnumNumber((EnumProperty) enumProperty));
}
+ /** {@inheritDoc} */
public int getEnum() {
return enumProperty.getEnum();
}
- /**
- * Returns the length in 1/1000ths of a point (millipoints)
- * @return the length in millipoints
- */
- public int getValue() {
- log.error("getValue() called on " + enumProperty + " number");
- return 0;
- }
-
- /**
- * Returns the value as numeric.
- * @return the length in millipoints
- */
- public double getNumericValue() {
- log.error("getNumericValue() called on " + enumProperty + " number");
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String getString() {
return enumProperty.toString();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Object getObject() {
return enumProperty.getObject();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public boolean equals(Object obj) {
if (obj instanceof EnumNumber) {
return (((EnumNumber)obj).enumProperty == this.enumProperty);
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public int hashCode() {
return enumProperty.hashCode();
}
+
+ /** {@inheritDoc} */
+ public int getDimension() {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ * Always <code>true</code> for instances of this type
+ */
+ public boolean isAbsolute() {
+ return true;
+ }
+ /**
+ * {@inheritDoc}
+ * logs an error, because it's not supposed to be called
+ */
+ public double getNumericValue(PercentBaseContext context) throws PropertyException {
+ log.error("getNumericValue() called on " + enumProperty + " number");
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ * logs an error, because it's not supposed to be called
+ */
+ public int getValue(PercentBaseContext context) {
+ log.error("getValue() called on " + enumProperty + " number");
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ * logs an error, because it's not supposed to be called
+ */
+ public int getValue() {
+ log.error("getValue() called on " + enumProperty + " number");
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ * logs an error, because it's not supposed to be called
+ */
+ public double getNumericValue() {
+ log.error("getNumericValue() called on " + enumProperty + " number");
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Numeric getNumeric() {
+ return this;
+ }
+
}
/**
* Class for handling numeric properties
*/
-public class NumberProperty extends Property implements Numeric {
+public final class NumberProperty extends Property implements Numeric {
/**
* Inner class for making NumberProperty objects
* Constructor for Number input
* @param num Number object value for property
*/
- protected NumberProperty(Number num) {
+ private NumberProperty(Number num) {
this.number = num;
}
/** {@inheritDoc} */
public boolean equals(Object o) {
- if (o != null && o instanceof NumberProperty) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof NumberProperty) {
NumberProperty np = (NumberProperty) o;
return (np.number == this.number
|| (this.number != null
&& this.number.equals(np.number)));
- } else {
- return false;
}
+ return false;
}
}