code: public static Object checkValue(Object value) {
          if (null == value) return null;
          if (value instanceof Tag) return ((Tag)value).getName(); // name instead of ordinal to make decoding easier
          Object result = value;
          if (result instanceof GString) result = value.toString();
          if (result instanceof BaseAttribute) {
              if (log.isLoggable(Level.WARNING)) log.warning("An Attribute may not itself contain an attribute as a value. Assuming you forgot to call getValue().");
              result = checkValue((((BaseAttribute) value).getValue()));
          }
          boolean ok = false;
          for (Class type : SUPPORTED_VALUE_TYPES ) {
              if (type.isAssignableFrom(result.getClass())) { ok = true; break; }
          }
          if (!ok) {
              throw new IllegalArgumentException("Attribute values of this type are not allowed: " + result.getClass().getSimpleName());
          }
          return result;
      }
docs: Check whether value is of allowed type and convert to an allowed type if possible.