Create a string suitable for logging the given object

@param object The object
@return The string
193817
private static String createLoggingString(Object object)
    {
        if (object == null)
        {
            return "null";
        }
        Class<? extends Object> objectClass = object.getClass();
        if (!objectClass.isArray())
        {
            return String.valueOf(object);
        }
        StringBuilder sb = new StringBuilder();
        int length = Array.getLength(object);
        sb.append("[");
        for (int i = 0; i < length; i++)
        {
            if (i > 0)
            {
                sb.append(", ");
            }
            Object element = Array.get(object, i);
            sb.append(createLoggingString(element));
        }
        sb.append("]");
        return sb.toString();
    }
466745
public static Object getId(Object object) {
		Objects.nonNull(object);
		try {
			Field idField = getIdField(object.getClass());
			if (idField == null) throw new IllegalArgumentException(object.getClass().getName() + " has no id field to get");
			Object id = idField.get(object);
			return id;
		} catch (SecurityException | IllegalAccessException e) {
			throw new LoggingRuntimeException(e, logger, "getting Id failed");
		}
	}
191368
public final byte[] serialize(Object object) throws IOException {
        if (object == null)
            return null;

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        SerializationService serializationSvc = serializationSvcRef.getServiceWithException();
        ObjectOutputStream oout = serializationSvc.createObjectOutputStream(new DeflaterOutputStream(bout));
        oout.writeObject(object);
        oout.flush();
        oout.close();
        byte[] bytes = bout.toByteArray();
        return bytes;
    }
368276
public static Object quoteIfString(Object obj) {
        return obj instanceof String ? quote((String) obj) : obj;
    }
159910
protected String toFFDCStringSingleObject(Object obj)
  {
    if (obj == null)
    {
      return "<null>";
    }
    else if (obj instanceof Traceable)
    {
      return ((Traceable) obj).toTraceString();
    }
    else if (obj instanceof String)
    {
      return ((String) obj);
    }
    else if (obj instanceof byte[])
    {
      return toFFDCString((byte[]) obj);
    }
    else
    {
      return obj.toString();
    }
  }
567714
public String serialize(Object object) {
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Serializing object to Json");
		}
		XStream xstream = new XStream(new JettisonMappedXmlDriver());
		String json = xstream.toXML(object);
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Object serialized well");
		}
		return json;
	}
28927
public static String serialise(Object object) {
        Gson gson = getBuilder().create();
        return gson.toJson(object);
    }
852696
public static String nn(Object object, Object defaultString) {
        if (object == null || object.toString().isEmpty()) {
            return defaultString == null ? "" : defaultString.toString();
        }

        return object.toString();
    }
63887
private static String jsonEncode(Object object) throws IOException {
      
      ObjectMapper mapper = new ObjectMapper();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      try {
         mapper.writeValue(outputStream, object);
         return new String(outputStream.toByteArray());
      } catch (JsonGenerationException e) {
         logger.severe("unable encode");
         throw new IOException(e);
      } catch (JsonMappingException e) {
         logger.severe("unable encode");
         throw new IOException(e.getMessage());
      }
      
   }
1204191
public Object getProperty(Object object) {
        return java.lang.reflect.Array.getLength(object);
    }
126090
public static String fieldsToString (Object object, String sep)
    {
        StringBuilder buf = new StringBuilder("[");
        fieldsToString(buf, object, sep);
        return buf.append("]").toString();
    }
