Package org.apache.fop.fo
Class PropertyList
- java.lang.Object
-
- org.apache.fop.fo.PropertyList
-
- Direct Known Subclasses:
Marker.MarkerPropertyList
,StaticPropertyList
public abstract class PropertyList extends java.lang.Object
Class containing the collection of properties for a given FObj.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PropertyList.UnknownPropertyHandler
A class to handle unknown shorthand property values e.g.
-
Field Summary
Fields Modifier and Type Field Description private FObj
fobj
private static boolean[]
inheritableProperty
private static org.apache.commons.logging.Log
log
protected PropertyList
parentPropertyList
reference to the parent FO's propertyListprivate PropertyList.UnknownPropertyHandler
unknownPropertyHandler
-
Constructor Summary
Constructors Constructor Description PropertyList(FObj fObjToAttach, PropertyList parentPropertyList)
Basic constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addAttributesToList(org.xml.sax.Attributes attributes)
Adds the attributes, passed in by the parser to the PropertyList.private java.lang.String
addAttributeToList(org.xml.sax.Attributes attributes, java.lang.String attributeName)
private void
convertAttributeToProperty(org.xml.sax.Attributes attributes, java.lang.String attributeName, java.lang.String attributeValue)
private Property
findBaseProperty(org.xml.sax.Attributes attributes, FObj parentFO, int propId, java.lang.String basePropertyName, PropertyMaker propertyMaker)
protected static java.lang.String
findBasePropertyName(java.lang.String attributeName)
Finds the first or base part (up to any period) of an attribute name.private static PropertyMaker
findMaker(int propId)
protected static java.lang.String
findSubPropertyName(java.lang.String attributeName)
Finds the second or sub part (portion past any period) of an attribute name.Property
get(int propId)
Return the property on the current FlowObject.Property
get(int propId, boolean bTryInherit, boolean bTryDefault)
Return the property on the current FlowObject.CommonAbsolutePosition
getAbsolutePositionProps()
Constructs a CommonAbsolutePosition object.CommonAural
getAuralProps()
Constructs a CommonAural object.CommonBorderPaddingBackground
getBorderPaddingBackgroundProps()
Constructs a BorderAndPadding object.abstract Property
getExplicit(int propId)
Return the value explicitly specified on this FO.Property
getExplicitOrShorthand(int propId)
Return the value explicitly specified on this FO.FObj
getFObj()
CommonFont
getFontProps()
Constructs a CommonFont object.Property
getFromParent(int propId)
Return the value of this property on the parent of this FO.CommonHyphenation
getHyphenationProps()
Constructs a CommonHyphenation object.Property
getInherited(int propId)
Return the value of this property inherited by this FO.CommonMarginBlock
getMarginBlockProps()
Constructs a CommonMarginBlock object.CommonMarginInline
getMarginInlineProps()
Constructs a CommonMarginInline object.Property
getNearestSpecified(int propId)
Return the "nearest" specified value for the given property.FObj
getParentFObj()
PropertyList
getParentPropertyList()
Property
getPropertyForAttribute(org.xml.sax.Attributes attributes, java.lang.String attributeName, java.lang.String attributeValue)
CommonRelativePosition
getRelativePositionProps()
Constructs a RelativePositionProps objects.private Property
getShorthand(int propId)
CommonTextDecoration
getTextDecorationProps()
Constructs a CommonTextDecoration object.java.util.Map<java.lang.String,Property>
getUnknownPropertyValues()
Gets the current list of unknown property valuesprotected void
handleInvalidProperty(org.apache.xmlgraphics.util.QName attr)
Handles an invalid property.private boolean
isInherited(int propId)
protected boolean
isValidPropertyName(java.lang.String propertyName)
Validates a property name.private Property
makeProperty(int propId)
abstract void
putExplicit(int propId, Property value)
Set an value defined explicitly on this FO.int
selectFromWritingMode(int lrtb, int rltb, int tbrl, int tblr)
Select a writing mode dependent property ID based on value of writing mode property.void
validatePropertyValue(java.lang.String propertyValue, Property output, Property property)
Adds an unknown property value to the property list so that if necessary, a warning can be displayed.
-
-
-
Field Detail
-
inheritableProperty
private static boolean[] inheritableProperty
-
parentPropertyList
protected PropertyList parentPropertyList
reference to the parent FO's propertyList
-
fobj
private FObj fobj
-
log
private static org.apache.commons.logging.Log log
-
unknownPropertyHandler
private final PropertyList.UnknownPropertyHandler unknownPropertyHandler
-
-
Constructor Detail
-
PropertyList
public PropertyList(FObj fObjToAttach, PropertyList parentPropertyList)
Basic constructor.- Parameters:
fObjToAttach
- the FO this PropertyList should be attached toparentPropertyList
- the PropertyList belonging to the new objects parent
-
-
Method Detail
-
getFObj
public FObj getFObj()
- Returns:
- the FObj object to which this propertyList is attached
-
getParentFObj
public FObj getParentFObj()
- Returns:
- the FObj object attached to the parentPropertyList
-
validatePropertyValue
public void validatePropertyValue(java.lang.String propertyValue, Property output, Property property)
Adds an unknown property value to the property list so that if necessary, a warning can be displayed.- Parameters:
propertyValue
- The unknown property valueoutput
- The output of the property to validateproperty
- The original property containing the full value
-
getUnknownPropertyValues
public java.util.Map<java.lang.String,Property> getUnknownPropertyValues()
Gets the current list of unknown property values- Returns:
- The set containing the list of unknown property values
-
getParentPropertyList
public PropertyList getParentPropertyList()
- Returns:
- the FObj object attached to the parentPropetyList
-
getExplicitOrShorthand
public Property getExplicitOrShorthand(int propId) throws PropertyException
Return the value explicitly specified on this FO.- Parameters:
propId
- The id of the property whose value is desired.- Returns:
- The value if the property is explicitly set or set by a shorthand property, otherwise null.
- Throws:
PropertyException
- ...
-
getExplicit
public abstract Property getExplicit(int propId)
Return the value explicitly specified on this FO.- Parameters:
propId
- The ID of the property whose value is desired.- Returns:
- The value if the property is explicitly set, otherwise null.
-
putExplicit
public abstract void putExplicit(int propId, Property value)
Set an value defined explicitly on this FO.- Parameters:
propId
- The ID of the property to set.value
- The value of the property.
-
getInherited
public Property getInherited(int propId) throws PropertyException
Return the value of this property inherited by this FO. Implements the inherited-property-value function. The property must be inheritable!- Parameters:
propId
- The ID of the property whose value is desired.- Returns:
- The inherited value, otherwise null.
- Throws:
PropertyException
- ...
-
get
public Property get(int propId) throws PropertyException
Return the property on the current FlowObject. If it isn't set explicitly, 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:
propId
- The Constants ID of the property whose value is desired.- Returns:
- the Property corresponding to that name
- Throws:
PropertyException
- if there is a problem evaluating the property
-
get
public Property get(int propId, boolean bTryInherit, boolean bTryDefault) 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:
propId
- the property's idbTryInherit
- true for inherited properties, or when the inherited value is neededbTryDefault
- true when the default value may be used as a last resort- Returns:
- the property
- Throws:
PropertyException
- if there is a problem evaluating the property
-
getNearestSpecified
public Property getNearestSpecified(int propId) throws PropertyException
Return the "nearest" specified value for the given property. Implements the from-nearest-specified-value function.- Parameters:
propId
- The ID of the property whose value is desired.- Returns:
- The computed value if the property is explicitly set on some ancestor of the current FO, else the initial value.
- Throws:
PropertyException
- if there an error occurred when getting the property
-
getFromParent
public Property getFromParent(int propId) throws PropertyException
Return the value of this property on the parent of this FO. Implements the from-parent function.- Parameters:
propId
- The Constants ID of the property whose value is desired.- Returns:
- The computed value on the parent or the initial value if this FO is the root or is in a different namespace from its parent.
- Throws:
PropertyException
- ...
-
selectFromWritingMode
public int selectFromWritingMode(int lrtb, int rltb, int tbrl, int tblr)
Select a writing mode dependent property ID based on value of writing mode property.- Parameters:
lrtb
- the property ID to return under lrtb writingmode.rltb
- the property ID to return under rltb writingmode.tbrl
- the property ID to return under tbrl writingmode.tblr
- the property ID to return under tblr writingmode.- Returns:
- one of the property IDs, depending on the writing mode.
-
addAttributeToList
private java.lang.String addAttributeToList(org.xml.sax.Attributes attributes, java.lang.String attributeName) throws ValidationException
- Throws:
ValidationException
-
addAttributesToList
public void addAttributesToList(org.xml.sax.Attributes attributes) throws ValidationException
Adds the attributes, passed in by the parser to the PropertyList.
Note that certain attributes are given priority in terms of order of processing due to conversion dependencies, where the order is as follows:
- writing-mode
- column-number
- number-columns-spanned
- font
- font-size
- all others in order of appearance
- Parameters:
attributes
- Collection of attributes passed to us from the parser.- Throws:
ValidationException
- if there is an attribute that does not map to a property id (strict validation only)
-
isValidPropertyName
protected boolean isValidPropertyName(java.lang.String propertyName)
Validates a property name.- Parameters:
propertyName
- the property name to check- Returns:
- true if the base property name and the subproperty name (if any) can be correctly mapped to an id
-
getPropertyForAttribute
public Property getPropertyForAttribute(org.xml.sax.Attributes attributes, java.lang.String attributeName, java.lang.String attributeValue) throws FOPException
- Throws:
FOPException
-
convertAttributeToProperty
private void convertAttributeToProperty(org.xml.sax.Attributes attributes, java.lang.String attributeName, java.lang.String attributeValue) throws ValidationException
- Parameters:
attributes
- Collection of attributesattributeName
- Attribute name to convertattributeValue
- Attribute value to assign to property- Throws:
ValidationException
- in case the property name is invalid for the FO namespace
-
findBaseProperty
private Property findBaseProperty(org.xml.sax.Attributes attributes, FObj parentFO, int propId, java.lang.String basePropertyName, PropertyMaker propertyMaker) throws PropertyException
- Throws:
PropertyException
-
handleInvalidProperty
protected void handleInvalidProperty(org.apache.xmlgraphics.util.QName attr) throws ValidationException
Handles an invalid property.- Parameters:
attr
- the invalid attribute- Throws:
ValidationException
- if an exception needs to be thrown depending on the validation settings
-
findBasePropertyName
protected static java.lang.String findBasePropertyName(java.lang.String attributeName)
Finds the first or base part (up to any period) of an attribute name. For example, if input is "space-before.minimum", should return "space-before".- Parameters:
attributeName
- String to be atomized- Returns:
- the base portion of the attribute
-
findSubPropertyName
protected static java.lang.String findSubPropertyName(java.lang.String attributeName)
Finds the second or sub part (portion past any period) of an attribute name. For example, if input is "space-before.minimum", should return "minimum".- Parameters:
attributeName
- String to be atomized- Returns:
- the sub portion of the attribute
-
getShorthand
private Property getShorthand(int propId) throws PropertyException
- Parameters:
propId
- ID of property- Returns:
- new Property object
- Throws:
PropertyException
- if there's a problem while processing the property
-
makeProperty
private Property makeProperty(int propId) throws PropertyException
- Parameters:
propId
- ID of property- Returns:
- new Property object
- Throws:
PropertyException
- if there's a problem while processing the property
-
isInherited
private boolean isInherited(int propId)
- Parameters:
propId
- ID of property- Returns:
- isInherited value from the requested Property.Maker
-
findMaker
private static PropertyMaker findMaker(int propId)
- Parameters:
propId
- Id of property- Returns:
- the Property.Maker for this property
-
getBorderPaddingBackgroundProps
public CommonBorderPaddingBackground getBorderPaddingBackgroundProps() throws PropertyException
Constructs a BorderAndPadding object.- Returns:
- a BorderAndPadding object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getHyphenationProps
public CommonHyphenation getHyphenationProps() throws PropertyException
Constructs a CommonHyphenation object.- Returns:
- the CommonHyphenation object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getMarginBlockProps
public CommonMarginBlock getMarginBlockProps() throws PropertyException
Constructs a CommonMarginBlock object.- Returns:
- the CommonMarginBlock object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getMarginInlineProps
public CommonMarginInline getMarginInlineProps() throws PropertyException
Constructs a CommonMarginInline object.- Returns:
- the CommonMarginInline object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getAuralProps
public CommonAural getAuralProps() throws PropertyException
Constructs a CommonAural object.- Returns:
- the CommonAural object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getRelativePositionProps
public CommonRelativePosition getRelativePositionProps() throws PropertyException
Constructs a RelativePositionProps objects.- Returns:
- a RelativePositionProps object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getAbsolutePositionProps
public CommonAbsolutePosition getAbsolutePositionProps() throws PropertyException
Constructs a CommonAbsolutePosition object.- Returns:
- the CommonAbsolutePosition object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getFontProps
public CommonFont getFontProps() throws PropertyException
Constructs a CommonFont object.- Returns:
- A CommonFont object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
getTextDecorationProps
public CommonTextDecoration getTextDecorationProps() throws PropertyException
Constructs a CommonTextDecoration object.- Returns:
- a CommonTextDecoration object
- Throws:
PropertyException
- if there's a problem while processing the properties
-
-