[FOray-commit] SF.net SVN: foray: [9054] trunk/foray/foray-fotree/src/java/org/foray/ fotree
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-03-31 00:24:24
|
Revision: 9054
http://svn.sourceforge.net/foray/?rev=9054&view=rev
Author: victormote
Date: 2007-03-30 17:24:24 -0700 (Fri, 30 Mar 2007)
Log Message:
-----------
Javadoc improvements.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/AbstractFoProperty.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/NamespaceFO.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyTokenizer.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2007-03-30 23:46:12 UTC (rev 9053)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2007-03-31 00:24:24 UTC (rev 9054)
@@ -65,27 +65,60 @@
public Property(final PropertyList propertyList) {
}
+ /**
+ * Constructor used when the property value has already been parsed.
+ * @param propertyList The PropertyList instance to which this Property
+ * will be added.
+ * @param value This property's value.
+ */
public Property(final PropertyList propertyList,
final PropertyValue value) {
this(propertyList);
this.value = value;
}
+ /**
+ * Sets the value for this property.
+ * @param value The new value.
+ */
public void setPropertyValue(final PropertyValue value) {
this.value = value;
}
+ /**
+ * Returns the value for this property.
+ * @return The value for this property.
+ */
public final PropertyValue value() {
return value;
}
+ /**
+ * Returns the type of this property.
+ * @return The type of this property.
+ */
public abstract PropertyType getPropertyType();
+ /**
+ * Convenience method which returns an exception indicating that the value
+ * of this property does not meet the properties requirements.
+ * @param value The unparsed property value.
+ * @param propertyList The property list of the parent FObj.
+ * @return The newly-constructed exception.
+ */
protected PropertyException unexpectedValue(final String value,
final PropertyList propertyList) {
return unexpectedValue(value, propertyList, null);
}
+ /**
+ * Convenience method which returns an exception indicating that the value
+ * of this property does not meet the properties requirements.
+ * @param value The unparsed property value.
+ * @param propertyList The property list of the parent FObj.
+ * @param reason The reason for the failure.
+ * @return The newly-constructed exception.
+ */
protected PropertyException unexpectedValue(final String value,
final PropertyList propertyList, final String reason) {
return new PropertyException(unexpectedValueMessage(reason, value,
@@ -129,6 +162,11 @@
return buffer.toString();
}
+ /**
+ * Creates a string indicating that the passed property name is not valid.
+ * @param propertyName The name of the property that is not valid.
+ * @return A string indicating that the passed property name is not valid.
+ */
public static String invalidPropertyName(final String propertyName) {
return "Invalid property: " + propertyName + "'.";
}
@@ -169,8 +207,21 @@
return pv;
}
+ /**
+ * Returns the valid keywords for this property.
+ * @return The valid keywords for this property.
+ */
protected abstract FoValue[] getValidKeywords();
+ /**
+ * Checks the keywords for this property, returning an appropriate property
+ * value if a keyword is detected.
+ * @param validKeywords The array of valid keywords.
+ * @param possibleKeyword The token to be evaluated against the valid
+ * keywords.
+ * @return If <code>possibleKeyword</code> is found in the validKeywords,
+ * return an appropriate property value instance, otherwise returns null.
+ */
protected PropertyKeyword checkKeywords(final FoValue[] validKeywords,
final String possibleKeyword) {
if (validKeywords == null
@@ -186,6 +237,14 @@
return null;
}
+ /**
+ * Searches an array of keywords to see if a keyword candidate is found in
+ * that list.
+ * @param possibleKeyword The candidate keyword being tested.
+ * @param validKeywords The array of valid keywords.
+ * @return If found, returns the index into <code>validKeywords</code>,
+ * otherwise returns -1.
+ */
public static int getKeywordIndex(final FoValue possibleKeyword,
final FoValue[] validKeywords) {
if (validKeywords == null) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/AbstractFoProperty.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/AbstractFoProperty.java 2007-03-30 23:46:12 UTC (rev 9053)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/AbstractFoProperty.java 2007-03-31 00:24:24 UTC (rev 9054)
@@ -35,18 +35,30 @@
import org.axsl.common.FoProperty;
/**
- * Superclass for properties in the "xml:" namespace.
+ * Superclass for properties in the "fo:" namespace.
*/
public abstract class AbstractFoProperty extends Property {
+ /** This property's type. */
private FoProperty foPropertyType;
+ /**
+ * Constructor for properties whose value has not yet been established.
+ * @param propertyList The parent object's list of properties.
+ * @param foPropertyType The property type of this property.
+ */
public AbstractFoProperty(final PropertyList propertyList,
final FoProperty foPropertyType) {
super(propertyList);
this.foPropertyType = foPropertyType;
}
+ /**
+ * Constructor for properties with a known value.
+ * @param propertyList The parent object's list of properties.
+ * @param foPropertyType The property type of this property.
+ * @param value The value of this property.
+ */
public AbstractFoProperty(final PropertyList propertyList,
final FoProperty foPropertyType, final PropertyValue value) {
super(propertyList, value);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/NamespaceFO.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/NamespaceFO.java 2007-03-30 23:46:12 UTC (rev 9053)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/NamespaceFO.java 2007-03-31 00:24:24 UTC (rev 9054)
@@ -46,24 +46,39 @@
*/
public class NamespaceFO extends Namespace {
+ /**
+ * Constructor.
+ */
public NamespaceFO() {
super();
}
+ /**
+ * {@inheritDoc}
+ */
public String getNamespaceURI() {
return "http://www.w3.org/1999/XSL/Format";
}
+ /**
+ * {@inheritDoc}
+ */
public String getTypicalPrefix() {
return "fo";
}
+ /**
+ * {@inheritDoc}
+ */
public FObj parseElementForNS(final String localName,
final FObj currentFObj, final PropertyList list,
final Locator locator) throws FOTreeException {
return ObjectMakerFO.makeObject(localName, currentFObj, list, locator);
}
+ /**
+ * {@inheritDoc}
+ */
public void parseAttributes(final PropertyList propertyList,
final Attributes attlist, final FObj currentFObj,
final Locator locator, final FOTreeBuilder builder)
@@ -77,6 +92,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public Property parseAttributeForNS(final Attributes attributes,
final String attributeName, final String attributeValue,
final PropertyList propertyList, final Locator locator)
@@ -93,6 +111,9 @@
return property;
}
+ /**
+ * {@inheritDoc}
+ */
protected PropertyList createNewPropertyList(final String localName,
final Attributes attlist) {
return new PropertyList();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2007-03-30 23:46:12 UTC (rev 9053)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2007-03-31 00:24:24 UTC (rev 9054)
@@ -63,6 +63,7 @@
*/
public final class PropertyParser extends PropertyTokenizer {
+ /** The function list of the parent FObj of the expression being parsed. */
private PropertyList propertyList;
/** Stack of functions being evaluated. */
@@ -116,8 +117,9 @@
}
/**
- * Try to parse an addition or subtraction expression and return the
- * resulting Property.
+ * Parse an addition or subtraction expression.
+ * @return The expression parsed.
+ * @throws PropertyException For errors parsing the expression.
*/
private ExprAdditive parseAdditiveExpr() throws PropertyException {
// Evaluate and put result on the operand stack
@@ -142,8 +144,9 @@
}
/**
- * Try to parse a multiply, divide or modulo expression and return
- * the resulting Property.
+ * Parse a multiply, divide or modulo expression.
+ * @return The expression parsed.
+ * @throws PropertyException For errors parsing the expression.
*/
private ExprMultiplicative parseMultiplicativeExpr()
throws PropertyException {
@@ -171,8 +174,9 @@
}
/**
- * Try to parse a unary minus expression and return the
- * resulting Property.
+ * Parse a unary minus expression.
+ * @return The expression parsed.
+ * @throws PropertyException For errors parsing the expression.
*/
private ExprUnary parseUnaryExpr() throws PropertyException {
if (getCurrentToken() == TOK_MINUS) {
@@ -184,8 +188,10 @@
/**
- * Checks that the current token is a right parenthesis
- * and throws an exception if this isn't the case.
+ * Checks that the current token is a right parenthesis and throws an
+ * exception if this isn't the case.
+ * @throws PropertyException If the current token is not a right
+ * parenthesis.
*/
private void expectRpar() throws PropertyException {
if (getCurrentToken() != TOK_RPAR) {
@@ -195,12 +201,13 @@
}
/**
- * Try to parse a primary expression and return the
- * resulting Property.
+ * Parse a primary expression.
* A primary expression is either a parenthesized expression or an
* expression representing a primitive Property datatype, such as a
* string literal, an NCname, a number or a unit expression, or a
* function call expression.
+ * @return The expression parsed.
+ * @throws PropertyException For errors parsing the expression.
*/
private ExprPrimary parsePrimaryExpr() throws PropertyException {
ExprPrimary prop;
@@ -276,6 +283,11 @@
return prop;
}
+ /**
+ * Parse an inner expression.
+ * @return The expression parsed.
+ * @throws PropertyException For errors parsing the expression.
+ */
private ExprInner parseInnerExpression() throws PropertyException {
final ExprAdditive expr = parseAdditiveExpr();
if (expr instanceof ExprNumeric) {
@@ -423,6 +435,10 @@
ExprNumeric.OPERATION_MOD);
}
+ /**
+ * Pushes a function onto the stack of functions being evaluated.
+ * @param func The function to push onto the stack.
+ */
public void pushFunction(final Function func) {
if (stkFunction == null) {
stkFunction = new Stack<Function>();
@@ -430,6 +446,9 @@
stkFunction.push(func);
}
+ /**
+ * Pops an item off of the function stack.
+ */
public void popFunction() {
if (stkFunction != null) {
stkFunction.pop();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyTokenizer.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyTokenizer.java 2007-03-30 23:46:12 UTC (rev 9053)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyTokenizer.java 2007-03-31 00:24:24 UTC (rev 9054)
@@ -33,28 +33,62 @@
/**
* Class to tokenize XSL FO property expression.
- * This class is heavily based on the epxression tokenizer in James Clark's
+ * This class is heavily based on the expression tokenizer in James Clark's
* XT, an XSLT processor.
*/
class PropertyTokenizer {
+ /** Constant indicating end-of-file. */
static final int TOK_EOF = 0;
+
+ /** Constant indicating an NCName. */
static final int TOK_NCNAME = TOK_EOF + 1;
+
+ /** Constant indicating the multiplication symbol. */
static final int TOK_MULTIPLY = TOK_NCNAME + 1;
+
+ /** Constant indicating a left parentheses. */
static final int TOK_LPAR = TOK_MULTIPLY + 1;
+
+ /** Constant indicating a right parentheses. */
static final int TOK_RPAR = TOK_LPAR + 1;
+
+ /** Constant indicating a literal. */
static final int TOK_LITERAL = TOK_RPAR + 1;
+
+ /** Constant indicating a number. */
static final int TOK_NUMBER = TOK_LITERAL + 1;
+
+ /** Constant indicating a left parentheses at the start of a function. */
static final int TOK_FUNCTION_LPAR = TOK_NUMBER + 1;
+
+ /** Constant indicating a plus sign. */
static final int TOK_PLUS = TOK_FUNCTION_LPAR + 1;
+
+ /** Constant indicating a minus sign. */
static final int TOK_MINUS = TOK_PLUS + 1;
+
+ /** Constant indicating a mod operation. */
static final int TOK_MOD = TOK_MINUS + 1;
+
+ /** Constant indicating a division operation. */
static final int TOK_DIV = TOK_MOD + 1;
+
static final int TOK_NUMERIC = TOK_DIV + 1;
+
+ /** Constant indicating a comma. */
static final int TOK_COMMA = TOK_NUMERIC + 1;
+
+ /** Constant indicating a percent. */
static final int TOK_PERCENT = TOK_COMMA + 1;
+
+ /** Constant indicating a color specification. */
static final int TOK_COLORSPEC = TOK_PERCENT + 1;
+
+ /** Constant indicating a float. */
static final int TOK_FLOAT = TOK_COLORSPEC + 1;
+
+ /** Constant indicating an integer. */
static final int TOK_INTEGER = TOK_FLOAT + 1;
private static final int CS = 1;
@@ -109,8 +143,13 @@
private String currentTokenValue = null;
private int currentTokenStartIndex = 0;
+
+ /** The current expression being parsed. */
private /* final */ String expr;
+
private int exprIndex = 0;
+
+ /** The length, in chars, of {@link expr}. */
private int exprLength;
@@ -329,6 +368,8 @@
/**
* Return a boolean value indicating whether the following non-whitespace
* character is an opening parenthesis.
+ * @return True iff The following non-whitespace character is an opening
+ * parenthesis.
*/
private boolean followingParen() {
for (int i = exprIndex; i < exprLength; i++) {
@@ -351,7 +392,8 @@
/**
* Return a boolean value indicating whether the argument is a
* decimal digit (0-9).
- * @param c The character to check
+ * @param c The character to check.
+ * @return True iff the test character is a decimal digit.
*/
private static boolean isDigit(final char c) {
return c > 0
@@ -362,7 +404,8 @@
/**
* Return a boolean value indicating whether the argument is a
* hexadecimal digit (0-9, A-F, a-f).
- * @param c The character to check
+ * @param c The character to check.
+ * @return True iff the test character is a hexadecimal digit.
*/
private static boolean isHexDigit(final char c) {
return c > 0
@@ -373,7 +416,8 @@
/**
* Return a boolean value indicating whether the argument is a valid name
* start character, ie. can start a NAME as defined by XSL.
- * @param c The character to check
+ * @param c The character to check.
+ * @return True iff The test character is a valid start-of-name character.
*/
private static boolean isNameStartChar(final char c) {
return c >= WKConstants.MAX_7_BIT_UNSIGNED_VALUES
@@ -384,7 +428,8 @@
/**
* Return a boolean value indicating whether the argument is a valid name
* character, ie. can occur in a NAME as defined by XSL.
- * @param c The character to check
+ * @param c The character to check.
+ * @return True iff The test character is a valid name character.
*/
private static boolean isNameChar(final char c) {
return c > WKConstants.MAX_7_BIT_UNSIGNED_VALUES
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|