/*
 *    GeoTools - OpenSource mapping toolkit
 *    http://geotools.org
 *    (C) 2007, GeoTools Project Managment Committee (PMC)
 *    (C) 2007, Geomatys
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.image.io.metadata;

import java.util.Date;
import org.opengis.referencing.cs.CoordinateSystemAxis;  // For javadoc


/**
 * An {@code <Axis>} element in
 * {@linkplain GeographicMetadataFormat geographic metadata format}.
 *
 * @since 2.4
 * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/coverageio/src/main/java/org/geotools/image/io/metadata/Axis.java $
 * @version $Id: Axis.java 26151 2007-07-04 18:54:48Z desruisseaux $
 * @author Martin Desruisseaux
 *
 * @see CoordinateSystemAxis
 */
public class Axis extends MetadataAccessor {
    /**
     * Creates a parser for an axis. This constructor should not be invoked
     * directly; use {@link ImageReferencing#getAxis} instead.
     *
     * @param metadata  The metadata which contains this axis.
     * @param index The band index for this instance.
     */
    protected Axis(final ImageReferencing metadata, final int index) {
        super(metadata.cs);
        selectChild(index);
    }

    /**
     * Creates a parser for an axis. This constructor should not be invoked
     * directly; use {@link ImageReferencing#getAxis} instead.
     *
     * @param parent The set of all axis.
     * @param index  The axis index for this instance.
     */
    Axis(final ChildList parent, final int index) {
        super(parent);
        selectChild(index);
    }

    /**
     * Returns the name for this axis, or {@code null} if none.
     */
    public String getName() {
        return getString("name");
    }

    /**
     * Sets the name for this axis.
     *
     * @param name The axis name, or {@code null} if none.
     */
    public void setName(final String name) {
        setString("name", name);
    }

    /**
     * Returns the direction for this axis, or {@code null} if none.
     */
    public String getDirection() {
        return getString("direction");
    }

    /**
     * Sets the direction for this axis.
     *
     * @param direction The axis direction, or {@code null} if none.
     */
    public void setDirection(final String direction) {
        setEnum("direction", direction, GeographicMetadataFormat.DIRECTIONS);
    }

    /**
     * Returns the units for this axis, or {@code null} if none.
     */
    public String getUnits() {
        return getString("units");
    }

    /**
     * Sets the units for this axis.
     *
     * @param units The axis units, or {@code null} if none.
     */
    public void setUnits(final String units) {
        setString("units", units);
    }

    /**
     * Returns the time origin for this axis, or {@code null} if none.
     */
    public Date getTimeOrigin() {
        return getDate("origin");
    }

    /**
     * Sets the time origin for this axis.
     *
     * @param origin The axis time origin, or {@code null} if none.
     */
    public void setTimeOrigin(final Date origin) {
        setDate("origin", origin);
    }
}
