将对象转成数组.
@param obj 对象
@return 数组
324191
@SuppressWarnings("rawtypes")
    private Object[] convertToArray(Object obj) {
        // 获取参数的集合信息，并转换成数组
        Object[] values;
        if (obj instanceof Collection) {
            values = ((Collection) obj).toArray();
        } else if (obj.getClass().isArray()) {
            values = (Object[]) obj;
        } else {
            values = new Object[]{obj};
        }
        return values;
    }
824887
public static List<String> getMethodNames(Object obj) {
		List<String> methods = new ArrayList<String>();

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

		for (Method method : objClass.getMethods()) {
			if (matchMethod(method, method.getName())) {
				methods.add(method.getName());
			}
		}

		return methods;
	}
506536
public static JSON parse(Object obj) {
		if (null == obj) {
			return null;
		}

		JSON json = null;
		if (obj instanceof JSON) {
			json = (JSON) obj;
		} else if (obj instanceof String) {
			String jsonStr = ((String) obj).trim();
			if (jsonStr.startsWith("[")) {
				json = parseArray(jsonStr);
			} else {
				json = parseObj(jsonStr);
			}
		} else if (obj instanceof Collection || obj.getClass().isArray()) {// 列表
			json = new JSONArray(obj);
		} else {// 对象
			json = new JSONObject(obj);
		}

		return json;
	}
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();
    }
  }
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;
    }
1166038
@Override
    public byte[] serialize(Object obj) throws IOException {
		KryoHolder kryoHolder = null;
		if (obj == null)
			throw new RuntimeException("obj can not be null");
		try {
			kryoHolder = KryoPoolImpl.getInstance().get();
			kryoHolder.output.clear(); // clear Output -->每次调用的时候 重置
			kryoHolder.kryo.writeClassAndObject(kryoHolder.output, obj);
			return kryoHolder.output.toBytes();// 无法避免拷贝 ~~~
		} catch (RuntimeException e) {
			throw new RuntimeException(e);
		} finally {
			if (kryoHolder != null) {
				KryoPoolImpl.getInstance().offer(kryoHolder);
			}
			// obj = null; //GC
		}
    }
1007186
public static PBKDF2Params getInstance(Object obj)
    {
        if (obj instanceof PBKDF2Params) {
            return (PBKDF2Params) obj;
        }

        if (obj instanceof org.bouncycastle.asn1.pkcs.PBKDF2Params) {
            org.bouncycastle.asn1.pkcs.PBKDF2Params params = (org.bouncycastle.asn1.pkcs.PBKDF2Params) obj;
            if (params.getKeyLength() != null) {
                return new PBKDF2Params(params.getSalt(),
                    params.getIterationCount().intValue(), params.getKeyLength().intValue());
            } else {
                return new PBKDF2Params(params.getSalt(), params.getIterationCount().intValue());
            }
        }

        if (obj != null) {
            return new PBKDF2Params(ASN1Sequence.getInstance(obj));
        }

        return null;
    }
1374064
public static Class<?> getNamedClass(Object obj) {
		Class<?> cls = getClass(obj);
		while (cls != null && cls.isAnonymousClass()) {
			cls = cls.getEnclosingClass();
		}
		return cls;
	}
884932
public static Object[] getFieldsValue(Object obj) {
		if (null != obj) {
			final Field[] fields = getFields(obj.getClass());
			if (null != fields) {
				final Object[] values = new Object[fields.length];
				for (int i = 0; i < fields.length; i++) {
					values[i] = getFieldValue(obj, fields[i]);
				}
				return values;
			}
		}
		return null;
	}
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);
        }
    }
110580
public static String format(Object object) {
        Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
        JsonParser jp = new JsonParser();
        JsonElement je = jp.parse(gson.toJson(object));
        String prettyJsonString = gson.toJson(je);
        //简单处理function
        String[] lines = prettyJsonString.split("\n");
        lines = replaceFunctionQuote(lines);
        StringBuilder stringBuilder = new StringBuilder();
        for (String line : lines) {
            stringBuilder.append(line);
        }
        return stringBuilder.toString();
    }
1182540
public static byte[] serialize(Object obj) throws IOException {
    if (obj == null) {
      return null;
    }
    try (ByteArrayOutputStream b = new ByteArrayOutputStream()) {
      try (ObjectOutputStream o = new ObjectOutputStream(b)) {
        o.writeObject(obj);
      }
      return b.toByteArray();
    }
  }
425867
public String getAlias(Object obj) {
        if (obj == null)
            return null;

        return getClassAlias(obj.getClass());
    }
282614
public Iterator<?> getBshIterator(final Object obj) {
        if (obj == null)
            return this.emptyIt();
        if (obj instanceof Primitive)
            return this.getBshIterator(Primitive.unwrap(obj));
        if (obj.getClass().isArray())
            return this.arrayIt(obj);
        if (obj instanceof Iterable)
            return this.getBshIterator((Iterable<?>) obj);
        if (obj instanceof Iterator)
            return this.getBshIterator((Iterator<?>) obj);
        if (obj instanceof Enumeration)
            return this.getBshIterator((Enumeration<?>) obj);
        if (obj instanceof CharSequence)
            return this.getBshIterator((CharSequence) obj);
        if (obj instanceof Number)
            return this.getBshIterator((Number) obj);
        if (obj instanceof Character)
            return this.getBshIterator((Character) obj);
        if (obj instanceof String)
            return this.getBshIterator((String) obj);
        return this.reflectNames(obj).iterator();
    }
133276
protected static String prettyPrint(Object obj){
		StringBuilder sb = new StringBuilder();
		if (obj == null){
			sb.append("NULL");
		} else 	if (obj instanceof Blob){
			sb.append(formatLogParam((Blob)obj));
		} else if (obj instanceof Clob){
			sb.append(formatLogParam((Clob)obj));
		} else if (obj instanceof Ref){
			sb.append(formatLogParam((Ref)obj));
		} else if (obj instanceof Array){
			sb.append(formatLogParam((Array)obj));
		} else if (obj instanceof String || obj instanceof Date){
			sb.append("'" + obj.toString()+"'");
		} else {
			sb.append(obj.toString());
		}
		return sb.toString();
	}
276598
public static Object[] toArray(Object obj)
	{
		if (obj instanceof Object[])
			return (Object[]) obj;
		else
		{
			Object[] returnArray =
			{ obj };
			return returnArray;

		}
	}
1247796
public static Map<String, Object> getProperties(Object obj) {
		Map<String, Object> map = new HashMap<String, Object>();

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

		// Get all fields
		for (Field field : objClass.getFields()) {
			try {
				if (matchField(field, field.getName())) {
					String name = field.getName();
					Object value = field.get(obj);
					map.put(name, value);
				}
			} catch (Throwable t) {
				// Ignore exception
			}
		}

		// Get all properties
		for (Method method : objClass.getMethods()) {
			try {
				if (method.getName().startsWith("get") && matchPropertyGetter(method, method.getName())) {
					String name = method.getName().substring(3);
					name = name.substring(0, 1).toLowerCase() + name.substring(1);
					Object value = method.invoke(obj);
					map.put(name, value);
				}
			} catch (Throwable t) {
				// Ignore exception
			}
		}

		return map;
	}