Revision: 12964
http://sourceforge.net/p/foray/code/12964
Author: victormote
Date: 2022-12-27 22:25:59 +0000 (Tue, 27 Dec 2022)
Log Message:
-----------
Move storage of named property to the subclasses.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnAbstractNamedProperty.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromNearestSpecifiedValue.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromPageMasterRegion.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromParent.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromTableColumn.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnInheritedPropertyValue.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnMergePropertyValues.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnAbstractNamedProperty.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnAbstractNamedProperty.java 2022-12-27 22:06:49 UTC (rev 12963)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnAbstractNamedProperty.java 2022-12-27 22:25:59 UTC (rev 12964)
@@ -40,22 +40,19 @@
*/
public abstract class FnAbstractNamedProperty extends Function {
- /** The parameter to this function. */
- private FoPropertyId operand1;
-
/**
- * Constructor.
+ * Computes the operand from the arguments and property type.
* @param arguments The arguments to this function.
* @param propertyType The property which is calling this function.
+ * @return The operand to be used for {@code arguments} and {@code propertyType}.
* @throws PropertyException For errors creating this function.
*/
- public FnAbstractNamedProperty(final Expr[] arguments,
- final PropertyId propertyType) throws PropertyException {
- super();
+ protected FoPropertyId computeOperand(final Expr[] arguments, final PropertyId propertyType)
+ throws PropertyException {
final DtName name = validateNoneOrOneName(arguments);
if (name == null) {
if (propertyType instanceof FoPropertyId) {
- this.operand1 = (FoPropertyId) propertyType;
+ return (FoPropertyId) propertyType;
} else {
throw new PropertyException("Function " + this.getFunctionName()
+ " is valid only for properties in the fo: "
@@ -62,13 +59,12 @@
+ "namespace.");
}
} else {
- final FoPropertyId foProperty = FoPropertyId.xslValueOf(
- name.getValue());
+ final FoPropertyId foProperty = FoPropertyId.xslValueOf(name.getValue());
if (foProperty == null) {
throw new PropertyException("Not a valid property in the fo: "
+ "namespace: " + name.getValue());
}
- this.operand1 = foProperty;
+ return foProperty;
}
}
@@ -76,9 +72,7 @@
* Returns the property type to be operated on by the subclass.
* @return The property type operand.
*/
- protected FoPropertyId getPropertyType() {
- return this.operand1;
- }
+ protected abstract FoPropertyId getPropertyType();
@Override
public boolean canEvalNumeric() {
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromNearestSpecifiedValue.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromNearestSpecifiedValue.java 2022-12-27 22:06:49 UTC (rev 12963)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromNearestSpecifiedValue.java 2022-12-27 22:25:59 UTC (rev 12964)
@@ -40,6 +40,9 @@
*/
public class FnFromNearestSpecifiedValue extends FnAbstractNamedProperty {
+ /** The parameter to this function. */
+ private FoPropertyId operand1;
+
/**
* Constructor.
* @param arguments The arguments to this function.
@@ -46,9 +49,8 @@
* @param propertyType The property which is calling this function.
* @throws PropertyException For errors creating this function.
*/
- public FnFromNearestSpecifiedValue(final Expr[] arguments,
- final PropertyId propertyType) throws PropertyException {
- super(arguments, propertyType);
+ public FnFromNearestSpecifiedValue(final Expr[] arguments, final PropertyId propertyType) throws PropertyException {
+ this.operand1 = computeOperand(arguments, propertyType);
}
@Override
@@ -56,6 +58,11 @@
return "from-nearest-specified-value";
}
+ @Override
+ protected FoPropertyId getPropertyType() {
+ return this.operand1;
+ }
+
/**
* Returns the value of this function.
* @param callingProperty The property which is calling this function.
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromPageMasterRegion.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromPageMasterRegion.java 2022-12-27 22:06:49 UTC (rev 12963)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromPageMasterRegion.java 2022-12-27 22:25:59 UTC (rev 12964)
@@ -31,6 +31,7 @@
import org.foray.fotree.FoObj;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyId;
+import org.foray.fotree.fo.FoPropertyId;
/**
* The "from-page-master-region" function in XSL-FO.
@@ -38,6 +39,9 @@
*/
public class FnFromPageMasterRegion extends FnAbstractNamedProperty {
+ /** The parameter to this function. */
+ private FoPropertyId operand1;
+
/**
* Constructor.
* @param arguments The arguments to this function.
@@ -44,9 +48,8 @@
* @param propertyType The property which is calling this function.
* @throws PropertyException For errors creating this function.
*/
- public FnFromPageMasterRegion(final Expr[] arguments,
- final PropertyId propertyType) throws PropertyException {
- super(arguments, propertyType);
+ public FnFromPageMasterRegion(final Expr[] arguments, final PropertyId propertyType) throws PropertyException {
+ this.operand1 = computeOperand(arguments, propertyType);
}
@Override
@@ -54,6 +57,11 @@
return "from-page-master-region";
}
+ @Override
+ protected FoPropertyId getPropertyType() {
+ return this.operand1;
+ }
+
/**
* Returns the value of this function.
* @param fobj The FO object for whom this property is being evaluated.
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromParent.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromParent.java 2022-12-27 22:06:49 UTC (rev 12963)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromParent.java 2022-12-27 22:25:59 UTC (rev 12964)
@@ -40,6 +40,9 @@
*/
public class FnFromParent extends FnAbstractNamedProperty {
+ /** The parameter to this function. */
+ private FoPropertyId operand1;
+
/**
* Constructor.
* @param arguments The arguments to this function.
@@ -46,9 +49,8 @@
* @param propertyType The property which is calling this function.
* @throws PropertyException For errors creating this function.
*/
- public FnFromParent(final Expr[] arguments, final PropertyId propertyType)
- throws PropertyException {
- super(arguments, propertyType);
+ public FnFromParent(final Expr[] arguments, final PropertyId propertyType) throws PropertyException {
+ this.operand1 = computeOperand(arguments, propertyType);
}
@Override
@@ -56,6 +58,11 @@
return "from-parent";
}
+ @Override
+ protected FoPropertyId getPropertyType() {
+ return this.operand1;
+ }
+
/**
* Returns the value of this function.
* @param fobj The FO object for whom this property is being evaluated.
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromTableColumn.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromTableColumn.java 2022-12-27 22:06:49 UTC (rev 12963)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnFromTableColumn.java 2022-12-27 22:25:59 UTC (rev 12964)
@@ -30,6 +30,7 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyId;
+import org.foray.fotree.fo.FoPropertyId;
/**
* The "from-table-column" function in XSL-FO.
@@ -38,7 +39,7 @@
public class FnFromTableColumn extends FnAbstractNamedProperty {
/** The parameter to this function. */
- private DtName operand1;
+ private FoPropertyId operand1;
/**
* Constructor.
@@ -47,8 +48,7 @@
* @throws PropertyException For errors creating this function.
*/
public FnFromTableColumn(final Expr[] arguments, final PropertyId propertyType) throws PropertyException {
- super(arguments, propertyType);
- this.operand1 = validateNoneOrOneName(arguments);
+ this.operand1 = computeOperand(arguments, propertyType);
}
@Override
@@ -56,12 +56,18 @@
return "from-table-column";
}
+ @Override
+ protected FoPropertyId getPropertyType() {
+ return this.operand1;
+ }
+
/**
* Returns the value of this function.
* @return The value of this function.
*/
public PropertyValue eval() {
- return this.operand1;
+ /* TODO: Implement this. */
+ return null;
}
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnInheritedPropertyValue.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnInheritedPropertyValue.java 2022-12-27 22:06:49 UTC (rev 12963)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnInheritedPropertyValue.java 2022-12-27 22:25:59 UTC (rev 12964)
@@ -40,6 +40,9 @@
*/
public class FnInheritedPropertyValue extends FnAbstractNamedProperty {
+ /** The parameter to this function. */
+ private FoPropertyId operand1;
+
/**
* Constructor.
* @param arguments The arguments to this function.
@@ -46,9 +49,8 @@
* @param propertyType The property which is calling this function.
* @throws PropertyException For errors creating this function.
*/
- public FnInheritedPropertyValue(final Expr[] arguments,
- final PropertyId propertyType) throws PropertyException {
- super(arguments, propertyType);
+ public FnInheritedPropertyValue(final Expr[] arguments, final PropertyId propertyType) throws PropertyException {
+ this.operand1 = computeOperand(arguments, propertyType);
}
@Override
@@ -56,6 +58,11 @@
return "inherited-property-value";
}
+ @Override
+ protected FoPropertyId getPropertyType() {
+ return this.operand1;
+ }
+
/**
* Returns the value of this function.
* @param callingProperty The property which is calling this function.
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnMergePropertyValues.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnMergePropertyValues.java 2022-12-27 22:06:49 UTC (rev 12963)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/FnMergePropertyValues.java 2022-12-27 22:25:59 UTC (rev 12964)
@@ -31,6 +31,7 @@
import org.foray.fotree.FoObj;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyId;
+import org.foray.fotree.fo.FoPropertyId;
/**
* The "merge-property-values" function in XSL-FO.
@@ -38,6 +39,9 @@
*/
public class FnMergePropertyValues extends FnAbstractNamedProperty {
+ /** The parameter to this function. */
+ private FoPropertyId operand1;
+
/**
* Constructor.
* @param arguments The arguments to this function.
@@ -45,7 +49,7 @@
* @throws PropertyException For errors creating this function.
*/
public FnMergePropertyValues(final Expr[] arguments, final PropertyId propertyType) throws PropertyException {
- super(arguments, propertyType);
+ this.operand1 = computeOperand(arguments, propertyType);
}
@Override
@@ -53,6 +57,11 @@
return "merge-property-values";
}
+ @Override
+ protected FoPropertyId getPropertyType() {
+ return this.operand1;
+ }
+
/**
* Returns the value of this function.
* @param fobj The FO object for whom this property is being evaluated.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|