com.lowagie.text.rtf.field

Class RtfField

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 3373 2008-05-12 16:21:24Z xlv $

Author: Mark Hall (Mark.Hall@mail.room3b.eu) Dirk Weigenand (Dirk.Weigenand@smb-tec.com) Thomas Bickel (tmb99@inode.at)

Field Summary
protected RtfDocumentdocument
The RtfDocument this RtfField belongs to
booleanfieldAlt
Is it an alt field
booleanfieldDirty
Is the field dirty
booleanfieldEdit
Is the field edited
booleanfieldLocked
Is the field locked
booleanfieldPrivate
Is the field private
RtfFontfont
The RtfFont of this RtfField
static byte[]FIELD
Constant for a rtf field
static byte[]FIELD_ALT
Constant for an alt field
static byte[]FIELD_DIRTY
Constant for a dirty field
static byte[]FIELD_EDIT
Constant for a edited field
static byte[]FIELD_INSTRUCTIONS
Constant for the field instructions
static byte[]FIELD_LOCKED
Constant for a locked field
static byte[]FIELD_PRIVATE
Constant for a private field
static byte[]FIELD_RESULT
Constant for the field result
booleaninHeader
Whether this RtfElement is in a header
booleaninTable
Whether this RtfField is in a table
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
booleanisEmpty()
An RtfField is never empty.
booleanisFieldAlt()
Get whether this field is an alt field
booleanisFieldDirty()
Get whether this field is dirty
booleanisFieldEdit()
Get whether this field is edited
booleanisFieldLocked()
Get whether this field is locked
booleanisFieldPrivate()
Get whether this field is private
booleanisInHeader()
Gets whether this RtfField is in a header.
booleanisInTable()
Gets whether this RtfField is in a table.
voidsetFieldAlt(boolean fieldAlt)
Set whether this field is an alt field
voidsetFieldDirty(boolean fieldDirty)
Set whether this field is dirty
voidsetFieldEdit(boolean fieldEdit)
Set whether this field is edited.
voidsetFieldLocked(boolean fieldLocked)
Set whether this field is locked
voidsetFieldPrivate(boolean fieldPrivate)
Set whether this field is private
voidsetFont(Font font)
Override setFont to perform the correct font handling.
voidsetInHeader(boolean inHeader)
Sets whether this RtfField is in a header
voidsetInTable(boolean inTable)
Sets whether this RtfField is in a table
voidsetRtfDocument(RtfDocument doc)
Sets the RtfDocument this RtfElement belongs to
voidwriteContent(OutputStream result)
Writes the field to the OutputStream.
voidwriteFieldBegin(OutputStream result)
Writes the field beginning.
voidwriteFieldEnd(OutputStream result)
Writes the end of the field
voidwriteFieldInstBegin(OutputStream result)
Writes the beginning of the field instruction area.
protected abstract voidwriteFieldInstContent(OutputStream result)
Writes the content of the field instruction area.
voidwriteFieldInstEnd(OutputStream result)
Writes the end of the field instruction area.
voidwriteFieldResultBegin(OutputStream result)
Writes the beginning of the field result area
protected abstract voidwriteFieldResultContent(OutputStream result)
Writes the content of the pre-calculated field result.
voidwriteFieldResultEnd(OutputStream result)
Writes the end of the field result area

Field Detail

document

protected RtfDocument document
The RtfDocument this RtfField belongs to

fieldAlt

private boolean fieldAlt
Is it an alt field

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

font

private RtfFont font
The RtfFont of this RtfField

FIELD

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

FIELD_ALT

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

FIELD_DIRTY

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

FIELD_EDIT

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

FIELD_INSTRUCTIONS

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

FIELD_LOCKED

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

FIELD_PRIVATE

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

FIELD_RESULT

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

inHeader

private boolean inHeader
Whether this RtfElement is in a header

inTable

private boolean inTable
Whether this RtfField is in a table

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

isEmpty

public boolean isEmpty()
An RtfField is never empty.

isFieldAlt

public boolean isFieldAlt()
Get whether this field is an alt field

Returns: Returns whether this field is an alt field

isFieldDirty

public boolean isFieldDirty()
Get whether this field is dirty

Returns: Returns whether this field is dirty

isFieldEdit

public boolean isFieldEdit()
Get whether this field is edited

Returns: Returns whether this field is edited

isFieldLocked

public boolean isFieldLocked()
Get whether this field is locked

Returns: Returns the fieldLocked.

isFieldPrivate

public boolean isFieldPrivate()
Get whether this field is private

Returns: Returns the fieldPrivate.

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

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

setFieldAlt

public void setFieldAlt(boolean fieldAlt)
Set whether this field is an alt field

Parameters: fieldAlt The value to use

setFieldDirty

public void setFieldDirty(boolean fieldDirty)
Set whether this field is dirty

Parameters: fieldDirty The value to use

setFieldEdit

public void setFieldEdit(boolean fieldEdit)
Set whether this field is edited.

Parameters: fieldEdit The value to use

setFieldLocked

public void setFieldLocked(boolean fieldLocked)
Set whether this field is locked

Parameters: fieldLocked The value to use

setFieldPrivate

public void setFieldPrivate(boolean fieldPrivate)
Set whether this field is private

Parameters: fieldPrivate The value to use

setFont

public void setFont(Font font)
Override setFont to perform the correct font handling.

setInHeader

public void setInHeader(boolean inHeader)
Sets whether this RtfField is in a header

Parameters: inHeader True if this RtfField is in a header, false otherwise

setInTable

public void setInTable(boolean inTable)
Sets whether this RtfField is in a table

Parameters: inTable True if this RtfField is in a table, false otherwise

setRtfDocument

public void setRtfDocument(RtfDocument doc)
Sets the RtfDocument this RtfElement belongs to

Parameters: doc The RtfDocument to use

writeContent

public void writeContent(OutputStream result)
Writes the field to the OutputStream.

Parameters: result The OutputStream to write to.

Throws: IOException on i/o errors.

writeFieldBegin

private void writeFieldBegin(OutputStream result)
Writes the field beginning. Also writes field properties.

Parameters: result The OutputStream to write to.

Throws: IOException

writeFieldEnd

private void writeFieldEnd(OutputStream result)
Writes the end of the field

Parameters: result The OutputStream to write to.

Throws: IOException on i/o errors.

writeFieldInstBegin

private void writeFieldInstBegin(OutputStream result)
Writes the beginning of the field instruction area.

Parameters: result The OutputStream to write to.

Throws: IOException

writeFieldInstContent

protected abstract void writeFieldInstContent(OutputStream result)
Writes the content of the field instruction area. Override this method in your subclasses.

Parameters: result The OutputStream to write to.

writeFieldInstEnd

private void writeFieldInstEnd(OutputStream result)
Writes the end of the field instruction area.

Parameters: result The OutputStream to write to.

writeFieldResultBegin

private void writeFieldResultBegin(OutputStream result)
Writes the beginning of the field result area

Parameters: result The OutputStream to write to.

writeFieldResultContent

protected abstract void writeFieldResultContent(OutputStream result)
Writes the content of the pre-calculated field result. Override this method in your subclasses.

Parameters: result The OutputStream to write to.

Throws: IOException on i/o errors.

writeFieldResultEnd

private void writeFieldResultEnd(OutputStream result)
Writes the end of the field result area

Parameters: result The OutputStream to write to.

Throws: IOException on i/o errors.