org.foray.fotree
Class Property

java.lang.Object
  extended by org.foray.fotree.Property
Direct Known Subclasses:
AbstractAxslProperty, AbstractFoProperty, AbstractXmlProperty

public abstract class Property
extends Object

Class representing an XSL-FO property. A Property consists of two parts: 1. Its identifier (what property am I?), e.g. "start-indent" or "font-family". This class does not currently record this, as its instances are accumulated in a PropertyList that knows this information. 2. Its value. For now, we consider a value to be either a) a valid datatype, or b) an expression (which contains valid datatypes).


Field Summary
static int PRECEDENCE_FORCE
          Constant defining a precedence of "force" (the maximum integer value).
 
Constructor Summary
Property()
           
 
Method Summary
protected  int convertNumericToInteger(PropertyValue value)
          Converts a numeric property value its integer equivalent.
protected  int convertValueToLength(PropertyValue value, FObj fobj, org.axsl.fo.FoContext context)
          Converts a property value to its computed length.
static String getBasePropertyName(String propertyName)
          Find the "base" portion of the property Name.
static int getKeywordIndex(FoValue possibleKeyword, FoValue[] validKeywords)
          Searches an array of keywords to see if a keyword candidate is found in that list.
static FoValue getKeywordInSet(FoValue keyword, FoValue[] keywordSet)
          Determines whether a given keyword is included in a given keyword set.
abstract  PropertyType getPropertyType()
          Returns the type of this property.
static String getSubPropertyName(String propertyName)
          Find the "sub" portion of the property Name.
static PropertyException invalidPropertyName(String propertyName)
          Returns an exception indicating that the passed property name is not valid.
static boolean keywordInSet(FoValue keyword, FoValue[] keywordSet)
          Determines whether a given keyword index is included in a given keyword set.
protected static IllegalArgumentException unexpectedInitialValueArgument(PropertyType propertyType, Class<? extends Property> theClass)
          Returns an IllegalArgumentException indicating that the arguments presented for retrieving an initial value for a given property are not valid.
protected  IllegalStateException unexpectedRetrieval()
          Returns an IllegalStateException indicating that the stored value is not expected at retrieval time.
protected  PropertyException unexpectedValue(String value, FObj fobj)
          Convenience method which returns an exception indicating that the value of this property does not meet the properties requirements.
protected  PropertyException unexpectedValue(String value, FObj fobj, String reason)
          Returns an exception indicating that the value of this property does not meet the property's requirements.
abstract  PropertyValue value()
          Returns the value for this property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRECEDENCE_FORCE

public static final int PRECEDENCE_FORCE
Constant defining a precedence of "force" (the maximum integer value).

See Also:
Constant Field Values
Constructor Detail

Property

public Property()
Method Detail

getPropertyType

public abstract PropertyType getPropertyType()
Returns the type of this property.

Returns:
The type of this property.

unexpectedValue

protected PropertyException unexpectedValue(String value,
                                            FObj fobj)
Convenience method which returns an exception indicating that the value of this property does not meet the properties requirements.

Parameters:
value - The unparsed property value.
fobj - The FObj to which this property belongs.
Returns:
The newly-constructed exception.

unexpectedValue

protected PropertyException unexpectedValue(String value,
                                            FObj fobj,
                                            String reason)
Returns an exception indicating that the value of this property does not meet the property's requirements.

Parameters:
value - The unparsed property value.
fobj - The FObj to which this property belongs.
reason - The reason for the failure.
Returns:
The newly-constructed exception.

invalidPropertyName

public static PropertyException invalidPropertyName(String propertyName)
Returns an exception indicating that the passed property name is not valid.

Parameters:
propertyName - The name of the property that is not valid.
Returns:
The newly-created exception.

unexpectedRetrieval

protected IllegalStateException unexpectedRetrieval()
Returns an IllegalStateException indicating that the stored value is not expected at retrieval time.

Returns:
An IllegalStateException instance that can be thrown by subclasses.

unexpectedInitialValueArgument

protected static IllegalArgumentException unexpectedInitialValueArgument(PropertyType propertyType,
                                                                         Class<? extends Property> theClass)
Returns an IllegalArgumentException indicating that the arguments presented for retrieving an initial value for a given property are not valid.

Parameters:
propertyType - The property type for which the initial value is being obtained.
theClass - The class reporting the illegal argument exception.
Returns:
An IllegalArgumentException instance that can be thrown by subclasses.

getKeywordIndex

public static int getKeywordIndex(FoValue possibleKeyword,
                                  FoValue[] validKeywords)
Searches an array of keywords to see if a keyword candidate is found in that list.

Parameters:
possibleKeyword - The candidate keyword being tested.
validKeywords - The array of valid keywords.
Returns:
If found, returns the index into validKeywords, otherwise returns -1.

getKeywordInSet

public static FoValue getKeywordInSet(FoValue keyword,
                                      FoValue[] keywordSet)
Determines whether a given keyword is included in a given keyword set.

Parameters:
keyword - The keyword whose inclusion is being tested.
keywordSet - The array of keywords that is being tested against.
Returns:
The keyword if it is found, or null if it is not.

keywordInSet

public static boolean keywordInSet(FoValue keyword,
                                   FoValue[] keywordSet)
Determines whether a given keyword index is included in a given keyword set.

Parameters:
keyword - The keyword index whose inclusion is being tested.
keywordSet - The short array that keywordIndex is being tested against.
Returns:
True if keywordIndex is found in keywordSet, false otherwise.

getBasePropertyName

public static String getBasePropertyName(String propertyName)
Find the "base" portion of the property Name. For example, for the property "inline-progression-dimension.minimum", the base portion is "inline-progression-dimension".

Parameters:
propertyName - The raw, unparsed property name.
Returns:
The "base" portion of the property Name, or null if the input is null.

getSubPropertyName

public static String getSubPropertyName(String propertyName)
Find the "sub" portion of the property Name. For example, for the property "inline-progression-dimension.minimum", the sub portion is "minimum".

Parameters:
propertyName - The raw, unparsed property name.
Returns:
The "sub" portion of the property Name, or null if the input is null, or if there is no sub-property.

value

public abstract PropertyValue value()
Returns the value for this property.

Returns:
The value for this property.

convertValueToLength

protected int convertValueToLength(PropertyValue value,
                                   FObj fobj,
                                   org.axsl.fo.FoContext context)
Converts a property value to its computed length.

Parameters:
value - The property value to be evaluated.
fobj - The FObj to which this property belongs.
context - An object that knows how to resolve FO context issues.
Returns:
The length of the property, in millipoints.

convertNumericToInteger

protected int convertNumericToInteger(PropertyValue value)
Converts a numeric property value its integer equivalent.

Parameters:
value - The property value to be converted.
Returns:
The value of the property, as an int.


Copyright © 2017. All rights reserved.