ru.novosoft.dc.rtf.dom
Class RTFObject

java.lang.Object
  |
  +--ru.novosoft.dc.rtf.dom.RTFObject

public final class RTFObject
extends java.lang.Object
implements RTFInline, ActiveSymbols

An inline object of rtf-file. It consists of a kind, an object, and a character context of this object. The predefined kinds are the following:

ACTIVE
this object contains an active character. An active symbol can have a parameter. It is recommened to set codes for active symbols in correspondence with the ActiveSymbols constants;
STRING
this object contains a raw text string;
PROXY
this object contains a proxy to a raw text string;
FOOTNOTE
this object contains a footnote flow;
LABEL
this object contains a list label content;
END_PAR
this object is the last object in the content of a paragraph have finished with the \par command;
END_CELL
this object is the last object in the content of a paragraph have finished with the \cell or \nestcell command;
END_SECTION
this object is the last object in the content of a paragraph have finished with a section break command \sect;
END_FIELD
this object marks the end of field.
Kind names starting from the "END" correspond to markers. Markers have no inline object attached. All mensioned objects except active symbols are constructed with the help of corresponding specialized constructors.

The meaning of an rtf-object could be widen with the so-called special objects. A special object has a non-negative kind. It is constructed with the help of general constructor. The following special kinds are predefined now:

PICTURE
this object contains a Picture object;
FIELD
this object contains a FieldMarker object;
BOOKMARK
this object contains a Bookmark object.
SHAPE
this object contains a RTFShape object.
The encapsulated instance of object of the special kind should implement the RTFInline interface.

The following methods are used for the access to the encapsulated object:


Field Summary
static byte ACTIVE
          The kind of active character object,
static byte BOOKMARK
          The kind of bookmark object.
static byte END_CELL
          The kind of cell mark.
static byte END_FIELD
          The kind of end of field mark.
static byte END_PAR
          The kind of paragraph mark.
static byte END_SECTION
          The kind of section break mark.
static byte FIELD
          The kind of field mark object.
static byte FOOTNOTE
          The kind of footnote object.
static byte LABEL
          The kind of marker object.
static byte PICTURE
          The kind of picture object.
static byte PROXY
          The kind of proxy RTFString object.
static byte SHAPE
          The kind of shape object.
static byte STRING
          The kind of raw string object.
 
Fields inherited from interface ru.novosoft.dc.rtf.dom.objects.ActiveSymbols
ANNOTATION_REFERENCE, BEGIN_FORMULA, COLUMN_BREAK, CURRENT_DATE, CURRENT_DATE_LONG, CURRENT_DATE_MEDIUM, CURRENT_PAGE_NUMBER, CURRENT_SECTION_NUMBER, CURRENT_TIME, FOOTNOTE_ANCHOR, FOOTNOTE_CONTINUE, FOOTNOTE_REFERENCE, LEFT_TO_RIGHT, LINE_BREAK, LINE_BREAK_TYPE, PAGE_BREAK, RIGHT_TO_LEFT, SOFT_COLUMN_BREAK, SOFT_LINE_BREAK, SOFT_LINE_HEIGHT, SOFT_PAGE_BREAK, SUBENTRY, TAB
 
Constructor Summary
RTFObject(int kind)
          Construct a marker having no encapculated object.
RTFObject(int kind, java.lang.Object object)
          Construct an object of any kind (we recommend to use this constructor for objects of special kinds only).
RTFObject(java.util.List label)
          Construct a paragraph list label of the LABEL kind.
RTFObject(RTFFlow flow, boolean isEndnote)
          Construct an object of the FOOTNOTE kind.
RTFObject(RTFString proxy)
          Construct an object of the PROXY kind.
RTFObject(java.lang.String text)
          Construct an object of the STRING kind.
 
