[FOray-commit] SF.net SVN: foray: [7884] trunk/foray/foray-fotree/src/java/org/foray/ fotree
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-09-04 18:02:48
|
Revision: 7884
http://svn.sourceforge.net/foray/?rev=7884&view=rev
Author: victormote
Date: 2006-09-04 11:02:40 -0700 (Mon, 04 Sep 2006)
Log Message:
-----------
Add logic to validate the existence of the page-masters at parse time.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/LayoutMasterSet.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -204,6 +204,18 @@
}
/**
+ * Creates a suitable exception or warning if an object references a
+ * non-existent page.
+ * @throws FOTreeException If a non-existent page is referenced.
+ */
+ public void invalidPageReference(final String invalidReference)
+ throws FOTreeException {
+ final String message = this.getFullName() + " references a "
+ + "non-existent page: \"" + invalidReference + "\"";
+ this.throwException(message);
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isBlockLevelFO() {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ConditionalPageMasterReference.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -65,14 +65,10 @@
logWarning(getFullName() + " has no master-reference, and "
+ "will be ignored.");
}
- final LayoutMasterSet layoutMasterSet = repeatablePMAlternatives()
- .pageSequenceMaster().layoutMasterSet();
- if (layoutMasterSet.getSimplePageMaster(this.traitMasterReference())
- == null) {
- logWarning(getFullName() + " \"" + this.traitMasterReference()
- + "\" has master-reference which matches \n"
- + " no page definitions. It will be ignored.");
- }
+ /* Validity of the page-master referenced cannot be checked until the
+ * entire layout-master-set has been parsed, because the page-masters
+ * can be created after they are referenced.
+ * See LayoutMasterSet.validateDescendants(). */
}
/**
@@ -101,7 +97,7 @@
}
/**
- * The parent.
+ * Convenience method returning the parent.
* @return The parent, properly cast.
*/
public RepeatablePMAlternatives repeatablePMAlternatives() {
@@ -110,6 +106,22 @@
}
/**
+ * Convenience method returning the grandparent, properly cast.
+ * @return The grandparent PageSequenceMaster.
+ */
+ public PageSequenceMaster pageSequenceMaster() {
+ return repeatablePMAlternatives().pageSequenceMaster();
+ }
+
+ /**
+ * Convenience method returning the great-grandparent, properly cast.
+ * @return The great-grandparent LayoutMasterSet.
+ */
+ public LayoutMasterSet layoutMasterSet() {
+ return pageSequenceMaster().layoutMasterSet();
+ }
+
+ /**
* Indicates whether this instance matches a specific set of constraints.
* @param isOddPage True if the
* @param isFirstPage Set to true to return a true value if this instance's
@@ -204,4 +216,17 @@
return factory.makeProxy(this);
}
+ /**
+ * Checks to make sure that each page referenced actually exists.
+ * Note that it is not useful to execute this method until the entire
+ * layout-master-set has been parsed, as you cannot be sure that all
+ * page-masters have been parsed until then.
+ */
+ public void validatePageExistence() throws FOTreeException {
+ if (layoutMasterSet().getSimplePageMaster(this.traitMasterReference())
+ == null) {
+ this.invalidPageReference(this.traitMasterReference());
+ }
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/LayoutMasterSet.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/LayoutMasterSet.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/LayoutMasterSet.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -94,7 +94,24 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
+ for (int i = 0; i < this.getChildCount(); i++) {
+ final Object child = this.getChildAt(i);
+ if (child instanceof PageSequenceMaster) {
+ final PageSequenceMaster psm = (PageSequenceMaster) child;
+ /* Existence of the pages referenced cannot be validated until
+ * here because page-masters can be created after they are
+ * referenced. */
+ psm.validatePageExistence();
+ } else if (child instanceof SimplePageMaster) {
+ /* No validation needed other than acknowledging the validity
+ * of the type. */
+ } else {
+ final FObj fobj = (FObj) child;
+ fobj.throwException(this.getFullName() + " children must be "
+ + "simple-page-master \n"
+ + " or page-sequence-master.");
+ }
+ }
}
public String getName() {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -142,4 +142,18 @@
return returnSet;
}
+ /**
+ * Checks to make sure that each page referenced actually exists.
+ * Note that it is not useful to execute this method until the entire
+ * layout-master-set has been parsed, as you cannot be sure that all
+ * page-masters have been parsed until then.
+ */
+ public void validatePageExistence() throws FOTreeException {
+ for (int i = 0; i < this.getChildCount(); i++) {
+ final SubSequenceSpecifier specifier = (SubSequenceSpecifier)
+ this.getChildAt(i);
+ specifier.validatePageExistence();
+ }
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMAlternatives.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -102,4 +102,15 @@
return returnSet;
}
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePageExistence() throws FOTreeException {
+ for (int i = 0; i < this.getChildCount(); i++) {
+ final ConditionalPageMasterReference child =
+ (ConditionalPageMasterReference) this.getChildAt(i);
+ child.validatePageExistence();
+ }
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/RepeatablePMReference.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -58,6 +58,10 @@
logWarning(getFullName() + " has no master-reference, and will be "
+ "ignored.");
}
+ /* Validity of the page-master referenced cannot be checked until the
+ * entire layout-master-set has been parsed, because the page-masters
+ * can be created after they are referenced.
+ * See LayoutMasterSet.validateDescendants(). */
}
/**
@@ -92,4 +96,14 @@
return returnSet;
}
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePageExistence() throws FOTreeException {
+ if (layoutMasterSet().getSimplePageMaster(this.traitMasterReference())
+ == null) {
+ this.invalidPageReference(this.traitMasterReference());
+ }
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SinglePageMasterReference.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -56,6 +56,10 @@
this.logWarning(getFullName() + " has no master-reference, and "
+ "will be ignored.");
}
+ /* Validity of the page-master referenced cannot be checked until the
+ * entire layout-master-set has been parsed, because the page-masters
+ * can be created after they are referenced.
+ * See LayoutMasterSet.validateDescendants(). */
}
/**
@@ -90,4 +94,14 @@
return returnSet;
}
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePageExistence() throws FOTreeException {
+ if (layoutMasterSet().getSimplePageMaster(this.traitMasterReference())
+ == null) {
+ this.invalidPageReference(this.traitMasterReference());
+ }
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java 2006-09-04 17:05:58 UTC (rev 7883)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SubSequenceSpecifier.java 2006-09-04 18:02:40 UTC (rev 7884)
@@ -78,10 +78,26 @@
}
/**
- * Returns the page-master instances that are included in this template.
+ * Convenience method returning the grandparent.
+ * @return The grandparent, properly cast.
+ */
+ public LayoutMasterSet layoutMasterSet() {
+ return pageSequenceMaster().layoutMasterSet();
+ }
+
+ /**
+ * Returns the page-master instances that are included in this specifier.
* @return The page-master instances that can be generated from this
- * template.
+ * specifier.
*/
public abstract Set getPages() ;
+ /**
+ * Checks to make sure that each page referenced actually exists.
+ * Note that it is not useful to execute this method until the entire
+ * layout-master-set has been parsed, as you cannot be sure that all
+ * page-masters have been parsed until then.
+ */
+ public abstract void validatePageExistence() throws FOTreeException ;
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|