opendap/src/main/java/opendap/dap/Attribute.java
private static String forceValue(int type, String value)
            throws AttributeBadValueException
    {
        try {
            dispatchCheckValue(type, value);
        } catch (AttributeBadValueException abe) {
            if(type == BYTE) {// Try again: allow e.g. negative byte values
                short val = Short.parseShort(value);
                if(val > 255 && val < -128)
                    throw new AttributeBadValueException("Cannot convert to byte: " + value);
                value = Integer.toString((val&0xFF));
            }
        }
        return value;
    }
private static String forceValue(int type, String value)
            throws AttributeBadValueException
    {
        try {
            dispatchCheckValue(type, value);
        } catch (AttributeBadValueException abe) {
            if(type == BYTE) {// Try again: allow e.g. negative byte values
                short val = Short.parseShort(value);
                if(val > 255 && val < -128)
                    throw new AttributeBadValueException("Cannot convert to byte: " + value);
                value = Integer.toString((val&0xFF));
            }
        }
        return value;
    }
Check if the value is legal for a given type
and try to convert to specified type.

@param type  the type of the value.
@param value the value <code>String</code>.
@return original or converted value
@throws AttributeBadValueException if the value is not a legal
member of type