diff options
author | Andreas L. Delmelle <adelmelle@apache.org> | 2008-05-03 10:55:07 +0000 |
---|---|---|
committer | Andreas L. Delmelle <adelmelle@apache.org> | 2008-05-03 10:55:07 +0000 |
commit | df1a55e4c7d582228dda8a527ff288d6d44b8958 (patch) | |
tree | 1b38fd909f0e7521de95510bc68ddb83b9a7cfab | |
parent | 6baa2824e1bbcc09ee4267c30b0456b5f70074e2 (diff) | |
download | xmlgraphics-fop-df1a55e4c7d582228dda8a527ff288d6d44b8958.tar.gz xmlgraphics-fop-df1a55e4c7d582228dda8a527ff288d6d44b8958.zip |
Tweaks: make fobj member final; have default implementations for some methods throw an UnsupportedOperationException instead of merely logging an error
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@653048 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java index c5e0ddfc9..a5af4c167 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java @@ -29,7 +29,7 @@ import org.apache.fop.fo.FObj; * The base class for nearly all LayoutManagers. * Provides the functionality for merging the {@link LayoutManager} * and the {@link org.apache.fop.datatypes.PercentBaseContext} interfaces - * into a common base calls for all higher LayoutManagers. + * into a common base class for all higher LayoutManagers. */ public abstract class AbstractBaseLayoutManager implements LayoutManager, PercentBaseContext { @@ -39,7 +39,7 @@ public abstract class AbstractBaseLayoutManager /** Indicator if this LM generates block areas */ protected boolean generatesBlockArea = false; /** The formatting object for this LM */ - protected FObj fobj = null; + protected final FObj fobj; /** * logging instance @@ -50,6 +50,7 @@ public abstract class AbstractBaseLayoutManager * Abstract base layout manager. */ public AbstractBaseLayoutManager() { + fobj = null; } /** @@ -67,9 +68,7 @@ public abstract class AbstractBaseLayoutManager // --------- Property Resolution related functions --------- // - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public int getBaseLength(int lengthBase, FObj fobj) { if (fobj == this.fobj) { switch (lengthBase) { @@ -82,7 +81,7 @@ public abstract class AbstractBaseLayoutManager case LengthBase.CONTAINING_REFAREA_WIDTH: return getReferenceAreaIPD(); default: - log.error(new Exception("Unknown base type for LengthBase:" + lengthBase)); + log.error("Unknown base type for LengthBase:" + lengthBase); return 0; } } else { @@ -112,9 +111,7 @@ public abstract class AbstractBaseLayoutManager } lm = lm.getParent(); } - if (lm == null) { - log.error("No parent LM found"); - } + log.error("No parent LM found"); return 0; } @@ -131,9 +128,7 @@ public abstract class AbstractBaseLayoutManager } lm = lm.getParent(); } - if (lm == null) { - log.error("No parent LM found"); - } + log.error("No parent LM found"); return 0; } @@ -176,9 +171,7 @@ public abstract class AbstractBaseLayoutManager } lm = lm.getParent(); } - if (lm == null) { - log.error("No parent LM found"); - } + log.error("No parent LM found"); return 0; } @@ -195,31 +188,31 @@ public abstract class AbstractBaseLayoutManager } lm = lm.getParent(); } - if (lm == null) { - log.error("No parent LM found"); - } + log.error("No parent LM found"); return 0; } /** * {@inheritDoc} + * <i>NOTE: Should be overridden by subclasses. + * Default implementation throws an <code>UnsupportedOperationException</code>.</i> */ public int getContentAreaIPD() { - log.error("getContentAreaIPD called when it should have been overwritten"); - return 0; + throw new UnsupportedOperationException( + "getContentAreaIPD() called when it should have been overridden"); } /** * {@inheritDoc} + * <i>NOTE: Should be overridden by subclasses. + * Default implementation throws an <code>UnsupportedOperationException</code>.</i> */ public int getContentAreaBPD() { - log.error("getContentAreaBPD called when it should have been overwritten"); - return 0; + throw new UnsupportedOperationException( + "getContentAreaBPD() called when it should have been overridden"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public boolean getGeneratesReferenceArea() { return generatesReferenceArea; } @@ -234,9 +227,7 @@ public abstract class AbstractBaseLayoutManager this.generatesReferenceArea = generatesReferenceArea; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public boolean getGeneratesBlockArea() { return generatesBlockArea; } @@ -250,9 +241,7 @@ public abstract class AbstractBaseLayoutManager this.generatesBlockArea = generatesBlockArea; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public boolean getGeneratesLineArea() { return false; } |