Update qdox-1.6.3.jar to qdox-1.10.jar

View: New views
2 Messages — Rating Filter:   Alert me  

Update qdox-1.6.3.jar to qdox-1.10.jar

by Alexander Kiel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

can we update QDox from 1.6.3 to 1.10?

I have an issue with QDox 1.6.3: It can't parse my Fixed16 class (which
I have attached to this mail). The problem is in line 35:

private static final float DENOMINATOR = (float) (1 << 14);

It can't parse the shift operator.

QDox 1.10 works fine.

Best Regards
Alex

--
e-mail: alexanderkiel@...
web:    www.alexanderkiel.net


[Fixed16.java]

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package org.apache.fop.fonts.opentype.common.io;

import java.text.NumberFormat;
import java.util.Locale;

/**
 * A 16-bit signed fixed-point number (2.14).
 */
public final class Fixed16 {

    /**
     * This constant represents the fixed-point number zero.
     */
    public static final Fixed16 ZERO = new Fixed16((short) 0);

    private static final float DENOMINATOR = (float) (1 << 14);

    private static final NumberFormat FORMAT = NumberFormat.getNumberInstance(Locale.US);

    static {
        FORMAT.setMinimumFractionDigits(1);
        FORMAT.setMaximumFractionDigits(6);
    }

    private final short value;

    /**
     * Creates a new fixed-point number.
     *
     * @param value the value of the fixed point number as short
     * @return a fixed-point number
     */
    public static Fixed16 fromShort(short value) {
        return new Fixed16(value);
    }

    /**
     * Creates a new fixed-point number.
     *
     * @param value the value of the fixed point number as float
     * @return a fixed-point number
     */
    public static Fixed16 fromFloat(float value) {
        int fixedValue = Math.round(value * DENOMINATOR);
        if (fixedValue > Short.MAX_VALUE) {
            throw new ArithmeticException("overflow; value: " + value);
        }
        if (fixedValue < Short.MIN_VALUE) {
            throw new ArithmeticException("underflow; value: " + value);
        }
        return new Fixed16((short) fixedValue);
    }

    private Fixed16(short value) {
        this.value = value;
    }

    /**
     * Retruns the internal short representation of this fixed-point number.
     *
     * @return the internal short representation of this fixed-point number.
     */
    public short toShort() {
        return value;
    }

    /**
     * Retruns the value of this fixed-point number as float.
     *
     * @return the value of this fixed-point number as float.
     */
    public float toFloat() {
        return value / DENOMINATOR;
    }

    /**
     * {@inheritDoc}
     */
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }

        Fixed16 otherFixed = (Fixed16) obj;

        return this.value == otherFixed.value;
    }

    /**
     * {@inheritDoc}
     */
    public int hashCode() {
        return value;
    }

    /**
     * {@inheritDoc}
     */
    public String toString() {
        return FORMAT.format(toFloat());
    }
}



signature.asc (204 bytes) Download Attachment

Re: Update qdox-1.6.3.jar to qdox-1.10.jar

by Vincent Hennebert-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alexander,

Alexander Kiel wrote:

> Hi,
>
> can we update QDox from 1.6.3 to 1.10?
>
> I have an issue with QDox 1.6.3: It can't parse my Fixed16 class (which
> I have attached to this mail). The problem is in line 35:
>
> private static final float DENOMINATOR = (float) (1 << 14);
>
> It can't parse the shift operator.
>
> QDox 1.10 works fine.

I’d suggest you to update locally, and we will include the update when
integrating your patch. We must make sure that no backwards
incompatibility has been introduced in newer versions.


> Best Regards
> Alex

Thanks,
Vincent