Method Summary
 void attachContext(CharacterContext context)
          Attach a character context to this inline object.
 CharacterContext context()
          Return the character context or null if no context attached.
 void exportTo(org.w3c.dom.Element elem)
          Export the contents of this object to the specified DOM element.
 RTFFootnote footnote()
          Return the encapsulated footnote for the FOOTNOTE kind or null otherwise.
 boolean hasParameter()
          Return true if the encapsulated ACTIVE symbol has a parameter.
 int kind()
          Return an object kind.
 java.util.List label()
          Return the encapsulated label for the LABEL kind or null otherwise.
 boolean mergeWith(java.lang.String s)
          Append a parameter string to the encapsulated string
 java.lang.Object object()
          Return the encapsulated object (for the ACTIVE kind, this is an int[] object of length 1 or 2 containing a code and parameter of active symbol).
 int parameter()
          Return the parameter of ACTIVE symbol or zero if no parameter specified.
 RTFInline special()
          Return the encapsulated inline object for a non-negative kind or null otherwise.
 int symbol()
          Return the value of encapsulated symbol for the ACTIVE kind or zero otherwise.
 java.lang.String text()
          Return the encapsulated string for the STRING and PROXY kinds or null otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHAPE

public static final byte SHAPE
The kind of shape object.

BOOKMARK

public static final byte BOOKMARK
The kind of bookmark object.

FIELD

public static final byte FIELD
The kind of field mark object.

PICTURE

public static final byte PICTURE
The kind of picture object.

ACTIVE

public static final byte ACTIVE
The kind of active character object,

STRING

public static final byte STRING
The kind of raw string object.

PROXY

public static final byte PROXY
The kind of proxy RTFString object.

LABEL

public static final byte LABEL
The kind of marker object.

FOOTNOTE

public static final byte FOOTNOTE
The kind of footnote object.

END_PAR

public static final byte END_PAR
The kind of paragraph mark.

END_CELL

public static final byte END_CELL
The kind of cell mark.

END_SECTION

public static final byte END_SECTION
The kind of section break mark.

END_FIELD

public static final byte END_FIELD
The kind of end of field mark.
Constructor Detail

RTFObject

public RTFObject(int kind)
Construct a marker having no encapculated object.

RTFObject

public RTFObject(java.lang.String text)
Construct an object of the STRING kind.

RTFObject

public RTFObject(RTFString proxy)
Construct an object of the PROXY kind.

RTFObject

public RTFObject(java.util.List label)
Construct a paragraph list label of the LABEL kind.

RTFObject

public RTFObject(RTFFlow flow,
                 boolean isEndnote)
Construct an object of the FOOTNOTE kind.

RTFObject

public RTFObject(int kind,
                 java.lang.Object object)
Construct an object of any kind (we recommend to use this constructor for objects of special kinds only).
Method Detail

kind

public final int kind()
Return an object kind.

attachContext

public final void attachContext(CharacterContext context)
Attach a character context to this inline object.

context

public final CharacterContext context()
Return the character context or null if no context attached.

symbol

public final int symbol()
Return the value of encapsulated symbol for the ACTIVE kind or zero otherwise.

hasParameter

public final boolean hasParameter()
Return true if the encapsulated ACTIVE symbol has a parameter.

parameter

public final int parameter()
Return the parameter of ACTIVE symbol or zero if no parameter specified.

text

public final java.lang.String text()
Return the encapsulated string for the STRING and PROXY kinds or null otherwise.

label

public final java.util.List label()
Return the encapsulated label for the LABEL kind or null otherwise.

footnote

public final RTFFootnote footnote()
Return the encapsulated footnote for the FOOTNOTE kind or null otherwise.

special

public final RTFInline special()
Return the encapsulated inline object for a non-negative kind or null otherwise.

object

public final java.lang.Object object()
Return the encapsulated object (for the ACTIVE kind, this is an int[] object of length 1 or 2 containing a code and parameter of active symbol).

mergeWith

public final boolean mergeWith(java.lang.String s)
Append a parameter string to the encapsulated string
Returns:
true if the object has the STRING type (successful merge) and false otherwise

exportTo

public void exportTo(org.w3c.dom.Element elem)
Export the contents of this object to the specified DOM element.