org.apache.fop.render.rtf.rtflib.rtfdoc

## Class RtfElement

- java.lang.Object
- - org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement

- Direct Known Subclasses:
    RtfBookmark, RtfContainer, RtfExternalGraphic, RtfGenerator, RtfLineBreak, RtfPageBreak, RtfParagraphBreak, RtfString, RtfText

      public abstract class RtfElement
      extends Object

  Base class for all elements of an RTF file.

  This work was authored by Bertrand Delacretaz (bdelacretaz@codeconsult.ch) and Andreas Putz (a.putz@skynamics.com).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RtfAttributes` | `attrib` attributes of the element
    `protected RtfContainer` | `parent` parent element
    `protected Writer` | `writer` Writer to be used

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Does nothing, meant to allow elements to write themselves without waiting for write(), but not implemented yet
    `RtfElement` | `getParentOfClass(Class c)` find the first parent where c.isAssignableFrom(parent.getClass()) is true
    `RtfAttributes` | `getRtfAttributes()` Added by Normand Masse Used for attribute inheritance
    `abstract boolean` | `isEmpty()`
    `void` | `newLine()` Starts a new line in the RTF file being written.
    `protected boolean` | `okToWriteRtf()` can be overridden to suppress all RTF output
    `String` | `toString()` minimal debugging display
    `protected void` | `writeAttributes(RtfAttributes attr, String[] nameList)` Write given attribute values to our Writer
    `protected void` | `writeControlWord(String word)` Write an RTF control word to our Writer
    `protected void` | `writeControlWordNS(String word)` Write rtf control word without the space behind it
    `protected void` | `writeExceptionInRtf(Exception ie)` Make a visible entry in the RTF for an exception
    `protected void` | `writeGroupMark(boolean isStart)` Write a start or end group mark
    `protected void` | `writeOneAttribute(String name, Object value)` Write one attribute to our Writer
    `protected void` | `writeOneAttributeNS(String name, Object value)` Write one attribute to our Writer without a space
    `void` | `writeRtf()` Write the RTF code of this element to our Writer
    `protected abstract void` | `writeRtfContent()` Must be implemented to write RTF content to m_writer
    `protected void` | `writeRtfPrefix()` Called before writeRtfContent()
    `protected void` | `writeRtfSuffix()` Called after writeRtfContent()
    `protected void` | `writeStarControlWord(String word)` Write an RTF control word to our Writer, preceeded by a star '*' meaning "ignore this if you don't know what it means"
    `protected void` | `writeStarControlWordNS(String word)` Same as writeStarControlWord(String word), except with no space behind it

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### writer

          protected final Writer writer

      Writer to be used

    - #### parent

          protected final RtfContainer parent

      parent element

    - #### attrib

          protected final RtfAttributes attrib

      attributes of the element

  - ### Method Detail

    - #### close

          public final void close()
                           throws IOException

      Does nothing, meant to allow elements to write themselves without waiting for write(), but not implemented yet
      Throws:
        `IOException` - for I/O problems

    - #### writeRtf

          public final void writeRtf()
                              throws IOException

      Write the RTF code of this element to our Writer
      Throws:
        `IOException` - for I/O problems

    - #### newLine

          public void newLine()
                       throws IOException

      Starts a new line in the RTF file being written. This is only to format the RTF file itself (for easier debugging), not its content.
      Throws:
        `IOException` - in case of an I/O problem

    - #### writeControlWord

          protected final void writeControlWord(String word)
                                         throws IOException

      Write an RTF control word to our Writer
      Parameters:
        `word` - RTF control word to write
      Throws:
        `IOException` - for I/O problems

    - #### writeStarControlWord

          protected final void writeStarControlWord(String word)
                                             throws IOException

      Write an RTF control word to our Writer, preceeded by a star '*' meaning "ignore this if you don't know what it means"
      Parameters:
        `word` - RTF control word to write
      Throws:
        `IOException` - for I/O problems

    - #### writeStarControlWordNS

          protected final void writeStarControlWordNS(String word)
                                               throws IOException

      Same as writeStarControlWord(String word), except with no space behind it
      Parameters:
        `word` - RTF control word to write
      Throws:
        `IOException` - for I/O problems

    - #### writeControlWordNS

          protected final void writeControlWordNS(String word)
                                           throws IOException

      Write rtf control word without the space behind it
      Parameters:
        `word` - RTF control word to write
      Throws:
        `IOException` - for I/O problems

    - #### writeRtfPrefix

          protected void writeRtfPrefix()
                                 throws IOException

      Called before writeRtfContent()
      Throws:
        `IOException` - for I/O problems

    - #### writeRtfContent

          protected abstract void writeRtfContent()
                                           throws IOException

      Must be implemented to write RTF content to m_writer
      Throws:
        `IOException` - for I/O problems

    - #### writeRtfSuffix

          protected void writeRtfSuffix()
                                 throws IOException

      Called after writeRtfContent()
      Throws:
        `IOException` - for I/O problems

    - #### writeGroupMark

          protected final void writeGroupMark(boolean isStart)
                                       throws IOException

      Write a start or end group mark
      Parameters:
        `isStart` - set to true if this is a start mark
      Throws:
        `IOException` - for I/O problems

    - #### writeAttributes

          protected void writeAttributes(RtfAttributes attr,
                                         String[] nameList)
                                  throws IOException

      Write given attribute values to our Writer
      Parameters:
        `attr` - RtfAttributes to be written
        `nameList` - if given, only attribute names from this list are considered
      Throws:
        `IOException` - for I/O problems

    - #### writeOneAttribute

          protected void writeOneAttribute(String name,
                                           Object value)
                                    throws IOException

      Write one attribute to our Writer
      Parameters:
        `name` - name of attribute to write
        `value` - value of attribute to be written
      Throws:
        `IOException` - for I/O problems

    - #### writeOneAttributeNS

          protected void writeOneAttributeNS(String name,
                                             Object value)
                                      throws IOException

      Write one attribute to our Writer without a space
      Parameters:
        `name` - name of attribute to write
        `value` - value of attribute to be written
      Throws:
        `IOException` - for I/O problems

    - #### okToWriteRtf

          protected boolean okToWriteRtf()

      can be overridden to suppress all RTF output
      Returns:
        true if this object can be written into the RTF

    - #### toString

          public String toString()

      minimal debugging display
      Overrides:
        `toString` in class `Object`
      Returns:
        String representation of object

    - #### getParentOfClass

          public RtfElement getParentOfClass(Class c)

      find the first parent where c.isAssignableFrom(parent.getClass()) is true
      Returns:
        null if not found

    - #### isEmpty

          public abstract boolean isEmpty()

      Returns:
        true if this element would generate no "useful" RTF content

    - #### writeExceptionInRtf

          protected void writeExceptionInRtf(Exception ie)
                                      throws IOException

      Make a visible entry in the RTF for an exception
      Parameters:
        `ie` - Exception to flag
      Throws:
        `IOException` - for I/O problems

    - #### getRtfAttributes

          public RtfAttributes getRtfAttributes()

      Added by Normand Masse Used for attribute inheritance
      Returns:
        RtfAttributes

Copyright © 2023 Apache Software Foundation. All rights reserved.