Returns the text which should be written to the configuration file for a given property value.<p>

@param obj the property value

@return the text to write for that property value
193041
private String getPropertyValueToWrite(Object obj) {

        String value;
        String valueToWrite = null;
        if (obj instanceof List<?>) {
            String[] values = {};
            values = CmsCollectionsGenericWrapper.list(obj).toArray(values);
            // write it
            valueToWrite = "\\\n" + createValueString(values);
        } else {
            value = String.valueOf(obj).trim();
            // escape commas and equals in value
            value = CmsStringUtil.substitute(value, ",", "\\,");
            // value = CmsStringUtil.substitute(value, "=", "\\=");
            // write it
            valueToWrite = value;
        }
        return valueToWrite;
    }
895476
@SuppressWarnings("PMD.AvoidCatchingThrowable")
  static String mkString(Object obj) {
    if (obj == null) {
      return "null";
    }
    try {
      return obj.toString() + " (type is " + obj.getClass() + ")";
    } catch (Throwable t) {
      return t.getClass().toString() + ": " + t.getMessage() + " (type is " + obj.getClass() + ")";
    }
  }
719033
public String objectToString(Object obj)
    {
        String string = BaseTransport.convertObjectToString(obj);
        return string;
    }
526613
public String getParameterByReflection(Object obj, String param)
    {
        Object value = null;
        try {
            java.lang.reflect.Method method = obj.getClass().getMethod("getParameter", String.class);
            
            if (method != null)
                value = method.invoke(obj, param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (value == null)
            return null;
        else
            return value.toString();
    }
1242556
public static <T> String serialize(T obj) {
        if (obj == null) {
            return "";
        }
        ByteArrayOutputStream bos = null;
        ObjectOutputStream oos = null;
        try {
            bos = new ByteArrayOutputStream();
            oos = new ObjectOutputStream(bos);
            oos.writeObject(obj);
            return CommonUtils.bytesToBase64Str(bos.toByteArray());
        } catch (Exception e) {
            throw new RuntimeException("serialize session error", e);
        } finally {
            CommonUtils.closeIOStream(null, bos);
            CommonUtils.closeIOStream(null, oos);
        }
    }
1022659
@Override
	public String toJson(Object obj) {
		try {
			String json;
			if (obj == null) {
				json = null;
			}
			else {
				json = mapper.writeValueAsString(obj);
			}
			return json;
		}
		catch (Exception e) {
			throw new JsonException(e.getMessage(), e);
		}
	}
623059
private Object propertyObj(Object obj, Element node) throws Exception {
		String id = getAttribute(node, "id");
		String name = getAttribute(node, "name");
		String defval = getAttribute(node, "default");
		Object prop = null;
		if (_propertyMap != null && _propertyMap.containsKey(name)) {
			prop = _propertyMap.get(name);
		} else {
			prop = defval;
		}
		if (id != null) {
			_idMap.put(id, prop);
		}
		if (prop != null) {
			configure(prop, node, 0);
		}
		return prop;
	}
1068053
public static <T> T getProperty(Object obj, String propertyName) {
		Method method = getGetterMethod(obj.getClass(), propertyName);
		if (method != null) {
			return invokeMethod(obj, method);
		} else {
			return getFieldValue(obj, propertyName);
		}
	}
413850
public static <P extends ParaObject> String toJSON(P obj) {
		if (obj == null) {
			return "{}";
		}
		try {
			return getJsonWriter().writeValueAsString(obj);
		} catch (Exception e) {
			logger.error(null, e);
		}
		return "{}";
	}
33501
public static Object getProperty(Object obj, String name) {
		if (obj == null)
			throw new NullPointerException("Object cannot be null");
		if (name == null)
			throw new NullPointerException("Property name cannot be null");

		Class<?> objClass = obj.getClass();

		// Search in fields
		for (Field field : objClass.getFields()) {
			try {
				if (matchField(field, name))
					return field.get(obj);
			} catch (Throwable t) {
				// Ignore exceptions
			}
		}

		// Search in properties
		name = "get" + name;
		for (Method method : objClass.getMethods()) {
			try {
				if (matchPropertyGetter(method, name))
					return method.invoke(obj);
			} catch (Throwable t) {
				// Ignore exceptions
			}
		}

		return null;
	}
32535
public static <T extends Object> T getFieldValue(Object obj, String fieldName) {
        Assert.notNull(obj, "obj不能为空");
        Assert.notNull(fieldName, "fieldName不能为空");

        Field field;
        if (obj instanceof Class) {
            field = getField((Class) obj, fieldName);
        } else {
            field = getField(obj.getClass(), fieldName);
        }

        return getFieldValue(obj, field);
    }
82025
public static <T> T getFieldValue(final Object obj, final String fieldName) {
		Field field = getField(obj.getClass(), fieldName);
		if (field == null) {
			throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + ']');
		}
		return getFieldValue(obj, field);
	}
1297459
public String getNavText() {

        String navText = "";
        try {
            navText = getCms().readPropertyObject(
                getCms().getSitePath(m_resource),
                CmsPropertyDefinition.PROPERTY_NAVTEXT,
                false).getValue();
        } catch (Throwable e) {
            String storedSiteRoot = getCms().getRequestContext().getSiteRoot();
            try {
                getCms().getRequestContext().setSiteRoot("");
                navText = getCms().readPropertyObject(
                    m_resource.getRootPath(),
                    CmsPropertyDefinition.PROPERTY_NAVTEXT,
                    false).getValue();
            } catch (Exception e1) {
                // should usually never happen
                if (LOG.isInfoEnabled()) {
                    LOG.info(e);
                }
            } finally {
                getCms().getRequestContext().setSiteRoot(storedSiteRoot);
            }
        }
        if (navText == null) {
            navText = "";
        }
        return navText;
    }
769427
public static String getPackageName(Object obj)
	{
		if(obj == null)
			throw new NullPointerException("obj is null");
		return getPackageName(obj.getClass());
	}
1256333
public static Object getProperty(Object obj, String prop, Object defaultValue) {

	// first try field
	Field[] fields = getFieldsIgnoreCase(obj.getClass(), prop, null);
	if (!ArrayUtil.isEmpty(fields)) {
	    try {
		return fields[0].get(obj);
	    }
	    catch (Throwable t) {
		ExceptionUtil.rethrowIfNecessary(t);
	    }
	}

	// then getter
	try {
	    char first = prop.charAt(0);
	    if (first >= '0' && first <= '9') return defaultValue;
	    return getGetter(obj.getClass(), prop).invoke(obj);
	}
	catch (Throwable e1) {
	    ExceptionUtil.rethrowIfNecessary(e1);
	    return defaultValue;
	}
    }
1295189
public static String getName(Object obj) {
		try {
			return obj.getClass().getAnnotation(XmlRootElement.class).name();
		} catch (NullPointerException e) {
			return obj.getClass().getAnnotation(XmlType.class).name();
		}
	}
965019
public static String object_to_string_withoutquotes(java.lang.Object obj) throws Exception {
		String str = null;

		Class<?> c = obj.getClass();
		Field[] flds = c.getDeclaredFields();
		if (flds != null) {
			for (int i = 0; i < flds.length; i++)
			{
				flds[i].setAccessible(true);
				if (flds[i].get(obj) != null)
				{
					String strtmp = "";
					if (flds[i].getType().isArray()) {
						Object tmp = flds[i].get(obj);
						if (tmp instanceof String[]) {
							String[] tmp1 = (String[])tmp;
							for (int j = 0 ;j<tmp1.length;j++) {
								strtmp += tmp1[j] + " "; 
							}
						} else if (tmp instanceof Integer[]) {
							Integer[] tmp1 = (Integer[])tmp;
							for (int j = 0 ;j<tmp1.length;j++) {
								strtmp += tmp1[j].toString() + " "; 
							}
						} else if (tmp instanceof Long[]) {
							Long[] tmp1 = (Long[])tmp;
							for (int j = 0 ;j<tmp1.length;j++) {
								strtmp += tmp1[j].toString() + " "; 
							}
						} else if (tmp instanceof Double[]) {
							Double[] tmp1 = (Double[])tmp;
							for (int j = 0 ;j<tmp1.length;j++) {
								strtmp += tmp1[j].toString() + " "; 
							}
						} else if(tmp instanceof Boolean[]) {
							Boolean[] tmp1 = (Boolean[])tmp;
							for (int j = 0 ;j<tmp1.length;j++) {
								strtmp += tmp1[j].toString() + " "; 
							}
						}						
						strtmp = strtmp.trim();
					} else {
						strtmp = flds[i].get(obj).toString();
					}
					if (str != null)
						str = str + ",";
					if (str == null)
					{
						str = flds[i].getName() + ":" + encode(strtmp);
					}
					else
					{
						str = str +flds[i].getName() + ":" + encode(strtmp);
					}
				}
			}
		}
		return str;
	}