Converts the string value to the java object for the given primitive category

@param value
the value
@param primitiveCategory
the primitive category
@return the java object
549468
public static Object getPrimitiveValue(String value, PrimitiveCategory primitiveCategory) {
        if (value != null) {
            try {
                switch (primitiveCategory) {
                    case BOOLEAN:
                        return Boolean.valueOf(value);
                    case BYTE:
                        return Byte.valueOf(value);
                    case DOUBLE:
                        return Double.valueOf(value);
                    case FLOAT:
                        return Float.valueOf(value);
                    case INT:
                        return Integer.valueOf(value);
                    case LONG:
                        return Long.valueOf(value);
                    case SHORT:
                        return Short.valueOf(value);
                    case STRING:
                        return value;
                    default:
                        throw new IllegalStateException(primitiveCategory.toString());
                }
            } catch (Exception ignored) {
            }
        }
        return null;
    }
787795
public T convert(Object value)
    {
        T result = null;
        if (value != null)
        {
            if (getValueClass().isInstance(value))
                result = getValueClass().cast(value);
            else
                result = convertFromString(value.toString());
        }
        return result;
    }
412074
public static Optional<Class> getPrimitiveType(String primitiveType) {
        return Optional.ofNullable(PRIMITIVE_TYPE_MAP.get(primitiveType));
    }
460854
private static Converter<List<String>, Object> createListConverter(Type resultType) {
    // Use boxed type if raw type is primitive type. Otherwise the type won't change.
    Class<?> resultClass = getRawClass(resultType);

    // For string, just return the first value
    if (resultClass == String.class) {
      return new BasicConverter(defaultValue(resultClass)) {
        @Override
        protected Object convert(String value) throws Exception {
          return value;
        }
      };
    }

    // Creates converter based on the type

    // Primitive
    Converter<List<String>, Object> converter = createPrimitiveTypeConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // String constructor
    converter = createStringConstructorConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Static string argument methods
    converter = createStringMethodConverter(resultClass);
    if (converter != null) {
      return converter;
    }

    // Collection
    converter = createCollectionConverter(resultType);
    if (converter != null) {
      return converter;
    }

    throw new IllegalArgumentException("Unsupported type " + resultType + " of type class " + resultType.getClass());
  }
1103190
public void printJavaTypeToObject(String value, JClass javaType)
      throws IOException
  {
    if (javaType.getName().equals("boolean"))
      print("new Boolean(" + value + ")");
    else if (javaType.getName().equals("byte"))
      print("new Byte(" + value + ")");
    else if (javaType.getName().equals("short"))
      print("new Short(" + value + ")");
    else if (javaType.getName().equals("int"))
      print("new Integer(" + value + ")");
    else if (javaType.getName().equals("long"))
      print("new Long(" + value + ")");
    else if (javaType.getName().equals("char"))
      print("String.valueOf(" + value + ")");
    else if (javaType.getName().equals("float"))
      print("new Float(" + value + ")");
    else if (javaType.getName().equals("double"))
      print("new Double(" + value + ")");
    else
      print(value);
  }
51097
private static final ArrayList<String> convertStringToArrayList(String value) {
        if (value != null && value.length() > 0) {
            ArrayList<String> result = new ArrayList<String>();
            StringTokenizer st = new StringTokenizer(value, STRING_ATTRIB_DELIM);
            while (st.hasMoreTokens()) {
                String nextString = unescape(st.nextToken());
                if (nextString != null) {
                    result.add(nextString);
                }
            }
            return result;
        }
        return null;
    }
1353421
public Object convertStringToJavaField(String value, int columnPos) throws SQLException {
		if (value == null) {
			return null;
		} else {
			return fieldConverter.resultStringToJava(this, value, columnPos);
		}
	}
73743
public void addCategory(String categoryPath) {

        m_searchObject.addCategory(categoryPath);
        m_searchObjectChanged = true;
        ValueChangeEvent.fire(this, m_searchObject);
    }
202492
@Nullable
  private static Object convertPrimitiveField(Group g, int fieldIndex, boolean binaryAsString)
  {
    PrimitiveType pt = (PrimitiveType) g.getType().getFields().get(fieldIndex);
    if (pt.isRepetition(Type.Repetition.REPEATED) && g.getFieldRepetitionCount(fieldIndex) > 1) {
      List<Object> vals = new ArrayList<>();
      for (int i = 0; i < g.getFieldRepetitionCount(fieldIndex); i++) {
        vals.add(convertPrimitiveField(g, fieldIndex, i, binaryAsString));
      }
      return vals;
    }
    return convertPrimitiveField(g, fieldIndex, 0, binaryAsString);
  }
19925
public static List<String> categoriesFromString(String categoriesList) {
		List<String> result = new ArrayList<String>();
		try {
			if (categoriesList != null) {
				String[] categories = categoriesList.split(DescribeService.CATEGORY_SEPARATOR);
				if (categories != null && categories.length != 0) {
					for (String cat : categories) {
						result.add(cat);
					}
				}
			}
		} catch (Exception ignore) {
			logger.warn("DescribeService", ignore);
		}

		return result;
	}
