<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
</Match>
<!-- Automatically generated list of exclusions -->
- <Match>
- <Class name="org.apache.fop.area.BodyRegion"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.area.Page"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.area.PageViewport"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.area.RegionReference"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.area.BodyRegion"/>
- <!--Neither method nor field-->
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.area.RegionViewport"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.hyphenation.CharVector"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.hyphenation.TernaryTree"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.hyphenation.HyphenationTree"/>
- <!--Neither method nor field-->
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
<Match>
<Class name="org.apache.fop.render.intermediate.IFGraphicContext"/>
<Method name="clone"/>
<Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
</Match>
- <Match>
- <Class name="org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes"/>
- <Method name="clone"/>
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
- <Match>
- <Class name="org.apache.fop.render.rtf.FOPRtfAttributes"/>
- <!--Neither method nor field-->
- <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
- </Match>
<Match>
<Class name="org.apache.fop.hyphenation.Hyphenator"/>
<Method name="getResourceStream"/>
<!--Neither method nor field-->
<Bug pattern="RI_REDUNDANT_INTERFACES"/>
</Match>
- <Match>
- <Class name="java.lang.Cloneable"/>
- <!--Neither method nor field-->
- <Bug pattern="RI_REDUNDANT_INTERFACES"/>
- </Match>
<Match>
<Class name="org.apache.fop.afp.modca.AbstractResourceGroupContainer"/>
<!--Neither method nor field-->
import java.io.Serializable;
import java.util.Map;
+import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
protected int bidiLevel = -1;
/**
- * Traits for this area stored in a HashMap
+ * Traits for this area.
*/
- protected transient Map<Integer, Object> traits = null;
+ protected TreeMap<Integer, Object> traits;
/**
* logging instance
return this.areaClass;
}
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ Area area = (Area) super.clone();
+ if (traits != null) {
+ area.traits = (TreeMap<Integer, Object>) traits.clone();
+ }
+ return area;
+ }
+
/**
* Set the area class of this area.
*
* @param prop the value of the trait
*/
public void addTrait(Integer traitCode, Object prop) {
- // use treemap instead of hashmap since the typical number
- // of traits are less than four
+ // use treemap since the typical number of traits are less than four
if (traits == null) {
- traits = new java.util.TreeMap<Integer, Object>();
+ traits = new TreeMap<Integer, Object>();
}
traits.put(traitCode, prop);
}
*/
public void setTraits ( Map traits ) {
if ( traits != null ) {
- this.traits = new java.util.TreeMap ( traits );
+ this.traits = new TreeMap<Integer, Object>( traits );
} else {
this.traits = null;
}
package org.apache.fop.area;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Abstract base class for all area tree objects.
*/
-public abstract class AreaTreeObject {
+public abstract class AreaTreeObject implements Cloneable {
/** Foreign attributes */
protected Map<QName, String> foreignAttributes = null;
/** Extension attachments */
protected List<ExtensionAttachment> extensionAttachments = null;
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ AreaTreeObject ato = (AreaTreeObject) super.clone();
+ if (foreignAttributes != null) {
+ ato.foreignAttributes = (Map) ((HashMap) foreignAttributes).clone();
+ }
+ if (extensionAttachments != null) {
+ ato.extensionAttachments = (List) ((ArrayList) extensionAttachments).clone();
+ }
+ return ato;
+ }
+
/**
* Sets a foreign attribute.
* @param name the qualified name of the attribute
*/
public void setForeignAttribute(QName name, String value) {
if (this.foreignAttributes == null) {
- this.foreignAttributes = new java.util.HashMap<QName, String>();
+ this.foreignAttributes = new HashMap<QName, String>();
}
this.foreignAttributes.put(name, value);
}
private void prepareExtensionAttachmentContainer() {
if (this.extensionAttachments == null) {
- this.extensionAttachments = new java.util.ArrayList<ExtensionAttachment>();
+ this.extensionAttachments = new ArrayList<ExtensionAttachment>();
}
}
}
}
- /**
- * Clone this object.
- *
- * @return a shallow copy of this object
- */
- public Object clone() {
- BodyRegion br = new BodyRegion(getRegionClass(), getRegionName(), regionViewport,
- getColumnCount(), getColumnGap());
- br.setCTM(getCTM());
- br.setIPD(getIPD());
- br.beforeFloat = beforeFloat;
- br.mainReference = mainReference;
- br.footnote = footnote;
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ BodyRegion br = (BodyRegion) super.clone();
+ br.mainReference = new MainReference(br);
return br;
}
+
}
* The page is cloneable so the page master can make copies of
* the top level page and regions.
*/
-public class Page extends AreaTreeObject implements Serializable, Cloneable {
+public class Page extends AreaTreeObject implements Serializable {
private static final long serialVersionUID = 6272157047421543866L;
private boolean fakeNonEmpty = false;
/**
- * Empty constructor, for cloning
+ * Empty constructor
*/
- public Page() {
- }
+ public Page() { }
/**
* Constructor
}
}
- /**
- * Clone this page.
- * This returns a new page with a clone of all the regions.
- *
- * @return a new clone of this page
- */
- public Object clone() {
- Page p = new Page();
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ Page p = (Page) super.clone();
if (regionBefore != null) {
p.regionBefore = (RegionViewport)regionBefore.clone();
}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.pagination.SimplePageMaster;
import org.apache.fop.traits.WritingModeTraitsGetter;
* This is the level that creates the page.
* The page (reference area) is then rendered inside the page object
*/
-public class PageViewport extends AreaTreeObject implements Resolvable, Cloneable {
+public class PageViewport extends AreaTreeObject implements Resolvable {
private Page page;
private Rectangle viewArea;
/**
* Copy constructor.
* @param original the original PageViewport to copy from
+ * @throws FOPException when cloning of the page is not supported
*/
- public PageViewport(PageViewport original) {
+ public PageViewport(PageViewport original) throws FOPException {
if (original.extensionAttachments != null) {
setExtensionAttachments(original.extensionAttachments);
}
this.pageIndex = original.pageIndex;
this.pageNumber = original.pageNumber;
this.pageNumberString = original.pageNumberString;
- this.page = (Page)original.page.clone();
+ try {
+ this.page = (Page) original.page.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new FOPException(e);
+ }
this.viewArea = new Rectangle(original.viewArea);
this.simplePageMasterName = original.simplePageMasterName;
this.blank = original.blank;
}
}
- /**
- * Clone this page.
- * Used by the page master to create a copy of an original page.
- * @return a copy of this page and associated viewports
- */
- public Object clone() {
- return new PageViewport(this);
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ PageViewport pvp = (PageViewport) super.clone();
+ pvp.page = (Page) page.clone();
+ pvp.viewArea = (Rectangle) viewArea.clone();
+ return pvp;
}
/**
* This area is the direct child of a region-viewport-area. It is cloneable
* so the page master can make copies from the original page and regions.
*/
-public class RegionReference extends Area implements Cloneable {
+public class RegionReference extends Area {
private static final long serialVersionUID = -298980963268244238L;
addChildArea(block);
}
- /**
- * Clone this region.
- * This is used when cloning the page by the page master.
- *
- * @return a copy of this region reference area
- */
- public Object clone() {
- RegionReference rr = new RegionReference(regionClass, regionName, regionViewport);
- rr.ctm = ctm;
- rr.setIPD(getIPD());
- rr.blocks = (ArrayList<Area>)blocks.clone();
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ RegionReference rr = (RegionReference) super.clone();
+ rr.blocks = (ArrayList) blocks.clone();
return rr;
}
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
-import java.util.HashMap;
import java.util.TreeMap;
import org.apache.fop.traits.WritingModeTraitsGetter;
* region-reference-area as its child. These areas are described
* in the fo:region-body description in the XSL Recommendation.
*/
-public class RegionViewport extends Area implements Cloneable, Viewport {
+public class RegionViewport extends Area implements Viewport {
private static final long serialVersionUID = 505781815165102572L;
setRegionReference((RegionReference) in.readObject());
}
- /**
- * Clone this region viewport.
- * Used when creating a copy from the page master.
- *
- * @return a new copy of this region viewport
- */
- public Object clone() {
- RegionViewport rv = new RegionViewport((Rectangle2D)viewArea.clone());
- rv.regionReference = (RegionReference)regionReference.clone();
- if (traits != null) {
- rv.traits = new TreeMap(traits);
- }
- if (foreignAttributes != null) {
- rv.foreignAttributes = new HashMap(foreignAttributes);
- }
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ RegionViewport rv = (RegionViewport) super.clone();
+ rv.regionReference = (RegionReference) regionReference.clone();
+ rv.viewArea = (Rectangle2D) viewArea.clone();
return rv;
}
}
/** {@inheritDoc} */
- public Object clone() {
- CharVector cv = new CharVector((char[])array.clone(), blockSize);
- cv.n = this.n;
+ public Object clone() throws CloneNotSupportedException {
+ CharVector cv = (CharVector) super.clone();
+ cv.array = (char[])array.clone();
return cv;
}
* patterns which will be keys in this tree. The strings patterns
* are usually small (from 2 to 5 characters), but each char in the
* tree is stored in a node. Thus memory usage is the main concern.
- * We will sacrify 'elegance' to keep memory requirenments to the
+ * We will sacrify 'elegance' to keep memory requirements to the
* minimum. Using java's char type as pointer (yes, I know pointer
* it is a forbidden word in java) we can keep the size of the node
* to be just 8 bytes (3 pointers and the data char). This gives
}
/** {@inheritDoc} */
- public Object clone() {
- TernaryTree t = new TernaryTree();
+ public Object clone() throws CloneNotSupportedException {
+ TernaryTree t = (TernaryTree) super.clone();
t.lo = (char[])this.lo.clone();
t.hi = (char[])this.hi.clone();
t.eq = (char[])this.eq.clone();
t.sc = (char[])this.sc.clone();
t.kv = (CharVector)this.kv.clone();
- t.root = this.root;
- t.freenode = this.freenode;
- t.length = this.length;
return t;
}
/**
* {@inheritDoc}
+ * @throws FOPException thrown by java2DRenderer
*/
- public void renderPage(PageViewport pageViewport) throws IOException {
+ public void renderPage(PageViewport pageViewport) throws IOException, FOPException {
super.renderPage(pageViewport);
if (statusListener != null) {
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
-import java.util.List;
+import java.util.ArrayList;
import org.apache.xmlgraphics.java2d.GraphicContext;
private static final AffineTransform[] EMPTY_TRANSFORM_ARRAY = new AffineTransform[0];
- private List groupList = new java.util.ArrayList();
+ private ArrayList groupList = new ArrayList();
/**
* Default constructor.
*/
protected IFGraphicContext(IFGraphicContext graphicContext) {
super(graphicContext);
- //We don't clone groupDepth!
+ // N.B. do not perform deep copy on groupList; doing so causes
+ // a junit regression... have not investigated cause... [GA]
+ // groupList = (ArrayList) graphicContext.groupList.clone();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public Object clone() {
- return new IFGraphicContext(this);
+ return new IFGraphicContext ( this );
}
/** @param group a group */
public void pushGroup(Group group) {
- //this.groupDepth++;
this.groupList.add(group);
for (int i = 0, c = group.getTransforms().length; i < c; i++) {
transform(group.getTransforms()[i]);
* @param pageViewport the <code>PageViewport</code> object supplied by
* the Area Tree
* @throws IOException In case of an I/O error
+ * @throws FOPException if cloning of pageViewport is not supported
* @see org.apache.fop.render.Renderer
*/
- public void renderPage(PageViewport pageViewport) throws IOException {
- rememberPage((PageViewport)pageViewport.clone());
+ public void renderPage(PageViewport pageViewport) throws IOException, FOPException {
+ try {
+ rememberPage((PageViewport)pageViewport.clone());
+ } catch (CloneNotSupportedException e) {
+ throw new FOPException(e);
+ }
//The clone() call is necessary as we store the page for later. Otherwise, the
//RenderPagesModel calls PageViewport.clear() to release memory as early as possible.
currentPageNumber++;
import java.io.IOException;
+import org.apache.fop.apps.FOPException;
+
/**
* <p>Interface for RtfElements that can contain RtfText elements.</p>
*
/**
* Text containers usually provide default attributes for all texts that they contain.
* @return a copy of the container's attributes.
+ * @throws FOPException if attributes cannot be obtained
*/
- RtfAttributes getTextContainerAttributes();
+ RtfAttributes getTextContainerAttributes() throws FOPException;
}
* <p>This work was authored by Bertrand Delacretaz (bdelacretaz@codeconsult.ch).</p>
*/
-public class RtfAttributes
-implements java.lang.Cloneable {
+public class RtfAttributes implements Cloneable {
+
private HashMap values = new HashMap();
/**
return values.toString() + "(" + super.toString() + ")";
}
- /**
- * implement cloning
- * @return cloned Object
- */
- public Object clone() {
- final RtfAttributes result = new RtfAttributes();
+ /** {@inheritDoc} */
+ public Object clone() throws CloneNotSupportedException {
+ RtfAttributes result = (RtfAttributes) super.clone();
result.values = (HashMap)values.clone();
// Added by Normand Masse
import java.io.IOException;
import java.io.Writer;
+import org.apache.fop.apps.FOPException;
+
/**
* <p>Creates an hyperlink.
* This class belongs to the <fo:basic-link> tag processing.</p>
/**
* IRtfTextContainer requirement:
* @return a copy of our attributes
+ * @throws FOPException if attributes cannot be cloned
*/
- public RtfAttributes getTextContainerAttributes() {
+ public RtfAttributes getTextContainerAttributes() throws FOPException {
if (attrib == null) {
return null;
}
- return (RtfAttributes) this.attrib.clone ();
+ try {
+ return (RtfAttributes) this.attrib.clone ();
+ } catch (CloneNotSupportedException e) {
+ throw new FOPException(e);
+ }
}
import java.io.Writer;
import java.util.List;
+import org.apache.fop.apps.FOPException;
+
/**
* <p>Model of an RTF paragraph, which can contain RTF text elements.</p>
*
/**
* IRtfTextContainer requirement: return a copy of our attributes
* @return a copy of this paragraphs attributes
+ * @throws FOPException if attributes cannot be cloned
*/
- public RtfAttributes getTextContainerAttributes() {
+ public RtfAttributes getTextContainerAttributes() throws FOPException {
if (attrib == null) {
return null;
}
- return (RtfAttributes)this.attrib.clone();
+ try {
+ return (RtfAttributes)this.attrib.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new FOPException(e);
+ }
}
/**
import java.io.IOException;
import java.io.Writer;
+import org.apache.fop.apps.FOPException;
+
/**
* <p>Container for RtfRow elements.</p>
*
* @param attrs attributs of new RtfTableRow
* @return new RtfTableRow
* @throws IOException for I/O problems
+ * @throws FOPException if attributes cannot be cloned
*/
- public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException {
+ public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException, FOPException {
RtfAttributes attr = null;
if (attrib != null) {
- attr = (RtfAttributes) attrib.clone ();
+ try {
+ attr = (RtfAttributes) attrib.clone ();
+ } catch (CloneNotSupportedException e) {
+ throw new FOPException(e);
+ }
attr.set (attrs);
} else {
attr = attrs;
import java.io.Writer;
import java.util.Iterator;
+import org.apache.fop.apps.FOPException;
+
/**
* <p>Container for RtfTableCell elements.</p>
*
* @param cellWidth width of new cell
* @return new RtfTableCell
* @throws IOException for I/O problems
+ * @throws FOPException if attributes cannot be cloned
*/
public RtfTableCell newTableCellMergedHorizontally (int cellWidth,
- RtfAttributes attrs) throws IOException {
+ RtfAttributes attrs) throws IOException, FOPException {
highestCell++;
// Added by Normand Masse
// Inherit attributes from base cell for merge
RtfAttributes wAttributes = null;
if (attrs != null) {
- wAttributes = (RtfAttributes)attrs.clone();
+ try {
+ wAttributes = (RtfAttributes)attrs.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new FOPException(e);
+ }
}
cell = new RtfTableCell(this, writer, cellWidth, wAttributes, highestCell);
import java.io.IOException;
import java.io.Writer;
+import org.apache.fop.apps.FOPException;
+
/**
* <p>Model of a text run (a piece of text with attributes) in an RTF document.</p>
*
}
/** IRtfTextContainer requirement:
- * @return a copy of our attributes */
- public RtfAttributes getTextContainerAttributes() {
+ * @return a copy of our attributes
+ * @throws FOPException if attributes cannot be cloned
+ */
+ public RtfAttributes getTextContainerAttributes() throws FOPException {
if (attrib == null) {
return null;
}
- return (RtfAttributes)this.attrib.clone();
+ try {
+ return (RtfAttributes)this.attrib.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new FOPException(e);
+ }
}
/** direct access to our text */
*/
private static boolean compareFileSize(File oldFile, File newFile) {
return oldFile.length() == newFile.length();
- } // end: compareBytes
+ }
private boolean filesExist(File oldFile, File newFile) {
if (!oldFile.exists()) {