com.lowagie.text.rtf.field
Class RtfField

java.lang.Object
  extended by com.lowagie.text.Chunk
      extended by com.lowagie.text.rtf.field.RtfField
All Implemented Interfaces:
Element, RtfBasicElement
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 2932 2007-09-12 11:17:02Z blowagie $
Author:
Mark Hall (mhall@edu.uni-klu.ac.at), Dirk Weigenand (Dirk.Weigenand@smb-tec.com), Thomas Bickel (tmb99@inode.at)

Field Summary
protected  RtfDocument document
          The RtfDocument this RtfField belongs to
private static byte[] FIELD
          Constant for a rtf field
private static byte[] FIELD_ALT
          Constant for an alt field
private static byte[] FIELD_DIRTY
          Constant for a dirty field
private static byte[] FIELD_EDIT
          Constant for a edited field
private static byte[] FIELD_INSTRUCTIONS
          Constant for the field instructions
private static byte[] FIELD_LOCKED
          Constant for a locked field
private static byte[] FIELD_PRIVATE
          Constant for a private field
private static byte[] FIELD_RESULT
          Constant for the field result
private  boolean fieldAlt
          Is it an alt field
private  boolean fieldDirty
          Is the field dirty
private  boolean fieldEdit
          Is the field edited
private  boolean fieldLocked
          Is the field locked
private  boolean fieldPrivate
          Is the field private
private  RtfFont font
          The RtfFont of this RtfField
private  boolean inHeader
          Whether this RtfElement is in a header
private  boolean inTable
          Whether this RtfField is in a table
 
Fields inherited from class com.lowagie.text.Chunk
ACTION, attributes, BACKGROUND, COLOR, content, ENCODING, GENERICTAG, HSCALE, HYPHENATION, IMAGE, LOCALDESTINATION, LOCALGOTO, NEWLINE, NEWPAGE, NEXTPAGE, OBJECT_REPLACEMENT_CHARACTER, PDFANNOTATION, REMOTEGOTO, SKEW, SPLITCHARACTER, SUBSUPSCRIPT, TEXTRENDERMODE, UNDERLINE
 
Fields inherited from interface com.lowagie.text.rtf.RtfBasicElement
CLOSE_GROUP, COMMA_DELIMITER, DELIMITER, OPEN_GROUP, TWIPS_FACTOR
 
Fields inherited from interface com.lowagie.text.Element
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, HEADER, IMGRAW, IMGTEMPLATE, JPEG, JPEG2000, KEYWORDS, LIST, LISTITEM, MARKED, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE
 
Constructor Summary
protected RtfField(RtfDocument doc)
          Constructs a RtfField for a RtfDocument.
protected RtfField(RtfDocument doc, Font font)
          Constructs a RtfField for a RtfDocument.
 
Method Summary
 boolean isEmpty()
          An RtfField is never empty.
 boolean isFieldAlt()
          Get whether this field is an alt field
 boolean isFieldDirty()
          Get whether this field is dirty
 boolean isFieldEdit()
          Get whether this field is edited
 boolean isFieldLocked()
          Get whether this field is locked
 boolean isFieldPrivate()
          Get whether this field is private
 void setFieldAlt(boolean fieldAlt)
          Set whether this field is an alt field
 void setFieldDirty(boolean fieldDirty)
          Set whether this field is dirty
 void setFieldEdit(boolean fieldEdit)
          Set whether this field is edited.
 void setFieldLocked(boolean fieldLocked)
          Set whether this field is locked
 void setFieldPrivate(boolean fieldPrivate)
          Set whether this field is private
 void setFont(Font font)
          Override setFont to perform the correct font handling.
 void setInHeader(boolean inHeader)
          Sets whether this RtfField is in a header
 void setInTable(boolean inTable)
          Sets whether this RtfField is in a table
 void setRtfDocument(RtfDocument doc)
          Sets the RtfDocument this RtfElement belongs to
 byte[] write()
          Deprecated. replaced by writeContent(OutputStream)
 void writeContent(java.io.OutputStream result)
          Writes the element content to the given output stream.
private  byte[] writeFieldBegin()
          Deprecated. replaced by writeFieldBegin(OutputStream)
private  void writeFieldBegin(java.io.OutputStream result)
          Writes the field beginning.
private  byte[] writeFieldEnd()
          Deprecated. replaced by writeFieldEnd(OutputStream)
private  void writeFieldEnd(java.io.OutputStream result)
          Writes the end of the field
private  byte[] writeFieldInstBegin()
          Deprecated. replaced by writeFieldInstBegin(OutputStream)
private  void writeFieldInstBegin(java.io.OutputStream result)
          Writes the beginning of the field instruction area.
protected abstract  byte[] writeFieldInstContent()
          Deprecated. replaced by writeFieldInstContent(OutputStream)
protected  void writeFieldInstContent(java.io.OutputStream out)
          Writes the content of the field instruction area.
private  byte[] writeFieldInstEnd()
          Deprecated. replaced by writeFieldInstEnd(OutputStream)
private  void writeFieldInstEnd(java.io.OutputStream result)
          Writes the end of the field instruction area.
private  byte[] writeFieldResultBegin()
          Deprecated. replaced by writeFieldResultBegin(OutputStream)
private  void writeFieldResultBegin(java.io.OutputStream result)
          Writes the beginning of the field result area
