dap4/d4core/src/main/java/dap4/core/util/CoreTypeFcns.java
static public Object
    attributeConvert(DapType type, Object value)
    {
        if(value == null) return value;
        if(type.isEnumType()) {
            if(value instanceof String) {
                // See if the constant is an int vs enum const name
                try {
                    int ival = Integer.parseInt(value.toString());
                    return ival;
                } catch (NumberFormatException nfe) {
                    // Assume it is an econst name; try to locate it
                    DapEnumConst dec = ((DapEnumeration) type).lookup(value.toString());
                    if(dec == null)
                        return value;
                    return dec.getValue();
                }
            } else if(value instanceof Long) {
              return (Long) value;
            }
        } else if(value instanceof Long) {
            return (Long) value;
        } else if(value instanceof Float) {
            return (Float) value;
        } else if(value instanceof Double) {
            return (Double) value;
        } else if(value instanceof Character) {
            return ((Character) value);
        }
        return value;
    }
static public Object
    attributeConvert(DapType type, Object value)
    {
        if(value == null) return value;
        if(type.isEnumType()) {
            if(value instanceof String) {
                // See if the constant is an int vs enum const name
                try {
                    int ival = Integer.parseInt(value.toString());
                    return ival;
                } catch (NumberFormatException nfe) {
                    // Assume it is an econst name; try to locate it
                    DapEnumConst dec = ((DapEnumeration) type).lookup(value.toString());
                    if(dec == null)
                        return value;
                    return dec.getValue();
                }
            } else if(value instanceof Long) {
              return (Long) value;
            }
        } else if(value instanceof Long) {
            return (Long) value;
        } else if(value instanceof Float) {
            return (Float) value;
        } else if(value instanceof Double) {
            return (Double) value;
        } else if(value instanceof Character) {
            return ((Character) value);
        }
        return value;
    }
static public Object attributeConvert ( DapType type , Object value ) { if ( value == null ) return value ; if ( type . isEnumType ( ) ) { if ( value instanceof String ) { // See if the constant is an int vs enum const name try { int ival = Integer . parseInt ( value . toString ( ) ) ; return ival ; } catch ( NumberFormatException nfe ) { // Assume it is an econst name; try to locate it DapEnumConst dec = ( ( DapEnumeration ) type ) . lookup ( value . toString ( ) ) ; if ( dec == null ) return value ; return dec . getValue ( ) ; } } else if ( value instanceof Long ) { return ( Long ) value ; } } else if ( value instanceof Long ) { return ( Long ) value ; } else if ( value instanceof Float ) { return ( Float ) value ; } else if ( value instanceof Double ) { return ( Double ) value ; } else if ( value instanceof Character ) { return ( ( Character ) value ) ; } return value ; }
Force an attribute value (typically string)
to match a given basetype

@param type  expected type
@param value actual value
@return the value as made to conform to the expected type
Force an attribute value ( typically string ) to match a given basetype