JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page
Interface TextMacro

All Known Implementing Classes:
DocumentPageCountMacro, PageNumberMacro, RomanPageMacro, SectionNumberMacro, SectionPageCountMacro, SectionPageNumberMacro

public interface TextMacro

Interface which defines an embeddable text macro. When evaluated in a context, the macro produces the text to be substituted in its place. Several standard macros are included below, including: PAGE_NUMBER -- current page number ROMAN_NUMBER -- current page number in roman numerals SECTION_NUMBER -- current section number SECTION_PAGE_NUMBER -- current page number within current section SECTION_PAGE_TOTAL -- total number of pages in current section PAGE_TOTAL -- total number of pages in document Users wanting to create their own macros should implement the methods in this interface. These methods will be called by PageLayout during its regular operation. They should behave as follows: If evaluate() has not yet been called by PageLayout, getStatus() should return MACRO_INITIALIZED and getText() should return some non-null initial value. When evaluate() is called by PageLayout, if the macro can be evaluated with the given information, the value MACRO_EVALUATED should be returned. getStatus() should henceforth return this value and getText() should return the evaluated macro text. If the macro cannot be evaluated with the information available when evaluate() is called, the method should return MACRO_NOT_YET_EVALUATED. getStatus() should henceforth return this same value and future calls to getText() should return the same non-null placeholder text returned during the initialize phase. Note that evaluate() may be called many several times per macro instance with different, potentially null values for flow and page. Once MACRO_EVALUATED has been returned by evaluate(), the method will not be called again for the instance of the macro with the current instance of the frame. When a new instance of the frame (such as a static header frame or the header frame of a table on a brand new new page) is created, the cycle will restart and evaluate() will be called again. This allows the macro to react to changes in the document between pages modify the text it represents accordingly.


Field Summary
static int MACRO_EVALUATED
          Macro status -- macro has been evaluated.
static int MACRO_INITIALIZED
          Macro status -- initialized, but evaluate has not yet been called.
static int MACRO_NOT_YET_EVALUATED
          Macro status -- evaluate() has been called, but macro cannot yet be evaluated.
static com.klg.jclass.page.TextMacro PAGE_NUMBER
           
static com.klg.jclass.page.TextMacro PAGE_TOTAL
           
static com.klg.jclass.page.TextMacro ROMAN_NUMBER
           
static com.klg.jclass.page.TextMacro SECTION_NUMBER
           
static com.klg.jclass.page.TextMacro SECTION_PAGE_NUMBER
           
static com.klg.jclass.page.TextMacro SECTION_PAGE_TOTAL
           
 
Method Summary
 int evaluate(com.klg.jclass.page.JCFlow flow, com.klg.jclass.page.JCPage page)
          Computes the text to which this macro evaluates given the current context.
 int getStatus()
          Gets the status of the last evaluation of the macro.
 String getText()
          Gets the text to which this macro evaluates given the current context.
 

Field Detail

MACRO_INITIALIZED

public static final int MACRO_INITIALIZED
Macro status -- initialized, but evaluate has not yet been called.

See Also:
Constant Field Values

MACRO_NOT_YET_EVALUATED

public static final int MACRO_NOT_YET_EVALUATED
Macro status -- evaluate() has been called, but macro cannot yet be evaluated.

See Also:
Constant Field Values

MACRO_EVALUATED

public static final int MACRO_EVALUATED
Macro status -- macro has been evaluated. Value will be returned by future calls to getText().

See Also:
Constant Field Values

PAGE_NUMBER

public static final com.klg.jclass.page.TextMacro PAGE_NUMBER

ROMAN_NUMBER

public static final com.klg.jclass.page.TextMacro ROMAN_NUMBER

SECTION_NUMBER

public static final com.klg.jclass.page.TextMacro SECTION_NUMBER

SECTION_PAGE_NUMBER

public static final com.klg.jclass.page.TextMacro SECTION_PAGE_NUMBER

SECTION_PAGE_TOTAL

public static final com.klg.jclass.page.TextMacro SECTION_PAGE_TOTAL

PAGE_TOTAL

public static final com.klg.jclass.page.TextMacro PAGE_TOTAL
Method Detail

evaluate

public int evaluate(com.klg.jclass.page.JCFlow flow,
                    com.klg.jclass.page.JCPage page)
Computes the text to which this macro evaluates given the current context.

Parameters:
flow - This parameter may be null when macro is initially added to a frame, but it usually contains the flow governing the document in which the marco appears, even if the macros has been added to a non-flow frame.
page - The page on which the macro is displayed. May be null when macro is initially added to frame.
Returns:
a status indicating whether the macro could be successfully resolved. One of MACRO_NOT_YET_EVALUATED or MACRO_EVALUATED.

getText

public String getText()
Gets the text to which this macro evaluates given the current context.

Returns:
The text which this macro resolves to. Even if the macro has not yet succesfully evaluated, this should NOT return null.

getStatus

public int getStatus()
Gets the status of the last evaluation of the macro.

Returns:
An indication of the degree of success of the last evaluation. One of MACRO_NOT_YET_EVALUATED or MACRO_EVALUATED.

Copyright © 2004 Quest Software Inc..
All rights reserved.