From e0ac3f2a8a6804f164f864a4188f173508348dfe Mon Sep 17 00:00:00 2001 From: William Victor Mote Date: Wed, 2 Jul 2003 16:13:29 +0000 Subject: [PATCH] style changes only, mostly javadoc comments and refactoring of names git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196558 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/rtf/rtflib/rtfdoc/RtfAttributes.java | 106 ++++++++++++------ .../fop/rtf/rtflib/rtfdoc/RtfBefore.java | 4 + .../fop/rtf/rtflib/rtfdoc/RtfBookmark.java | 4 +- .../rtfdoc/RtfBookmarkContainerImpl.java | 2 +- .../fop/rtf/rtflib/rtfdoc/RtfColorTable.java | 11 +- .../fop/rtf/rtflib/rtfdoc/RtfContainer.java | 72 +++++++----- 6 files changed, 131 insertions(+), 68 deletions(-) diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java index 6bd6e10bc..c48e2e5fe 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfAttributes.java @@ -70,10 +70,13 @@ import org.xml.sax.helpers.AttributesImpl; public class RtfAttributes implements java.lang.Cloneable { - private HashMap m_values = new HashMap(); + private HashMap values = new HashMap(); - /** set attributes from a other attributes object. - * @return this object, for chaining calls + /** + * Set attributes from another attributes object + * @param attrs RtfAttributes object whose elements will be copied into this + * instance + * @return this object, for chaining calls */ public RtfAttributes set (RtfAttributes attrs) { if (attrs != null) { @@ -106,100 +109,131 @@ implements java.lang.Cloneable { return this; } - /** set an attribute that has no value. - * @return this object, for chaining calls + /** + * set an attribute that has no value. + * @param name name of attribute to set + * @return this object, for chaining calls */ public RtfAttributes set(String name) { - m_values.put(name, null); + values.put(name, null); return this; } - /** unset an attribute that has no value - * @return this object, for chaining calls + /** + * unset an attribute that has no value + * @param name name of attribute to unset + * @return this object, for chaining calls */ public RtfAttributes unset(String name) { - m_values.remove(name); + values.remove(name); return this; } - /** debugging log */ + /** + * debugging log + * @return String representation of object + */ public String toString() { - return m_values.toString() + "(" + super.toString() + ")"; + return values.toString() + "(" + super.toString() + ")"; } - /** implement cloning */ + /** + * implement cloning + * @return cloned Object + */ public Object clone() { final RtfAttributes result = new RtfAttributes(); - result.m_values = (HashMap)m_values.clone(); + result.values = (HashMap)values.clone(); // Added by Normand Masse // indicate the XSL attributes used to build the Rtf attributes - if (m_xsl_attributes != null) { - result.m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl(m_xsl_attributes); + if (xslAttributes != null) { + result.xslAttributes = new org.xml.sax.helpers.AttributesImpl(xslAttributes); } return result; } - /** set an attribute that has an integer value - * @return this object, for chaining calls + /** + * Set an attribute that has an integer value + * @param name name of attribute + * @param value value of attribute + * @return this (which now contains the new entry), for chaining calls */ public RtfAttributes set(String name, int value) { - m_values.put(name, new Integer(value)); + values.put(name, new Integer(value)); return this; } + /** + * Set an attribute that has a String value + * @param name name of attribute + * @param type value of attribute + * @return this (which now contains the new entry) + */ public RtfAttributes set(String name, String type) { - m_values.put(name, type); + values.put(name, type); return this; } - /** get the value of an attribute, null if not found */ + /** + * @param name String containing attribute name + * @return the value of an attribute, null if not found + */ public Object getValue(String name) { - return m_values.get(name); + return values.get(name); } - /** true if given attribute is set */ + /** + * @param name String containing attribute name + * @return true if given attribute is set + */ public boolean isSet(String name) { - return m_values.containsKey(name); + return values.containsKey(name); } - /** return an Iterator on all names that are set */ + /** @return an Iterator on all names that are set */ public Iterator nameIterator() { - return m_values.keySet().iterator(); + return values.keySet().iterator(); } - private Attributes m_xsl_attributes = null; + private Attributes xslAttributes = null; - // Added by Normand Masse - // Used for attribute inheritance + /** + * Added by Normand Masse + * Used for attribute inheritance + * @return Attributes + */ public Attributes getXslAttributes() { - return m_xsl_attributes; + return xslAttributes; } - // Added by Normand Masse - // Used for attribute inheritance + /** + * Added by Normand Masse + * Used for attribute inheritance + * @param pAttribs attributes + */ public void setXslAttributes(Attributes pAttribs) { if (pAttribs == null) { return; } // copy/replace the xsl attributes into the current attributes - if (m_xsl_attributes != null) { + if (xslAttributes != null) { for (int i = 0; i < pAttribs.getLength(); i++) { String wKey = pAttribs.getQName(i); - int wPos = m_xsl_attributes.getIndex(wKey); + int wPos = xslAttributes.getIndex(wKey); if (wPos == -1) { - ((AttributesImpl)m_xsl_attributes).addAttribute(pAttribs.getURI(i), + ((AttributesImpl)xslAttributes).addAttribute(pAttribs.getURI(i), pAttribs.getLocalName(i), pAttribs.getQName(i), pAttribs.getType(i), pAttribs.getValue(i)); } else { - ((AttributesImpl)m_xsl_attributes).setAttribute(wPos, pAttribs.getURI(i), + ((AttributesImpl)xslAttributes).setAttribute(wPos, pAttribs.getURI(i), pAttribs.getLocalName(i), pAttribs.getQName(i), pAttribs.getType(i), pAttribs.getValue(i)); } } } else { - m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl(pAttribs); + xslAttributes = new org.xml.sax.helpers.AttributesImpl(pAttribs); } } } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java index 072d7c027..7046f5dec 100644 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBefore.java @@ -66,6 +66,7 @@ public class RtfBefore extends RtfAfterBeforeBase { /**RtfBefore attributes*/ public static final String HEADER = "header"; + /** String array of attribute names */ public static final String[] HEADER_ATTR = new String[]{ HEADER }; @@ -74,6 +75,9 @@ public class RtfBefore extends RtfAfterBeforeBase { super(parent, w, attrs); } + /** + * @see RtfAfterBeforeBase#writeMyAttributes + */ protected void writeMyAttributes() throws IOException { writeAttributes(attrib, HEADER_ATTR); } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java index 86d1cfd14..3323bf22f 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmark.java @@ -184,7 +184,9 @@ public class RtfBookmark extends RtfElement { this.writeGroupMark (false); } - /** true if this element would generate no "useful" RTF content */ + /** + * @return true if this element would generate no "useful" RTF content + */ public boolean isEmpty() { return bookmark == null || bookmark.trim().length() == 0; } diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java index d5f2f5649..2748a7cdc 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfBookmarkContainerImpl.java @@ -73,7 +73,7 @@ public class RtfBookmarkContainerImpl extends RtfContainer implements IRtfBookma ////////////////////////////////////////////////// /** Rtf bookmark */ - RtfBookmark mBookmark = null; + private RtfBookmark mBookmark = null; ////////////////////////////////////////////////// diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java index 2b1bce0ef..97843a592 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfColorTable.java @@ -74,9 +74,9 @@ public class RtfColorTable { ////////////////////////////////////////////////// // Defines the bit moving for the colors - private static int RED = 16; - private static int GREEN = 8; - private static int BLUE = 0; + private static final int RED = 16; + private static final int GREEN = 8; + private static final int BLUE = 0; ////////////////////////////////////////////////// @@ -164,8 +164,9 @@ public class RtfColorTable { // @@ Public methods ////////////////////////////////////////////////// - /** get the RTF number of a named color - * @return null if name not found + /** + * @param name a named color + * @return the RTF number of a named color, or null if name not found */ public Integer getColorNumber (String name) { return (Integer)namedColors.get(name.toLowerCase()); diff --git a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java index 566986fcf..c6fd4b9d5 100755 --- a/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java +++ b/src/java/org/apache/fop/rtf/rtflib/rtfdoc/RtfContainer.java @@ -70,9 +70,9 @@ import org.apache.fop.rtf.rtflib.exceptions.RtfStructureException; */ public class RtfContainer extends RtfElement { - private LinkedList m_children; // 'final' removed by Boris Poudérous on 07/22/2002 - private RtfOptions m_options = new RtfOptions(); - private RtfElement m_lastChild; + private LinkedList children; // 'final' removed by Boris Poudérous on 07/22/2002 + private RtfOptions options = new RtfOptions(); + private RtfElement lastChild; /** Create an RTF container as a child of given container */ RtfContainer(RtfContainer parent, Writer w) throws IOException { @@ -82,15 +82,22 @@ public class RtfContainer extends RtfElement { /** Create an RTF container as a child of given container with given attributes */ RtfContainer(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException { super(parent, w, attr); - m_children = new LinkedList(); + children = new LinkedList(); } - /** set options */ + /** + * set options + * @param opt options to set + */ public void setOptions(RtfOptions opt) { - m_options = opt; + options = opt; } - /** add a child element to this */ + /** + * add a child element to this + * @param e child element to add + * @throws RtfStructureException for trying to add an invalid child (??) + */ protected void addChild(RtfElement e) throws RtfStructureException { if (isClosed()) { @@ -116,37 +123,46 @@ public class RtfContainer extends RtfElement { */ } - m_children.add(e); - m_lastChild = e; + children.add(e); + lastChild = e; } - /** return a copy of our children's list */ + /** + * @return a copy of our children's list + */ public List getChildren() { - return (List)m_children.clone(); + return (List)children.clone(); } - /** return the number of children */ + /** + * @return the number of children + */ public int getChildCount() { - return m_children.size(); + return children.size(); } /** * Add by Boris Poudérous on 07/22/2002 * Set the children list + * @param children list of child objects + * @return true if process succeeded */ public boolean setChildren (List children) { if (children instanceof LinkedList) { - this.m_children = (LinkedList)children; + this.children = (LinkedList)children; return true; } return false; } - /** write RTF code of all our children */ + /** + * write RTF code of all our children + * @throws IOException for I/O problems + */ protected void writeRtfContent() throws IOException { - for (Iterator it = m_children.iterator(); it.hasNext();) { + for (Iterator it = children.iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); e.writeRtf(); } @@ -154,13 +170,13 @@ public class RtfContainer extends RtfElement { /** return our options */ RtfOptions getOptions() { - return m_options; + return options; } /** true if this (recursively) contains at least one RtfText object */ boolean containsText() { boolean result = false; - for (Iterator it = m_children.iterator(); it.hasNext();) { + for (Iterator it = children.iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); if (e instanceof RtfText) { result = !e.isEmpty(); @@ -180,32 +196,38 @@ public class RtfContainer extends RtfElement { void dump(Writer w, int indent) throws IOException { super.dump(w, indent); - for (Iterator it = m_children.iterator(); it.hasNext();) { + for (Iterator it = children.iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); e.dump(w, indent + 1); } } - /** minimal debugging display */ + /** + * minimal debugging display + * @return String representation of object contents + */ public String toString() { return super.toString() + " (" + getChildCount() + " children)"; } - /** don't write any RTF if empty of if our options block it */ + /** + * @return false if empty or if our options block writing + */ protected boolean okToWriteRtf() { boolean result = super.okToWriteRtf() && !isEmpty(); - if (result && !m_options.renderContainer(this)) { + if (result && !options.renderContainer(this)) { result = false; } return result; } - /** true if this element would generate no "useful" RTF content. - * For an RtfContainer, true if it has no children where isEmpty() is false + /** + * @return true if this element would generate no "useful" RTF content, + * i.e. (for RtfContainer) true if it has no children where isEmpty() is false */ public boolean isEmpty() { boolean result = true; - for (Iterator it = m_children.iterator(); it.hasNext();) { + for (Iterator it = children.iterator(); it.hasNext();) { final RtfElement e = (RtfElement)it.next(); if (!e.isEmpty()) { result = false; -- 2.39.5