Gets the string representation of the submitted object and never returns {@code null}.

@param o the object to get the string representation of.
@return the string representation of the submitted object (never {@code null}).
428397
@SuppressWarnings("null")
	public static String valueOf(@Nullable Object o) {
		return String.valueOf(String.valueOf(o));
	}
990369
public static String convertSerializableToString(Serializable obj) {
        ByteArrayOutputStream baos = null;
        ObjectOutputStream oos = null;
        try {
            baos = new ByteArrayOutputStream();
            oos = new ObjectOutputStream(baos);
            oos.writeObject(obj);

            return new String(baos.toByteArray());
        } catch (IOException e) {
            return null;
        } finally {
            closeQuietly(baos, oos);
            closeQuietly(oos);
        }
    }
216795
public static String encode(Serializable o) {
                ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
            try {
                        ObjectOutputStream oos = new ObjectOutputStream(bos);
                        try {
                                oos.writeObject(o);
                                oos.flush();
                        } finally {
                                oos.close();
                        }
                        return Base64.encodeBytes(bos.toByteArray());
                } catch (IOException e) {
                        throw new RuntimeException(e);
                }
        }
196880
String _serialize(Object o) {
        String body = null;
            try {
                body = new String(serialize(o));
            } catch (IOException e) {
                throw new ServiceException(ErrorCode.HTTP_CLIENT_ERROR,
                        ErrorCode.HTTP_CLIENT_ERROR.getMessageTemplate(),
                        "serialize failed.");
            }
        return body;
    }
1373093
public byte[] serializeToBytes(final Serializable o) {
        byte[] bytes = null;
        try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
             final ObjectOutputStream oos = new ObjectOutputStream(baos)) {
            oos.writeObject(o);
            oos.flush();
            bytes = baos.toByteArray();
        } catch (final IOException e) {
            logger.warn("cannot Java serialize object", e);
        }
        return bytes;
    }
901592
public static String deepToString(final Object obj) {
        if (obj == null) {
            return NULL_STRING;
        }

        if (obj.getClass().isArray()) {
            return typeOf(obj.getClass()).deepToString(obj);
        }

        return obj.toString();
    }
640056
public static String getString(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asString();
    }
52974
public String objectToString() {
		try {
			checkForDao();
		} catch (SQLException e) {
			throw new IllegalArgumentException(e);
		}
		@SuppressWarnings("unchecked")
		T t = (T) this;
		return dao.objectToString(t);
	}
1053328
@Override
    public String convertToString(T object) {
        try {
            return (String) toString.invoke(object);
        } catch (IllegalAccessException ex) {
            throw new IllegalStateException("Method is not accessible: " + toString);
        } catch (InvocationTargetException ex) {
            if (ex.getCause() instanceof RuntimeException) {
                throw (RuntimeException) ex.getCause();
            }
            throw new RuntimeException(ex.getMessage(), ex.getCause());
        }
    }
729177
public static String toMMCIF(String categoryName, Object o) {

		StringBuilder sb = new StringBuilder();

		Class<?> c = o.getClass();


		Field[] fields = getFields(c);
		String[] names = getFieldNames(fields);

		int maxFieldNameLength = getMaxStringLength(names);

		for (int i=0;i<fields.length;i++) {
			Field f = fields[i];
			String name = names[i];

			sb.append(categoryName).append(".").append(name);

			int spacing = maxFieldNameLength - name.length() + 3;

			try {
				Object obj = f.get(o);
				String val;
				if (obj==null) {
					logger.debug("Field {} is null, will write it out as {}",name,MMCIF_MISSING_VALUE);
					val = MMCIF_MISSING_VALUE;
				} else {
					val = (String) obj;
				}
				for (int j=0;j<spacing;j++) sb.append(' ');
				sb.append(addMmCifQuoting(val));
				sb.append(newline);

			} catch (IllegalAccessException e) {
				logger.warn("Field {} is inaccessible", name);
				continue;
			} catch (ClassCastException e) {
				logger.warn("Could not cast value to String for field {}",name);
				continue;
			}

		}

		sb.append(SimpleMMcifParser.COMMENT_CHAR+newline);

		return sb.toString();
	}
6564
public static String toJSONString(final Object obj) {
        try {
            return mapper.writeValueAsString(obj);
        } catch (final JsonProcessingException e) {
            logger.error("Cannot to JSON string", e);
        }
        return null;
    }
812880
protected String getMessageCode(Object o) {
		if (o instanceof TypeResolvable) {
			String type = ((TypeResolvable) o).getType();
			if (type != null) {
				return type;
			}
		}
		return ClassUtils.getShortNameAsProperty(o.getClass());
	}
505457
public String objectToString(T object) {
		StringBuilder sb = new StringBuilder(64);
		sb.append(object.getClass().getSimpleName());
		for (FieldType fieldType : fieldTypes) {
			sb.append(' ').append(fieldType.getColumnName()).append('=');
			try {
				sb.append(fieldType.extractJavaFieldValue(object));
			} catch (Exception e) {
				throw new IllegalStateException("Could not generate toString of field " + fieldType, e);
			}
		}
		return sb.toString();
	}
336947
public static String convertObjectToString(Object obj)
    {
        try {
            ByteArrayOutputStream writer = new ByteArrayOutputStream();
            ObjectOutputStream outStream = new ObjectOutputStream(writer);
            outStream.writeObject(obj);
            outStream.flush();
            writer.flush();
            String string = writer.toString(Constant.OBJECT_ENCODING);//Constants.STRING_ENCODING);
            writer.close();
            outStream.close();
            return string;
        } catch (IOException ex)    {
            ex.printStackTrace();   // Never
        }
        return null;
    }
1261762
public static String convertObjectToString(Object objData)
    {
        if (objData == null)
            return null;
        try {
            return Utility.convertObjectToString(objData, objData.getClass(), null);
        } catch (Exception ex) {
            return null;
        }
    }
264505
public <T> String marshal(final T object) {

        if (object == null) {
            throw new IllegalArgumentException("object parameter is null");
        }

        ObjectWriter writer = objectMapper.writer().withDefaultPrettyPrinter();
        String results = null;
        try {
            results = writer.writeValueAsString(object);
        } catch (JsonGenerationException e) {
            System.err.println("JsonGenerationException, message=" + e.getMessage());
        } catch (JsonMappingException e) {
            e.printStackTrace();
            System.err.println("JsonMappingException, message=" + e.getMessage());
        } catch (IOException e) {
            System.err.println("IOException, message=" + e.getMessage());
        }

        return (results);
    }
521619
public static String serializeAsString(Object o) throws IOException {
        try {
            JsonStructure builtJsonObject = findFieldsToSerialize(o).mainObject;
            return builtJsonObject.toString();
        } catch (IllegalStateException ise) {
            // the reflective attempt to build the object failed.
            throw new IOException("Unable to build JSON for Object", ise);
        } catch (JsonException e) {
            throw new IOException("Unable to build JSON for Object", e);
        }
    }