162531
@Nullable
  private static Converter<List<String>, Object> createPrimitiveTypeConverter(final Class<?> resultClass) {
    Object defaultValue = defaultValue(resultClass);

    if (defaultValue == null) {
      // For primitive type, the default value shouldn't be null
      return null;
    }

    return new BasicConverter(defaultValue) {
      @Override
      protected Object convert(String value) throws Exception {
        return valueOf(value, resultClass);
      }
    };
  }
291352
public void setProperty(String category, String key, Object value) {
		this.setProperty(category, key, value.toString());
	}
482595
public static Object convertValue(final Object value, final Class<?> convertType) {
        if (null == value) {
            return convertNullValue(convertType);
        } 
        if (value.getClass() == convertType) {
            return value;
        }
        if (value instanceof Number) {
            return convertNumberValue(value, convertType);
        }
        if (value instanceof Date) {
            return convertDateValue(value, convertType);
        }
        if (String.class.equals(convertType)) {
            return value.toString();
        } else {
            return value;
        }
    }
1022562
public <T> T to(Class<T> targetType) {
        if (targetType == String.class) {
            return (T) value;
        }
        try {
            final String methodName;
            final Class type;
            if (targetType.isPrimitive()) {
                final String typeName = targetType.getSimpleName();
                methodName = "parse" + typeName.substring(0, 1).toUpperCase() + typeName.substring(1);
                type = PRIMITIVE_TO_OBJECT_TYPE_MAP.get(targetType);
            } else {
                methodName = "valueOf";
                type = targetType;
            }
            return (T) type.getMethod(methodName, String.class).invoke(null, value);
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
            throw new RuntimeException("Could not convert value '" + value + "' to type " + targetType.getName(), e);
        }
    }
1314178
public static Object toBasicType(String value, String type) throws SQLException {

        // Early return from first "if" condition that evaluates to true

        if (value == null) {
            return null;
        }

        if (type == null || type.equals(String.class.getName())) {
            return value;
        }

        if (type.equals(Integer.class.getName()) || type.equals(int.class.getName())) {
            try { return Integer.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Integer", value);
            }
        }

        if (type.equals(Float.class.getName()) || type.equals(float.class.getName())) {
            try { return Float.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Float", value);
            }
        }

        if (type.equals(Long.class.getName()) || type.equals(long.class.getName())) {
            try { return Long.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Long", value);
            }
        }

        if (type.equals(Double.class.getName()) || type.equals(double.class.getName())) {
            try { return Double.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Double", value);
            }
        }

        if (type.equals(Character.class.getName()) || type.equals(char.class.getName())) {
            if (value.length() != 1) {
                throw new SQLException("Invalid Character value: " + value);
            }
            return value.charAt(0);
        }

        if (type.equals(Byte.class.getName()) || type.equals(byte.class.getName())) {
            try { return Byte.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Byte", value);
            }
        }

        if (type.equals(Short.class.getName()) || type.equals(short.class.getName())) {
            try { return Short.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Short", value);
            }
        }

        // Will be "false" if not in correct format...
        if (type.equals(Boolean.class.getName()) || type.equals(boolean.class.getName())) {
            return Boolean.valueOf(value);
        }

        throw new SQLException("Unrecognized property type: " + type);
    }
524885
protected Object convertNullValue(Class type) throws ConversionException {
        try {
            return type.isPrimitive() ? Array.get(Array.newInstance(type, 1), 0) : null;
        } catch (Exception e) {
            throw new ConversionException(String.format("Could not convert null to primitive type <%s>", type), e);
        }
    }
411528
@SuppressWarnings("unchecked")
  public static <T> T stringToObject(String value, Class<T> type) {
    if (value == null) {
      return null;
    }
    if (type == String.class) {
      return (T)value;
    }
    else if (type == String[].class) {
      return (T)decodeString(splitPreserveAllTokens(value, ARRAY_DELIMITER_CHAR));
    }
    if (type == Integer.class) {
      return (T)(Integer)NumberUtils.toInt(value, 0);
    }
    if (type == Long.class) {
      return (T)(Long)NumberUtils.toLong(value, 0L);
    }
    if (type == Double.class) {
      return (T)(Double)NumberUtils.toDouble(value, 0d);
    }
    if (type == Boolean.class) {
      return (T)(Boolean)BooleanUtils.toBoolean(value);
    }
    if (type == Map.class) {
      String[] rows = splitPreserveAllTokens(value, ARRAY_DELIMITER_CHAR);
      Map<String, String> map = new LinkedHashMap<>();
      for (int i = 0; i < rows.length; i++) {
        String[] keyValue = splitPreserveAllTokens(rows[i], KEY_VALUE_DELIMITER_CHAR);
        if (keyValue.length == 2 && StringUtils.isNotEmpty(keyValue[0])) {
          map.put(decodeString(keyValue[0]), StringUtils.isEmpty(keyValue[1]) ? null : decodeString(keyValue[1]));
        }
      }
      return (T)map;
    }
    throw new IllegalArgumentException("Unsupported type: " + type.getName());
  }