Package org.apache.fop.fo.properties
Class PropertyMaker
java.lang.Object
org.apache.fop.fo.properties.PropertyMaker
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
CharacterProperty.Maker
,ColorProperty.Maker
,CompoundPropertyMaker
,EnumProperty.Maker
,FontFamilyProperty.Maker
,FontShorthandProperty.Maker
,LengthProperty.Maker
,ListProperty.Maker
,NumberProperty.Maker
,NumberProperty.PositiveIntegerMaker
,OptionalCharacterProperty.Maker
,StringProperty.Maker
,TableFObj.ColumnNumberPropertyMaker
,ToBeImplementedProperty.Maker
,URIProperty.Maker
Base class for all property makers
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Indicates whether the property is context-dependant and therefore can't be cached.protected CorrespondingPropertyMaker
Maker for 'corresponding' propertiesprotected Property
default propertyprotected String
the default value for the makerprotected int
the property IDprotected boolean
Indicates whether the property is set through a shorthand. -
Constructor Summary
ConstructorDescriptionPropertyMaker
(int propId) Construct an instance of a Property.Maker for the given property. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a enum constant.void
addKeyword
(String keyword, String value) Add a keyword-equiv to the maker.void
addShorthand
(PropertyMaker shorthand) Add a shorthand to this maker.void
addSubpropMaker
(PropertyMaker subproperty) Add a subproperty to this maker.protected Property
checkEnumValues
(String value) For properties that contain enumerated values.checkValueKeywords
(String keyword) Return a String to be parsed if the passed value corresponds to a keyword which can be parsed and used to initialize the property.clone()
Return a clone of the makers.protected Property
compute
(PropertyList propertyList) Return a Property object representing the value of this property, based on other property values for this FO.protected Property
convertProperty
(Property p, PropertyList propertyList, FObj fo) Return a Property object based on the passed Property object.protected Property
convertPropertyDatatype
(Property p, PropertyList propertyList, FObj fo) For properties that have more than one legal way to be specified, this routine should be overridden to attempt to set them based upon the other methods.convertShorthandProperty
(PropertyList propertyList, Property prop, FObj fo) Converts a shorthand propertyfindProperty
(PropertyList propertyList, boolean tryInherit) If the property is a relative property with a corresponding absolute value specified, the absolute value is used.get
(int subpropertyId, PropertyList propertyList, boolean tryInherit, boolean tryDefault) Return the property on the current FlowObject.getName()
This is used to handle properties specified as a percentage of some "base length", such as the content width of their containing box.int
getShorthand
(PropertyList propertyList) For properties that can be set by shorthand properties, this method should return the Property, if any, that is parsed from any shorthand properties that affect this property.getSubprop
(Property p, int subpropertyId) Return a property value for the given component of a compound property.getSubpropMaker
(int subpropertyId) Return a subproperty maker for the subpropertyId.boolean
Default implementation of isInherited.make
(Property baseProperty, int subpropertyId, PropertyList propertyList, String value, FObj fo) Make a property value for a compound property.make
(PropertyList propertyList) Return the default value.make
(PropertyList propertyList, String value, FObj fo) Create a Property object from an attribute specification.Create a new empty property.void
setByShorthand
(boolean setByShorthand) Set the setByShorthand flag which only is applicable for subproperty makers.void
setCorresponding
(CorrespondingPropertyMaker corresponding) Set the correspoding property information.void
setDatatypeParser
(ShorthandParser parser) Set the shorthand datatype parser.void
setDefault
(String defaultValue) Set the default value for this maker.void
setDefault
(String defaultValue, boolean contextDep) Set the default value for this maker.void
setInherited
(boolean inherited) Set the inherited flag.void
setPercentBase
(int percentBase) Set the percent base identifier for this maker.protected Property
setSubprop
(Property baseProperty, int subpropertyId, Property subproperty) Set a component in a compound property and return the modified compound property object.void
useGeneric
(PropertyMaker generic) Copy all the values from the generic maker to this maker.
-
Field Details
-
propId
protected int propIdthe property ID -
defaultValue
the default value for the maker -
contextDep
protected boolean contextDepIndicates whether the property is context-dependant and therefore can't be cached. -
setByShorthand
protected boolean setByShorthandIndicates whether the property is set through a shorthand. -
defaultProperty
default property -
corresponding
Maker for 'corresponding' properties
-
-
Constructor Details
-
PropertyMaker
public PropertyMaker(int propId) Construct an instance of a Property.Maker for the given property.- Parameters:
propId
- The Constant ID of the property to be made.
-
-
Method Details
-
getPropId
public int getPropId()- Returns:
- the name of the property for this Maker
-
useGeneric
Copy all the values from the generic maker to this maker.- Parameters:
generic
- a generic property maker.
-
setInherited
public void setInherited(boolean inherited) Set the inherited flag.- Parameters:
inherited
- true if this is an inherited property
-
addKeyword
Add a keyword-equiv to the maker.- Parameters:
keyword
- the keywordvalue
- the value to be used when the keyword is specified
-
addEnum
Add a enum constant.- Parameters:
constant
- the enum constantvalue
- the Property value to use when the constant is specified
-
addSubpropMaker
Add a subproperty to this maker.- Parameters:
subproperty
- the PropertyMaker for the subproperty
-
getSubpropMaker
Return a subproperty maker for the subpropertyId.- Parameters:
subpropertyId
- The subpropertyId of the maker.- Returns:
- The subproperty maker.
-
addShorthand
Add a shorthand to this maker. Only an Integer is added to the shorthands list. Later the Integers are replaced with references to the actual shorthand property makers.- Parameters:
shorthand
- a property maker thar is that is checked for shorthand values.
-
setDatatypeParser
Set the shorthand datatype parser.- Parameters:
parser
- the shorthand parser
-
setDefault
Set the default value for this maker.- Parameters:
defaultValue
- the default value.
-
setDefault
Set the default value for this maker.- Parameters:
defaultValue
- the default valuecontextDep
- true when the value context dependent and must not be cached.
-
setPercentBase
public void setPercentBase(int percentBase) Set the percent base identifier for this maker.- Parameters:
percentBase
- the percent base (ex. LengthBase.FONTSIZE)
-
setByShorthand
public void setByShorthand(boolean setByShorthand) Set the setByShorthand flag which only is applicable for subproperty makers. It should be true for the subproperties which must be assigned a value when the base property is assigned a attribute value directly.- Parameters:
setByShorthand
- true if this subproperty must be set when the base property is set
-
setCorresponding
Set the correspoding property information.- Parameters:
corresponding
- a corresponding maker where the isForcedCorresponding and compute methods are delegated to.
-
makeNewProperty
Create a new empty property. Must be overriden in compound subclasses.- Returns:
- a new instance of the Property for which this is a maker.
-
findProperty
public Property findProperty(PropertyList propertyList, boolean tryInherit) throws PropertyException If the property is a relative property with a corresponding absolute value specified, the absolute value is used. This is also true of the inheritance priority (I think...) If the property is an "absolute" property and it isn't specified, then we try to compute it from the corresponding relative property: this happens in computeProperty.- Parameters:
propertyList
- the applicable property listtryInherit
- true if inherited properties should be examined.- Returns:
- the property value
- Throws:
PropertyException
- if there is a problem evaluating the property
-
get
public Property get(int subpropertyId, PropertyList propertyList, boolean tryInherit, boolean tryDefault) throws PropertyException Return the property on the current FlowObject. Depending on the passed flags, this will try to compute it based on other properties, or if it is inheritable, to return the inherited value. If all else fails, it returns the default value.- Parameters:
subpropertyId
- The subproperty id of the property being retrieved. Is 0 when retrieving a base property.propertyList
- The PropertyList object being built for this FO.tryInherit
- true if inherited properties should be examined.tryDefault
- true if the default value should be returned.- Returns:
- the property value
- Throws:
PropertyException
- if there is a problem evaluating the property
-
isInherited
public boolean isInherited()Default implementation of isInherited.- Returns:
- A boolean indicating whether this property is inherited.
-
getPercentBase
This is used to handle properties specified as a percentage of some "base length", such as the content width of their containing box. Overridden by subclasses which allow percent specifications. See the documentation on properties.xsl for details.- Parameters:
pl
- the PropertyList containing the property. (TODO: explain what this is used for, or remove it from the signature.)- Returns:
- an object implementing the PercentBase interface.
- Throws:
PropertyException
- if there is a problem while evaluating the base property
-
getSubprop
Return a property value for the given component of a compound property.- Parameters:
p
- A property value for a compound property type such as SpaceProperty.subpropertyId
- the id of the component whose value is to be returned. NOTE: this is only to ease porting when calls are made to PropertyList.get() using a component name of a compound property, such as get("space.optimum"). The recommended technique is: get("space").getOptimum(). Overridden by property maker subclasses which handle compound properties.- Returns:
- the Property containing the subproperty
-
setSubprop
Set a component in a compound property and return the modified compound property object. This default implementation returns the original base property without modifying it. It is overridden by property maker subclasses which handle compound properties.- Parameters:
baseProperty
- The Property object representing the compound property, such as SpaceProperty.subpropertyId
- The ID of the component whose value is specified.subproperty
- A Property object holding the specified value of the component to be set.- Returns:
- The modified compound property object.
-
make
Return the default value.- Parameters:
propertyList
- The PropertyList object being built for this FO.- Returns:
- the Property object corresponding to the parameters
- Throws:
PropertyException
- for invalid or inconsisten FO input
-
make
Create a Property object from an attribute specification.- Parameters:
propertyList
- The PropertyList object being built for this FO.value
- The attribute value.fo
- The parent FO for the FO whose property is being made.- Returns:
- The initialized Property object.
- Throws:
PropertyException
- for invalid or inconsistent FO input
-
make
public Property make(Property baseProperty, int subpropertyId, PropertyList propertyList, String value, FObj fo) throws PropertyException Make a property value for a compound property. If the property value is already partially initialized, this method will modify it.- Parameters:
baseProperty
- The Property object representing the compound property, for example: SpaceProperty.subpropertyId
- The Constants ID of the subproperty (component) whose value is specified.propertyList
- The propertyList being built.fo
- The parent FO for the FO whose property is being made.value
- the value of the- Returns:
- baseProperty (or if null, a new compound property object) with the new subproperty added
- Throws:
PropertyException
- for invalid or inconsistent FO input
-
convertShorthandProperty
public Property convertShorthandProperty(PropertyList propertyList, Property prop, FObj fo) throws PropertyException Converts a shorthand property- Parameters:
propertyList
- the propertyList for which to convertprop
- the shorthand propertyfo
- ...- Returns:
- the converted property
- Throws:
PropertyException
- ...
-
checkEnumValues
For properties that contain enumerated values. This method should be overridden by subclasses.- Parameters:
value
- the string containing the property value- Returns:
- the Property encapsulating the enumerated equivalent of the input value
-
checkValueKeywords
Return a String to be parsed if the passed value corresponds to a keyword which can be parsed and used to initialize the property. For example, the border-width family of properties can have the initializers "thin", "medium", or "thick". The FOPropertyMapping file specifies a length value equivalent for these keywords, such as "0.5pt" for "thin".- Parameters:
keyword
- the string value of property attribute.- Returns:
- a String containing a parseable equivalent or null if the passed value isn't a keyword initializer for this Property
-
convertProperty
protected Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException Return a Property object based on the passed Property object. This method is called if the Property object built by the parser isn't the right type for this property. It is overridden by subclasses.- Parameters:
p
- The Property object return by the expression parserpropertyList
- The PropertyList object being built for this FO.fo
- The parent FO for the FO whose property is being made.- Returns:
- A Property of the correct type or null if the parsed value can't be converted to the correct type.
- Throws:
PropertyException
- for invalid or inconsistent FO input
-
convertPropertyDatatype
protected Property convertPropertyDatatype(Property p, PropertyList propertyList, FObj fo) throws PropertyException For properties that have more than one legal way to be specified, this routine should be overridden to attempt to set them based upon the other methods. For example, colors may be specified using an RGB model, or they may be specified using an NCname.- Parameters:
p
- property whose datatype should be convertedpropertyList
- collection of properties. (TODO: explain why this is needed, or remove it from the signature.)fo
- The parent FO for the FO whose property is being made. why this is needed, or remove it from the signature).- Returns:
- an Property with the appropriate datatype used
- Throws:
PropertyException
- for invalid or inconsistent input
-
compute
Return a Property object representing the value of this property, based on other property values for this FO. A special case is properties which inherit the specified value, rather than the computed value.- Parameters:
propertyList
- The PropertyList for the FO.- Returns:
- Property A computed Property value or null if no rules are specified to compute the value.
- Throws:
PropertyException
- for invalid or inconsistent FO input
-
getShorthand
For properties that can be set by shorthand properties, this method should return the Property, if any, that is parsed from any shorthand properties that affect this property. This method expects to be overridden by subclasses. For example, the border-right-width property could be set implicitly from the border shorthand property, the border-width shorthand property, or the border-right shorthand property. This method should be overridden in the appropriate subclass to check each of these, and return an appropriate border-right-width Property object.- Parameters:
propertyList
- the collection of properties to be considered- Returns:
- the Property, if found, the correspons, otherwise, null
- Throws:
PropertyException
- if there is a problem while evaluating the shorthand
-
getName
- Returns:
- the name of the property this maker is used for.
-
clone
Return a clone of the makers. Used by useGeneric() to clone the subproperty makers of the generic compound makers.
-