boolean hasExpLetter = false;
    public static long textScaleToLong(String textScale) {        Long resolution;        Long realValue;        int expLetter; // location of m, M, K        int expLetterSmall;        int colon = textScale.indexOf(":");        boolean hasExpLetter = false;        try {            if (colon == -1) {                // dealing with an imagery scale                expLetter = textScale.indexOf("m");                if (expLetter == -1) {                    expLetter = textScale.indexOf("M");                    if (expLetter == -1)                        return -1; // ERROR                }                resolution = new Long(textScale.substring(0, expLetter));                return (long) (resolution.longValue() / .000150);            }            // dealing with a map scale            String expValue = "";            resolution = new Long(textScale.substring(0, colon));            expLetter = textScale.lastIndexOf('K');            expLetterSmall = textScale.lastIndexOf('k');            if (expLetter == -1 && expLetterSmall == -1) {                expLetter = textScale.lastIndexOf('M');                expLetterSmall = textScale.lastIndexOf('m');                if (expLetter != -1 || expLetterSmall != -1) {                    expValue = "000000";                }            } else {                expValue = "000";            }            StringBuffer buf;            if (!expValue.equals("")) {                // make sure we have the right index variable                if (expLetter == -1) {                    expLetter = expLetterSmall;                }                buf = new StringBuffer(textScale.substring(colon + 1, expLetter));                buf.append(expValue);            } else {                buf = new StringBuffer(textScale.substring(colon + 1));            }            String longString = buf.toString().trim();            realValue = new Long(longString);        } catch (NumberFormatException nfe) {            if (Debug.debugging("rpftoc")) {                Debug.output("textScaleToLong: Number Format Exception!!!!"                        + textScale);            }            return (long) RpfConstants.UK.scale;        } catch (StringIndexOutOfBoundsException sioobe) {            if (Debug.debugging("rpftoc")) {                Debug.output("textScaleToLong: String index out of bounds:\n"                        + sioobe.getMessage());            }            return (long) RpfConstants.UK.scale;        }        long ret = (realValue.longValue() / resolution.longValue());        if (Debug.debugging("rpftoc")) {            Debug.output("RpfTocHandler: textScaleToLong converted "                    + textScale + " to " + ret);        }        return ret;    }