Package org.foray.fotree

Examples of org.foray.fotree.PropertyException


        }
        if (this.permitsPercentages) {
            if (pv.canEvalPercentage()) {
                return;
            } else {
                throw new PropertyException("Length-range value must evaluate "
                        + "to a length or a percentage");
            }
        }
        throw new PropertyException("Minimum value must evaluate to a length.");
    }
View Full Code Here


                enumeration, propertyFullName, attributeValue);
        if (property != null) {
            return property;
        }
        if (enumeration == null) {
            throw new PropertyException("Invalid property for xml namespace: "
                    + propertyFullName);
        }
        switch (enumeration) {
        case LANG: {
            return new Lang(fobj, propertyFullName, attributeValue);
View Full Code Here

     * @throws PropertyException For an invalid units value.
     */
    public DtFrequency(final double quantity, final byte units)
            throws PropertyException {
        if (units < 1 || units > 2) {
            throw new PropertyException("Invalid FrequencyDT unit ID.");
        }
        this.quantity = quantity;
        this.units = units;
    }
View Full Code Here

            case '"':
            case '\'':
                this.exprIndex = this.expr.indexOf(c, this.exprIndex);
                if (this.exprIndex < 0) {
                    this.exprIndex = this.currentTokenStartIndex + 1;
                    throw new PropertyException("missing quote");
                }
                this.currentTokenValue = this.expr.substring(
                        this.currentTokenStartIndex + 1, this.exprIndex++);
                this.currentToken = PropertyTokenizer.TOK_LITERAL;
                return;
            case '*':
                /*
                 * if (currentMaybeOperator) {
                 * recognizeOperator = false;
                 */
                this.currentToken = PropertyTokenizer.TOK_MULTIPLY;
                /*
                 * }
                 * else
                 * throw new PropertyException("illegal operator *");
                 */
                return;
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
                scanDigits();
                if (this.exprIndex < this.exprLength
                        && this.expr.charAt(this.exprIndex) == '.') {
                    this.exprIndex++;
                    bSawDecimal = true;
                    if (this.exprIndex < this.exprLength
                            && isDigit(this.expr.charAt(this.exprIndex))) {
                        this.exprIndex++;
                        scanDigits();
                    }
                } else {
                    bSawDecimal = false;
                }
                if (this.exprIndex < this.exprLength
                        && this.expr.charAt(this.exprIndex) == '%') {
                    this.exprIndex++;
                    this.currentToken = PropertyTokenizer.TOK_PERCENT;
                } else {
                    // Check for possible unit name following number
                    this.currentUnitLength = this.exprIndex;
                    scanName();
                    this.currentUnitLength = this.exprIndex
                            - this.currentUnitLength;
                    if (this.currentUnitLength > 0) {
                        this.currentToken = PropertyTokenizer.TOK_NUMERIC;
                    } else {
                        if (bSawDecimal) {
                            this.currentToken = PropertyTokenizer.TOK_FLOAT;
                        } else {
                            this.currentToken = PropertyTokenizer.TOK_INTEGER;
                        }
                    }
                }
                this.currentTokenValue = this.expr.substring(
                        this.currentTokenStartIndex, this.exprIndex);
                return;

            case '.':
                if (this.exprIndex < this.exprLength
                        && isDigit(this.expr.charAt(this.exprIndex))) {
                    ++this.exprIndex;
                    scanDigits();
                    if (this.exprIndex < this.exprLength
                            && this.expr.charAt(this.exprIndex) == '%') {
                        this.exprIndex++;
                        this.currentToken = PropertyTokenizer.TOK_PERCENT;
                    } else {
                        // Check for possible unit name following number
                        this.currentUnitLength = this.exprIndex;
                        scanName();
                        this.currentUnitLength = this.exprIndex
                                - this.currentUnitLength;
                        if (this.currentUnitLength > 0) {
                            this.currentToken = PropertyTokenizer.TOK_NUMERIC;
                        } else {
                            this.currentToken = PropertyTokenizer.TOK_FLOAT;
                        }
                    }
                    this.currentTokenValue = this.expr.substring(
                            this.currentTokenStartIndex, this.exprIndex);
                    return;
                }
                throw new PropertyException("illegal character '.'");

            case '#':
                // Start of color value
                if (this.exprIndex < this.exprLength
                        && isHexDigit(this.expr.charAt(this.exprIndex))) {
                    ++this.exprIndex;
                    scanHexDigits();
                    this.currentToken = PropertyTokenizer.TOK_COLORSPEC;
                    this.currentTokenValue = this.expr.substring(
                            this.currentTokenStartIndex, this.exprIndex);
                    // Probably should have some multiple of 3 for length!
                    return;
                }
                throw new PropertyException("illegal character '#'");

            default:
                --this.exprIndex;
                scanName();
                if (this.exprIndex == this.currentTokenStartIndex) {
                    throw new PropertyException("illegal character");
                }
                this.currentTokenValue = this.expr.substring(
                        this.currentTokenStartIndex, this.exprIndex);
                // if (currentMaybeOperator) {
                if (this.currentTokenValue.equals("mod")) {
View Full Code Here

     * @throws PropertyException If the current token is not a right
     * parenthesis.
     */
    private void expectRpar() throws PropertyException {
        if (getCurrentToken() != TOK_RPAR) {
            throw new PropertyException("expected )");
        }
        next();
    }
View Full Code Here

        case TOK_COLORSPEC:
            try {
                prop = DtColor.parseColorDescription(getCurrentTokenValue());
            } catch (final PropertyException e) {
                throw new PropertyException(e.getMessage());
            }
            break;

        case TOK_FUNCTION_LPAR: {
            final int functionType = Function.enumerateFunctionName(
                    getCurrentTokenValue());
            if (functionType < 1) {
                throw new PropertyException("No such function: "
                        + getCurrentTokenValue());
            }
            next();
            final Expr[] functionArguments = parseArgs();
            final Function function = Function.makeFunction(functionType,
View Full Code Here

        switch (functionType) {
        case Function.BODY_START: {
            /* TODO: Provide the right context. */
            final ListItem listItem = fobj.getNearestListItem(null);
            if (listItem == null) {
                throw new PropertyException("body-start() called from outside "
                        + "an fo:list-item");
            }
            break;
        }
        case Function.LABEL_END: {
            /* TODO: Provide the right context. */
            final ListItem listItem = fobj.getNearestListItem(null);
            if (listItem == null) {
                throw new PropertyException("label-end() called from outside "
                        + "an fo:list-item");
            }
            break;
        }
        case Function.PROPORTIONAL_COLUMN_WIDTH: {
            /* Per the XSL-FO standard 1.0, Section 5.10.4, it is an error for
             * this function to be used by anything but a table-column. */
            if (! (fobj instanceof TableColumn)) {
                throw new PropertyException(
                        "Function 'proportional-column-width' "
                        + "is only valid for object 'fo:table-column'.");
            }
            /* Per the XSL-FO standard 1.0, Section 5.10.4, it is an error for
             * this function to be used within a table unless the table-layout
             * is "fixed".
             */
            Table table = null;
            if (fobj instanceof Table) {
                table = (Table) fobj;
            } else {
                /* TODO: Provide the right context. */
                table = fobj.ancestorTable(null);
            }
            if (table == null) {
                throw new PropertyException("Ancestor 'table' object not found "
                        + "for function \"proportional-column-width\".");
            }
            if (table.traitTableLayout() != TableLayout.FIXED) {
                throw new PropertyException("Table layout must be \"fixed\" "
                        + "for function \"proportional-column-width\".");
            }
            break;
        }
        default: {
View Full Code Here

     * @throws PropertyException If either operand is null.
     */
    private ExprAdditiveOper evalAddition(final ExprAdditive op1,
            final ExprMultiplicative op2) throws PropertyException {
        if (op1 == null || op2 == null) {
            throw new PropertyException("Missing parameter: addition.");
        }
        return new ExprAdditiveOper(op1, op2, Expr.OPERATION_ADD);
    }
View Full Code Here

     * @throws PropertyException If either operand is null.
     */
    private ExprAdditiveOper evalSubtraction(final ExprAdditive op1,
            final ExprMultiplicative op2) throws PropertyException {
        if (op1 == null || op2 == null) {
            throw new PropertyException("Missing parameter: subtraction.");
        }
        return new ExprAdditiveOper(op1, op2, Expr.OPERATION_SUBTRACT);
    }
View Full Code Here

     * @throws PropertyException If the operand is null.
     */
    private ExprUnaryOper evalNegate(final ExprUnary op)
            throws PropertyException {
        if (op == null) {
            throw new PropertyException("Negation: missing parameter.");
        }
        return new ExprUnaryOper(op, Expr.OPERATION_NEGATION);
    }
View Full Code Here

TOP

Related Classes of org.foray.fotree.PropertyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.