[FOray-commit] SF.net SVN: foray: [7865] 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-03 17:55:26
|
Revision: 7865
http://svn.sourceforge.net/foray/?rev=7865&view=rev
Author: victormote
Date: 2006-09-03 10:55:15 -0700 (Sun, 03 Sep 2006)
Log Message:
-----------
Move some of the logic in end() to validateDescendants().
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Bookmark.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTree.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Flow.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Footnote.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/InstreamForeignObject.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListBlock.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListItem.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.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/SimplePageMaster.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/StaticContent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Table.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/TableCell.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FOTreeBuilder.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -130,8 +130,8 @@
}
}
try {
+ currentFObj.end();
currentFObj.validateDescendants();
- currentFObj.end();
} catch (final FOTreeException e) {
throw new SAXException(e);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractFlow.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -60,13 +60,6 @@
}
}
- /**
- * {@inheritDoc}
- */
- protected void validateDescendants() throws FOTreeException {
- return;
- }
-
public boolean isRAGenerator() {
return true;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/AbstractPageMaster.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -60,11 +60,4 @@
}
}
- /**
- * {@inheritDoc}
- */
- protected void validateDescendants() throws FOTreeException {
- return;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Bookmark.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Bookmark.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Bookmark.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -83,10 +83,6 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
- }
-
- public void end() throws FOTreeException {
// Validate that the first child is a Label.
if (children == null
|| children.size() < 1
@@ -108,6 +104,9 @@
}
}
+ public void end() throws FOTreeException {
+ }
+
public Bookmark getParentOutline(final FOContext context) {
for (FONode node = (FONode) getParent();
node != null; node = node.effectiveParent(context)) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTitle.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -70,11 +70,6 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
- }
-
- public void end() throws FOTreeException {
- super.end();
/* Validate children. Content Model: (#PCDATA)
* Must have exactly one child, an FOText instance. */
if (this.children.size() != 1) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTree.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTree.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/BookmarkTree.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -71,10 +71,6 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
- }
-
- public void end() throws FOTreeException {
// Validate that all children are Bookmark instances.
for (int i = 1; i < children.size(); i++) {
final FObj child = (FObj) children.get(i);
@@ -85,6 +81,10 @@
}
}
+ public void end() throws FOTreeException {
+ return;
+ }
+
public String getName() {
return "bookmark-tree";
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Flow.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Flow.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Flow.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -50,6 +50,13 @@
}
public void end() throws FOTreeException {
+ return;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void validateDescendants() throws FOTreeException {
boolean anyBlockContent = false;
for (int i = 0; i < getChildren().size(); i++) {
/* Cast to FObj should be OK, because it is not possible to create
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Footnote.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Footnote.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Footnote.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -63,11 +63,24 @@
return;
}
+ public void end() throws FOTreeException {
+ return;
+ }
+
/**
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
+ if (this.children.size() != 2) {
+ throwException("fo:footnote requires exactly two children.");
+ }
+ if (! (this.children.get(0) instanceof Inline)) {
+ throwException("First child of fo:footnote must be an fo:inline.");
+ }
+ if (! (this.children.get(1) instanceof FootnoteBody)) {
+ throwException("Second child of fo:footnote must be an "
+ + "fo:footnote-body.");
+ }
}
public String getName() {
@@ -86,19 +99,6 @@
return true;
}
- public void end() throws FOTreeException {
- if (this.children.size() != 2) {
- throwException("fo:footnote requires exactly two children.");
- }
- if (! (this.children.get(0) instanceof Inline)) {
- throwException("First child of fo:footnote must be an fo:inline.");
- }
- if (! (this.children.get(1) instanceof FootnoteBody)) {
- throwException("Second child of fo:footnote must be an "
- + "fo:footnote-body.");
- }
- }
-
public org.axsl.foR.fo.Inline getInline() {
/* Cast and index are guaranteed in the end() method. */
return (Inline) this.children.get(0);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/InstreamForeignObject.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/InstreamForeignObject.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/InstreamForeignObject.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -70,14 +70,14 @@
return;
}
+ public void end() throws FOTreeException {
+ return;
+ }
+
/**
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
- }
-
- public void end() throws FOTreeException {
/*
* XSL-FO Standard 1.1, Section 6.6.6, Heading "Contents" seems to
* indicate that only one child is allowed.
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListBlock.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListBlock.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListBlock.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -67,7 +67,16 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
+ if (this.getChildCount() < 1) {
+ this.throwException("fo:list-block must have at least one child.");
+ }
+ for (int i = 0; i < this.getChildren().size(); i++) {
+ final FObj fobj = (FObj) this.getChildAt(i);
+ if (! (fobj instanceof ListItem)) {
+ this.throwException("Child of fo:list-block must be "
+ + "fo:list-item", fobj.getContextMessage());
+ }
+ }
}
public String getName() {
@@ -83,16 +92,7 @@
}
public void end() throws FOTreeException {
- if (this.getChildCount() < 1) {
- this.throwException("fo:list-block must have at least one child.");
- }
- for (int i = 0; i < this.getChildren().size(); i++) {
- final FObj fobj = (FObj) this.getChildAt(i);
- if (! (fobj instanceof ListItem)) {
- this.throwException("Child of fo:list-block must be "
- + "fo:list-item", fobj.getContextMessage());
- }
- }
+ return;
}
public FONodeProxy makeProxy(final ProxyFactory factory) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListItem.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListItem.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/ListItem.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -68,10 +68,6 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
- }
-
- public void end() throws FOTreeException {
if (getChildren().size() != 2) {
throwException(getFullName() + " must have exactly two children.");
}
@@ -85,6 +81,10 @@
}
}
+ public void end() throws FOTreeException {
+ return;
+ }
+
/**
* Override the FObj method, because this is a ListItem instance.
*/
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequence.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -90,7 +90,9 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
+ if (flow == null) {
+ throwException(getFullName() + "has no flow.");
+ }
}
/**
@@ -103,9 +105,7 @@
}
public void end() throws FOTreeException {
- if (flow == null) {
- throwException(getFullName() + "has no flow.");
- }
+ return;
}
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-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/PageSequenceMaster.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -89,11 +89,7 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
- }
-
- public void end() throws FOTreeException {
- /* Validate children. Every child should be a SubSequenceSpecifier. */
+ /* Every child should be a SubSequenceSpecifier. */
if (this.children.size() < 1) {
this.throwException(getFullName() + "must have at least one "
+ "sub-sequence specifier.");
@@ -110,6 +106,9 @@
}
}
+ public void end() throws FOTreeException {
+ }
+
/**
* The parent.
*
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -63,6 +63,13 @@
}
protected void end() throws FOTreeException {
+ return;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void validateDescendants() throws FOTreeException {
if (getRegionBody() == null) {
throwException(getFullName() + " must have an fo:region-body.");
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/StaticContent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/StaticContent.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/StaticContent.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -50,6 +50,13 @@
}
public void end() throws FOTreeException {
+ return;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void validateDescendants() throws FOTreeException {
boolean anyBlockContent = false;
for (int i = 0; i < getChildren().size(); i++) {
/* Cast to FObj should be OK, because it is not possible to create
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Table.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Table.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/Table.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -84,14 +84,6 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
- }
-
- public String getName() {
- return "table";
- }
-
- public void end() throws FOTreeException {
final ArrayList columns = new ArrayList();
boolean doneWithMarkers = false;
boolean doneWithColumns = false;
@@ -140,6 +132,14 @@
}
}
+ public String getName() {
+ return "table";
+ }
+
+ public void end() throws FOTreeException {
+ return;
+ }
+
/**
* @param nextColumnNumber
* @param c
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/TableCell.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/TableCell.java 2006-09-03 17:01:34 UTC (rev 7864)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/TableCell.java 2006-09-03 17:55:15 UTC (rev 7865)
@@ -71,7 +71,18 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FOTreeException {
- return;
+ if (this.children.size() < 1) {
+ this.throwException(getFullName()
+ + " must have at least one child");
+ }
+ /* The content model requires that all children be %block content. */
+ for (int i = 0; i < this.children.size(); i++) {
+ final FObj fobj = (FObj) this.children.get(i);
+ if (! fobj.isContentBlock()) {
+ this.throwException(fobj.getContextMessage(),
+ "Child of " + getFullName() + " must be %block.");
+ }
+ }
}
public String getName() {
@@ -134,18 +145,6 @@
}
public void end() throws FOTreeException {
- if (this.children.size() < 1) {
- this.throwException(getFullName()
- + " must have at least one child");
- }
- /* The content model requires that all children be %block content. */
- for (int i = 0; i < this.children.size(); i++) {
- final FObj fobj = (FObj) this.children.get(i);
- if (! fobj.isContentBlock()) {
- this.throwException(fobj.getContextMessage(),
- "Child of " + getFullName() + " must be %block.");
- }
- }
}
public FONodeProxy makeProxy(final ProxyFactory factory) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|