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) {
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);
}
}
}
*/
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 {
/** 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()) {
*/
}
- 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();
}
/** 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();
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;