code: public static Object readPrimitive(Class<?> clazz, String value) throws Exception {
          if (clazz == String.class) {
              return value;
          } else if (clazz == Long.class) {
              return Long.parseLong(value);
          } else if (clazz == Integer.class) {
              return Integer.parseInt(value);
          } else if (clazz == Double.class) {
              return Double.parseDouble(value);
          } else if (clazz == Boolean.class) {
              return Boolean.parseBoolean(value);
          } else if (clazz == Byte.class) {
              return Byte.parseByte(value);
          } else if (clazz == Short.class) {
              return Short.parseShort(value);
          } else if (clazz == Float.class) {
              return Float.parseFloat(value);
          } else {
              throw new Exception("Unsupported primitive: " + clazz); //$NON-NLS-1$
          }
      }
docs: Parses the String value as a primitive or a String, depending on its type.
  @param clazz the destination type
  @param value the value to parse
  @return the parsed value
  @throws Exception