Generating Initial Values
by Peter B. West
Introduction
The previous section discussed the common data elements in the simplest examples of property classes. This section discusses more complex classes whose facilities are accessed only through various methods.
Generating & Accessing Initial Values
org.apache.fop.fo.properties.AutoRestore is an example of the next most complex property class. In addition to all of the common static fields, these classes have initial data value types which require the dynamic generation of a PropertyValue instance.
The method PropertyValue getInitialValue(int) returns an instance of PropertyValue of the appropriate subclass containing the initial value for this property. Like the static data fields, this value is, in turn, stored in the array of initial values maintained in the PropertyConsts singleton pconsts.` As with the fields, the first invocation of the method setupProperty on the property instantiates the singleton instance of the class, and stores that instance in the in the Property[] properties array of pconsts.
Unlike the static data fields, however, the initial value is not immediately generated. It is generated by a call to PropertyValue getInitialValue(int) in pconsts. This call, in turn, locates the relevant instance of the particular property class in the properties array of PropertyConsts, and invokes the getInitialValue() of that instance. A side-effect of this call is to store the initial value in PropertyValue[] initialValues.
Properties without getInitialValue()
What about property classes which have no getInitialValue() method? The simplest classes, e.g. Character, fall into this category. As noted previously, all of the property classes extend org.apache.fop.fo.properties.Property. Property provides a base PropertyValue getInitialValue(int) method to which the simple classes fall back. Note that it is only valid for NOTYPE_IT, AUTO_IT, NONE_IT and AURAL_IT initial value types, so all classes which have any other initial value type must override this method.
Previous: Simple property classes
Next: Enumerated values