001    /*
002     *    GeoAPI - Java interfaces for OGC/ISO standards
003     *    http://www.geoapi.org
004     *
005     *    Copyright (C) 2007-2012 Open Geospatial Consortium, Inc.
006     *    All Rights Reserved. http://www.opengeospatial.org/ogc/legal
007     *
008     *    Permission to use, copy, and modify this software and its documentation, with
009     *    or without modification, for any purpose and without fee or royalty is hereby
010     *    granted, provided that you include the following on ALL copies of the software
011     *    and documentation or portions thereof, including modifications, that you make:
012     *
013     *    1. The full text of this NOTICE in a location viewable to users of the
014     *       redistributed or derivative work.
015     *    2. Notice of any changes or modifications to the OGC files, including the
016     *       date changes were made.
017     *
018     *    THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
019     *    NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
020     *    TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
021     *    THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
022     *    PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
023     *
024     *    COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
025     *    CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
026     *
027     *    The name and trademarks of copyright holders may NOT be used in advertising or
028     *    publicity pertaining to the software without specific, written prior permission.
029     *    Title to copyright in this software and any associated documentation will at all
030     *    times remain with copyright holders.
031     */
032    package org.opengis.metadata.identification;
033    
034    import org.opengis.annotation.UML;
035    
036    import static org.opengis.annotation.Obligation.MANDATORY;
037    import static org.opengis.annotation.Specification.ISO_19115;
038    
039    
040    /**
041     * A scale defined as the inverse of a denominator. This is derived from ISO 19103 {@code Scale}
042     * where {@linkplain #getDenominator denominator} = 1 / <var>scale</var>.
043     * <p>
044     * Implementations are encouraged to extend {@link Number} in a manner equivalent to:
045     *
046     * <blockquote><pre>
047     *  class MyRepresentedFraction extends Number implements RepresentedFraction {
048     *      ...
049     *      public double doubleValue() {
050     *          return 1.0 / (double) denominator;
051     *      }
052     *      public float floatValue() {
053     *          return 1.0f / (float) denominator;
054     *      }
055     *      public long longValue() {
056     *          return 1 / denominator; // Result is zero except for denominator=[0,1].
057     *      }
058     *      ...
059     *  }
060     * </pre></blockquote>
061     *
062     * @author  Ely Conn (Leica Geosystems Geospatial Imaging, LLC)
063     * @version 3.0
064     * @since   2.1
065     */
066    @UML(identifier="MD_RepresentativeFraction", specification=ISO_19115)
067    public interface RepresentativeFraction {
068        /**
069         * Returns the scale value in a form usable for computation.
070         *
071         * @return <code>1.0 / (double) {@linkplain #getDenominator()}</code>
072         *
073         * @since 2.2
074         */
075        double doubleValue();
076    
077        /**
078         * The number below the line in a vulgar fraction.
079         *
080         * @return The denominator.
081         */
082        @UML(identifier = "denominator", obligation = MANDATORY, specification = ISO_19115)
083        long getDenominator();
084    
085        /**
086         * Compares this representative fraction with the specified object for equality.
087         * {@code RepresentativeFraction} is a data object - {@code equals} is defined
088         * according to {@link #getDenominator()};
089         * <p>
090         * Implementations should match the following:
091         *
092         * <blockquote><pre>
093         * public boolean equals(Object object) {
094         *     if (object instanceof RepresentativeFraction) {
095         *         final RepresentativeFraction that = (RepresentativeFraction) object;
096         *         return getDenominator() == that.getDenominator();
097         *     }
098         *     return false;
099         * }
100         * </pre></blockquote>
101         *
102         * @param other The object to compare with.
103         * @return {@code true} if {@code other} is a {@code RepresentedFraction} with the same
104         *         {@linkplain #getDenominator denominator} value.
105         */
106        @Override
107        boolean equals(Object other);
108    
109        /**
110         * Returns a hash value for this representative fraction.
111         * {@code RepresentativeFraction} is a data object - {@code hashcode} is defined
112         * according to {@link #getDenominator()}.
113         * <p>
114         * Implementations should match the following:
115         *
116         * <blockquote><pre>
117         * public int hashCode() {
118         *     return (int) getDenominator();
119         * }
120         * </pre></blockquote>
121         *
122         * @return A hash code value for this representative fraction.
123         */
124        @Override
125        int hashCode();
126    }