146331
public void writeFields (Object object) {
		Class type = object.getClass();

		Object[] defaultValues = getDefaultValues(type);

		OrderedMap<String, FieldMetadata> fields = getFields(type);
		int i = 0;
		for (FieldMetadata metadata : new OrderedMapValues<FieldMetadata>(fields)) {
			Field field = metadata.field;
			try {
				Object value = field.get(object);
				if (defaultValues != null) {
					Object defaultValue = defaultValues[i++];
					if (value == null && defaultValue == null) continue;
					if (value != null && defaultValue != null) {
						if (value.equals(defaultValue)) continue;
						if (value.getClass().isArray() && defaultValue.getClass().isArray()) {
							equals1[0] = value;
							equals2[0] = defaultValue;
							if (Arrays.deepEquals(equals1, equals2)) continue;
						}
					}
				}

				if (debug) System.out.println("Writing field: " + field.getName() + " (" + type.getName() + ")");
				writer.name(field.getName());
				writeValue(value, field.getType(), metadata.elementType);
			} catch (IllegalAccessException ex) {
				throw new JsonException("Error accessing field: " + field.getName() + " (" + type.getName() + ")", ex);
			} catch (JsonException ex) {
				ex.addTrace(field + " (" + type.getName() + ")");
				throw ex;
			} catch (Exception runtimeEx) {
				JsonException ex = new JsonException(runtimeEx);
				ex.addTrace(field + " (" + type.getName() + ")");
				throw ex;
			}
		}
	}
123819
public String format(String key,
                         Object object) {
        if (traceNLS != null) {
            return traceNLS.getFormattedMessage(key, new Object[] { object }, defaultMessage);
        } else {
            return objectsToString(key, object);
        }
    }
809817
public static function log($object)
    {
        $cwd = getcwd();
        $log = $cwd.'/producer.log';

        foreach (func_get_args() as $object) {
            if (is_array($object)) {
                $msg = 'array('.count($object).'):'.json_encode($object);
            } elseif (is_object($object) && !method_exists($object, '__toString')) {
                $msg = 'object('.get_class($object).'):'.json_encode($object);
            } else {
                $msg = $object;
            }
            file_put_contents($log, '>  '.trim($msg)."\n", FILE_APPEND);
        }
    }
1077886
private String safeToString(Object obj)
	{
		String toString = null;
		if (obj != null)
		{
		    try
		    {
		        toString = obj.toString();
		    }
		    catch (Throwable ex)
		    {
		        toString = "BAD toString() impl for " + obj.getClass().getName();
		    }
		}
		return toString;
	}
728167
public String from(Object obj) {
                StringBuilder sb = new StringBuilder(str);
                Method[] methods = obj.getClass().getMethods();
                Field[] fields = obj.getClass().getDeclaredFields();
                int lastIndex = -1;
                out:
                while (true) {
                        int start = sb.indexOf("${", lastIndex) + 2;
                        if (start == 1) {
                                break;
                        }
                        int end = sb.indexOf("}", start);
                        if (end == -1 || start == end) {
                                break;
                        }
                        String name = sb.substring(start, end);
                        // check functional methods
                        for (Method m : methods) {
                                String mName = m.getName();
                                if (m.getParameterTypes().length == 0 && m.getReturnType() != Void.TYPE && mName.equals(name)) {
                                        m.setAccessible(true);
                                        try {
                                                sb.replace(start - 2, end + 1, m.invoke(obj, new Object[0]).toString());
                                        } catch (Exception e) {
                                                throw $(e);
                                        }
                                        lastIndex = end;
                                        continue out;
                                }
                        }
                        // check getter
                        for (Method m : methods) {
                                String mName = m.getName();
                                if (m.getParameterTypes().length == 0 && m.getReturnType() != Void.TYPE
                                        && mName.equals("get" + name.substring(0, 1).toUpperCase() + name.substring(1))) {
                                        m.setAccessible(true);
                                        try {
                                                sb.replace(start - 2, end + 1, m.invoke(obj, new Object[0]).toString());
                                        } catch (Exception e) {
                                                throw $(e);
                                        }
                                        lastIndex = end;
                                        continue out;
                                }
                        }
                        // check field
                        for (Field f : fields) {
                                if (f.getName().equals(name)) {
                                        f.setAccessible(true);
                                        try {
                                                sb.replace(start - 2, end + 1, f.get(obj).toString());
                                        } catch (Exception e) {
                                                throw $(e);
                                        }
                                        lastIndex = end;
                                        continue out;
                                }
                        }
                        lastIndex = end;
                }
                str = sb.toString();
                return str;
        }
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();
	}