001    /*
002     *    GeoAPI - Java interfaces for OGC/ISO standards
003     *    http://www.geoapi.org
004     *
005     *    Copyright (C) 2004-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.coverage.grid;
033    
034    import java.util.List;
035    import java.util.ArrayList;
036    
037    import org.opengis.util.CodeList;
038    import org.opengis.coverage.SampleDimensionType;
039    import org.opengis.annotation.UML;
040    
041    import static org.opengis.annotation.Obligation.*;
042    import static org.opengis.annotation.Specification.*;
043    
044    
045    /**
046     * Order of values packed in a byte for sample dimensions with less than 8 bits.
047     * This include
048     * {@link SampleDimensionType#UNSIGNED_1BIT UNSIGNED_1BIT},
049     * {@link SampleDimensionType#UNSIGNED_2BITS UNSIGNED_2BITS} and
050     * {@link SampleDimensionType#UNSIGNED_4BITS UNSIGNED_4BITS} data types.
051     *
052     * <P>&nbsp;</P>
053     * <TABLE WIDTH="80%" ALIGN="center" CELLPADDING="18" BORDER="4" BGCOLOR="#FFE0B0">
054     *   <TR><TD>
055     *     <P align="justify"><STRONG>WARNING: THIS CLASS WILL CHANGE.</STRONG> Current API is derived from OGC
056     *     <A HREF="http://www.opengis.org/docs/01-004.pdf">Grid Coverages Implementation specification 1.0</A>.
057     *     We plan to replace it by new interfaces derived from ISO 19123 (<CITE>Schema for coverage geometry
058     *     and functions</CITE>). Current interfaces should be considered as legacy and are included in this
059     *     distribution only because they were part of GeoAPI 1.0 release. We will try to preserve as much
060     *     compatibility as possible, but no migration plan has been determined yet.</P>
061     *   </TD></TR>
062     * </TABLE>
063     *
064     * @version <A HREF="http://www.opengis.org/docs/01-004.pdf">Grid Coverage specification 1.0</A>
065     * @author  Martin Desruisseaux (IRD)
066     * @since   GeoAPI 1.0
067     *
068     * @see GridPacking
069     * @see ByteInValuePacking
070     *
071     * @deprecated In favor of migrating to ISO 19123 definition for Coverage.
072     */
073    @UML(identifier="GC_ValueInBytePacking", specification=OGC_01004)
074    public final class ValueInBytePacking extends CodeList<ValueInBytePacking> {
075        /**
076         * Serial number for compatibility with different versions.
077         */
078        private static final long serialVersionUID = 6895036289489868770L;
079    
080        /**
081         * List of all enumerations of this type.
082         * Must be declared before any enum declaration.
083         */
084        private static final List<ValueInBytePacking> VALUES = new ArrayList<ValueInBytePacking>(2);
085    
086        /**
087         * Low bit firts (little endian order).
088         */
089        @UML(identifier="GC_LoBitFirst", obligation=CONDITIONAL, specification=OGC_01004)
090        public static final ValueInBytePacking LO_BIT_FIRST = new ValueInBytePacking("LO_BIT_FIRST");
091    
092        /**
093         * High bit first (big endian order).
094         */
095        @UML(identifier="GC_HiBitFirst", obligation=CONDITIONAL, specification=OGC_01004)
096        public static final ValueInBytePacking HI_BIT_FIRST = new ValueInBytePacking("HI_BIT_FIRST");
097    
098        /**
099         * Constructs an enum with the given name. The new enum is
100         * automatically added to the list returned by {@link #values}.
101         *
102         * @param name The enum name. This name must not be in use by an other enum of this type.
103         */
104        private ValueInBytePacking(final String name) {
105            super(name, VALUES);
106        }
107    
108        /**
109         * Returns the list of {@code ValueInBytePacking}s.
110         *
111         * @return The list of codes declared in the current JVM.
112         */
113        public static ValueInBytePacking[] values() {
114            synchronized (VALUES) {
115                return VALUES.toArray(new ValueInBytePacking[VALUES.size()]);
116            }
117        }
118    
119        /**
120         * Returns the list of enumerations of the same kind than this enum.
121         */
122        public ValueInBytePacking[] family() {
123            return values();
124        }
125    
126        /**
127         * Returns the value in byte packing that matches the given string, or returns a
128         * new one if none match it. More specifically, this methods returns the first instance for
129         * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code>
130         * returns {@code true}. If no existing instance is found, then a new one is created for
131         * the given name.
132         *
133         * @param code The name of the code to fetch or to create.
134         * @return A code matching the given name.
135         */
136        public static ValueInBytePacking valueOf(String code) {
137            return valueOf(ValueInBytePacking.class, code);
138        }
139    }