//
// $Id: DirectionUtil.java,v 1.1 2001/12/17 03:32:32 mdb Exp $

package com.threerings.util;

/**
 * Direction related utility functions.
 */
public class DirectionUtil implements DirectionCodes
{
    /**
     * Returns a string representation of the supplied direction code.
     */
    public static String toString (int direction)
    {
        return ((direction >= SOUTHWEST) && (direction <= SOUTH)) ?
            DIR_STRINGS[direction] : "INVALID";
    }

    /**
     * Returns an abbreviated string representation of the supplied
     * direction code.
     */
    public static String toShortString (int direction)
    {
        return ((direction >= SOUTHWEST) && (direction <= SOUTH)) ?
            SHORT_DIR_STRINGS[direction] : "?";
    }

    /**
     * Returns a string representation of an array of direction codes. The
     * directions are represented by the abbreviated names.
     */
    public static String toString (int[] directions)
    {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < directions.length; i++) {
            if (i > 0) {
                buf.append(", ");
            }
            buf.append(toShortString(directions[i]));
        }
        return buf.toString();
    }

    /** Direction constant string names. */
    protected static final String[] DIR_STRINGS = {
        "SOUTHWEST", "WEST", "NORTHWEST", "NORTH",
        "NORTHEAST", "EAST", "SOUTHEAST", "SOUTH"
    };

    /** Abbreviated direction constant string names. */
    protected static final String[] SHORT_DIR_STRINGS = {
        "SW", "W", "NW", "N", "NE", "E", "SE", "S"
    };
}

@@ -27,17 +27,17 @@
 ava,v 1.
-1
+2
  2001/12
@@ -47,13 +47,13 @@
  03:
-32:32
+43:54
  mdb
@@ -191,18 +191,198 @@
 onCodes%0A
-
 %7B%0A
+    /**%0A     * Returns an array of names corresponding to each direction constant.%0A     */%0A    public static String%5B%5D getDirectionNames ()%0A    %7B%0A        return DIR_STRINGS;%0A    %7D%0A%0A
     /**%0A

Added a method for obtaining the direction names array.