Class RtfField

  • All Implemented Interfaces:
    Element, RtfBasicElement, RtfElementInterface
    Direct Known Subclasses:
    RtfAnchor, RtfPageNumber, RtfTableOfContents, RtfTOCEntry, RtfTotalPageNumber

    public abstract class RtfField
    extends Chunk
    implements RtfBasicElement
    The RtfField class is an abstract base class for all rtf field functionality. Subclasses only need to implement the two abstract methods writeFieldInstContent and writeFieldResultContent. All other field functionality is handled by the RtfField class.
    Version:
    $Id: RtfField.java 3580 2008-08-06 15:52:00Z howard_s $
    Author:
    Mark Hall (Mark.Hall@mail.room3b.eu), Dirk Weigenand (Dirk.Weigenand@smb-tec.com), Thomas Bickel (tmb99@inode.at)
    • Field Detail

      • FIELD

        private static final byte[] FIELD
        Constant for a rtf field
      • FIELD_DIRTY

        private static final byte[] FIELD_DIRTY
        Constant for a dirty field
      • FIELD_PRIVATE

        private static final byte[] FIELD_PRIVATE
        Constant for a private field
      • FIELD_LOCKED

        private static final byte[] FIELD_LOCKED
        Constant for a locked field
      • FIELD_EDIT

        private static final byte[] FIELD_EDIT
        Constant for a edited field
      • FIELD_ALT

        private static final byte[] FIELD_ALT
        Constant for an alt field
      • FIELD_INSTRUCTIONS

        private static final byte[] FIELD_INSTRUCTIONS
        Constant for the field instructions
      • FIELD_RESULT

        private static final byte[] FIELD_RESULT
        Constant for the field result
      • fieldDirty

        private boolean fieldDirty
        Is the field dirty
      • fieldEdit

        private boolean fieldEdit
        Is the field edited
      • fieldLocked

        private boolean fieldLocked
        Is the field locked
      • fieldPrivate

        private boolean fieldPrivate
        Is the field private
      • fieldAlt

        private boolean fieldAlt
        Is it an alt field
      • inTable

        private boolean inTable
        Whether this RtfField is in a table
      • inHeader

        private boolean inHeader
        Whether this RtfElement is in a header
      • document

        protected RtfDocument document
        The RtfDocument this RtfField belongs to
      • font

        private RtfFont font
        The RtfFont of this RtfField
    • Constructor Detail

      • RtfField

        protected RtfField​(RtfDocument doc)
        Constructs a RtfField for a RtfDocument. This is not very useful, since the RtfField by itself does not do anything. Use one of the subclasses instead.
        Parameters:
        doc - The RtfDocument this RtfField belongs to.
      • RtfField

        protected RtfField​(RtfDocument doc,
                           Font font)
        Constructs a RtfField for a RtfDocument. This is not very useful, since the RtfField by itself does not do anything. Use one of the subclasses instead.
        Parameters:
        doc - The RtfDocument this RtfField belongs to.
        font - The Font this RtfField should use
    • Method Detail

      • setRtfDocument

        public void setRtfDocument​(RtfDocument doc)
        Sets the RtfDocument this RtfElement belongs to
        Specified by:
        setRtfDocument in interface RtfBasicElement
        Parameters:
        doc - The RtfDocument to use
      • writeFieldBegin

        private void writeFieldBegin​(java.io.OutputStream result)
                              throws java.io.IOException
        Writes the field beginning. Also writes field properties.
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException
      • writeFieldInstBegin

        private void writeFieldInstBegin​(java.io.OutputStream result)
                                  throws java.io.IOException
        Writes the beginning of the field instruction area.
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException
      • writeFieldInstContent

        protected abstract void writeFieldInstContent​(java.io.OutputStream result)
                                               throws java.io.IOException
        Writes the content of the field instruction area. Override this method in your subclasses.
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException
      • writeFieldInstEnd

        private void writeFieldInstEnd​(java.io.OutputStream result)
                                throws java.io.IOException
        Writes the end of the field instruction area.
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException
      • writeFieldResultBegin

        private void writeFieldResultBegin​(java.io.OutputStream result)
                                    throws java.io.IOException
        Writes the beginning of the field result area
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException
      • writeFieldResultContent

        protected abstract void writeFieldResultContent​(java.io.OutputStream result)
                                                 throws java.io.IOException
        Writes the content of the pre-calculated field result. Override this method in your subclasses.
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException - on i/o errors.
      • writeFieldResultEnd

        private void writeFieldResultEnd​(java.io.OutputStream result)
                                  throws java.io.IOException
        Writes the end of the field result area
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException - on i/o errors.
      • writeFieldEnd

        private void writeFieldEnd​(java.io.OutputStream result)
                            throws java.io.IOException
        Writes the end of the field
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException - on i/o errors.
      • writeContent

        public void writeContent​(java.io.OutputStream result)
                          throws java.io.IOException
        Writes the field to the OutputStream.
        Specified by:
        writeContent in interface RtfBasicElement
        Parameters:
        result - The OutputStream to write to.
        Throws:
        java.io.IOException - on i/o errors.
      • isFieldAlt

        public boolean isFieldAlt()
        Get whether this field is an alt field
        Returns:
        Returns whether this field is an alt field
      • setFieldAlt

        public void setFieldAlt​(boolean fieldAlt)
        Set whether this field is an alt field
        Parameters:
        fieldAlt - The value to use
      • isFieldDirty

        public boolean isFieldDirty()
        Get whether this field is dirty
        Returns:
        Returns whether this field is dirty
      • setFieldDirty

        public void setFieldDirty​(boolean fieldDirty)
        Set whether this field is dirty
        Parameters:
        fieldDirty - The value to use
      • isFieldEdit

        public boolean isFieldEdit()
        Get whether this field is edited
        Returns:
        Returns whether this field is edited
      • setFieldEdit

        public void setFieldEdit​(boolean fieldEdit)
        Set whether this field is edited.
        Parameters:
        fieldEdit - The value to use
      • isFieldLocked

        public boolean isFieldLocked()
        Get whether this field is locked
        Returns:
        Returns the fieldLocked.
      • setFieldLocked

        public void setFieldLocked​(boolean fieldLocked)
        Set whether this field is locked
        Parameters:
        fieldLocked - The value to use
      • isFieldPrivate

        public boolean isFieldPrivate()
        Get whether this field is private
        Returns:
        Returns the fieldPrivate.
      • setFieldPrivate

        public void setFieldPrivate​(boolean fieldPrivate)
        Set whether this field is private
        Parameters:
        fieldPrivate - The value to use
      • setInTable

        public void setInTable​(boolean inTable)
        Sets whether this RtfField is in a table
        Specified by:
        setInTable in interface RtfBasicElement
        Parameters:
        inTable - True if this RtfField is in a table, false otherwise
      • isInTable

        public boolean isInTable()
        Gets whether this RtfField is in a table.
        Returns:
        True if this RtfField is in a table, false otherwise
        Since:
        2.1.0
      • setInHeader

        public void setInHeader​(boolean inHeader)
        Sets whether this RtfField is in a header
        Specified by:
        setInHeader in interface RtfBasicElement
        Parameters:
        inHeader - True if this RtfField is in a header, false otherwise
      • isInHeader

        public boolean isInHeader()
        Gets whether this RtfField is in a header.
        Returns:
        True if this RtfField is in a header, false otherwise
        Since:
        2.1.0
      • isEmpty

        public boolean isEmpty()
        An RtfField is never empty.
        Overrides:
        isEmpty in class Chunk
        Returns:
        false if the Chunk contains other characters than space.
      • setFont

        public void setFont​(Font font)
        Override setFont to perform the correct font handling.
        Overrides:
        setFont in class Chunk
        Parameters:
        font - a Font