protected abstract  byte[] writeFieldResultContent()
          Deprecated. replaced by writeFieldResultContent(OutputStream)
protected  void writeFieldResultContent(java.io.OutputStream out)
          Writes the content of the pre-calculated field result.
private  byte[] writeFieldResultEnd()
          Deprecated. replaced by writeFieldResultEnd(OutputStream)
private  void writeFieldResultEnd(java.io.OutputStream result)
          Writes the end of the field result area
 
Methods inherited from class com.lowagie.text.Chunk
addToArray, append, content, font, getAttributes, getChunks, getContent, getFont, getHorizontalScaling, getImage, getKeySet, getTextRise, getWidthPoint, hasAttributes, process, setAction, setAnchor, setAnchor, setAnnotation, setAttributes, setBackground, setBackground, setGenericTag, setHorizontalScaling, setHyphenation, setLocalDestination, setLocalGoto, setNewPage, setRemoteGoto, setRemoteGoto, setSkew, setSplitCharacter, setTextRenderMode, setTextRise, setUnderline, setUnderline, toString, type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 byte[] writeFieldBegin()
                        throws java.io.IOException
Deprecated. replaced by writeFieldBegin(OutputStream)

Writes the field beginning. Also writes field properties.

Returns:
A byte array with the field beginning.
Throws:
java.io.IOException

writeFieldBegin

private void writeFieldBegin(java.io.OutputStream result)
                      throws java.io.IOException
Writes the field beginning. Also writes field properties.

Throws:
java.io.IOException

writeFieldInstBegin

private byte[] writeFieldInstBegin()
                            throws java.io.IOException
Deprecated. replaced by writeFieldInstBegin(OutputStream)

Writes the beginning of the field instruction area.

Returns:
The beginning of the field instruction area
Throws:
java.io.IOException

writeFieldInstBegin

private void writeFieldInstBegin(java.io.OutputStream result)
                          throws java.io.IOException
Writes the beginning of the field instruction area.

Throws:
java.io.IOException

writeFieldInstContent

protected abstract byte[] writeFieldInstContent()
                                         throws java.io.IOException
Deprecated. replaced by writeFieldInstContent(OutputStream)

Writes the content of the field instruction area. Override this method in your subclasses.

Returns:
The content of the field instruction area
Throws:
java.io.IOException - If an error occurs.

writeFieldInstContent

protected void writeFieldInstContent(java.io.OutputStream out)
                              throws java.io.IOException
Writes the content of the field instruction area. Override this method in your subclasses.

Throws:
java.io.IOException

writeFieldInstEnd

private byte[] writeFieldInstEnd()
                          throws java.io.IOException
Deprecated. replaced by writeFieldInstEnd(OutputStream)

Writes the end of the field instruction area.

Returns:
A byte array containing the end of the field instruction area
Throws:
java.io.IOException

writeFieldInstEnd

private void writeFieldInstEnd(java.io.OutputStream result)
                        throws java.io.IOException
Writes the end of the field instruction area.

Throws:
java.io.IOException

writeFieldResultBegin

private byte[] writeFieldResultBegin()
                              throws java.io.IOException
Deprecated. replaced by writeFieldResultBegin(OutputStream)

Writes the beginning of the field result area

Returns:
A byte array containing the beginning of the field result area
Throws:
java.io.IOException

writeFieldResultBegin

private void writeFieldResultBegin(java.io.OutputStream result)
                            throws java.io.IOException
Writes the beginning of the field result area

Throws:
java.io.IOException

writeFieldResultContent

protected abstract byte[] writeFieldResultContent()
                                           throws java.io.IOException
Deprecated. replaced by writeFieldResultContent(OutputStream)

Writes the content of the pre-calculated field result. Override this method in your subclasses.

Returns:
A byte array containing the field result
Throws:
java.io.IOException - If an error occurs

writeFieldResultContent

protected void writeFieldResultContent(java.io.OutputStream out)
                                throws java.io.IOException
Writes the content of the pre-calculated field result. Override this method in your subclasses.

Throws:
java.io.IOException

writeFieldResultEnd

private byte[] writeFieldResultEnd()
                            throws java.io.IOException
Deprecated. replaced by writeFieldResultEnd(OutputStream)

Writes the end of the field result area

Returns:
A byte array containing the end of the field result area
Throws:
java.io.IOException

writeFieldResultEnd

private void writeFieldResultEnd(java.io.OutputStream result)
                          throws java.io.IOException
Writes the end of the field result area

Throws:
java.io.IOException

writeFieldEnd

private byte[] writeFieldEnd()
                      throws java.io.IOException
Deprecated. replaced by writeFieldEnd(OutputStream)

Writes the end of the field

Returns:
A byte array containing the end of the field
Throws:
java.io.IOException

writeFieldEnd

private void writeFieldEnd(java.io.OutputStream result)
                    throws java.io.IOException
Writes the end of the field

Throws:
java.io.IOException

write

public byte[] write()
Deprecated. replaced by writeContent(OutputStream)

Write the content of this RtfField.

Specified by:
write in interface RtfBasicElement
Returns:
A byte array containing the content of this RtfField

writeContent

public void writeContent(java.io.OutputStream result)
                  throws java.io.IOException
Writes the element content to the given output stream.

Specified by:
writeContent in interface RtfBasicElement
Throws:
java.io.IOException

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

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

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