Creates a string for an object based on the MetaField annotations.
@param obj The object to search
@return A string representing the current values of any MetaFields
779805
public static String toMetaFieldInfoString(Object obj) {
        StringBuffer buf = new StringBuffer(100);
        MetaFieldInfo[] fields = toMetaFieldInfoArray(obj, null, true);
        for (int i = 0; i < fields.length; i++) {
            MetaFieldInfo field = fields[i];
            buf.append(field.name);
            buf.append("=");
            // if the field's actual value is non-null and of type String
            if (field.actualValue != null && field.actualValue.getClass().equals(String.class)) {
                buf.append('"');
                buf.append(field.value);
                buf.append('"');
            } else {
                buf.append(field.value);
            }
            // if not last element, delimit with a comma
            if (i+1 < fields.length)
                buf.append(",");
        }
        return buf.toString();
    }
1160511
public static ObjectNode getObjAndRemove(ObjectNode obj, String fieldName) {
		ObjectNode result = null;
		if (obj != null) {
			result = obj(remove(obj, fieldName));
		}
		return result;
	}
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;
    }
511387
public static String unpackString(Object obj) {
        Object value = unpack(obj);
        return value == null ? null : value.toString();
    }
253790
public static DERUTF8String getInstance(
        Object  obj)
    {
        if (obj == null || obj instanceof DERUTF8String)
        {
            return (DERUTF8String)obj;
        }

        if (obj instanceof ASN1OctetString)
        {
            return new DERUTF8String(((ASN1OctetString)obj).getOctets());
        }

        if (obj instanceof ASN1TaggedObject)
        {
            return getInstance(((ASN1TaggedObject)obj).getObject());
        }

        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
    }
1013328
function stringify(obj) {
  if (!isObject(obj)) {
    throw new Error('`Stringify`\'s first argument should be an object')
  }

  var meta = Object.keys(obj)
    .map(function (key) {
      return getLine(key, obj[key])
    }).join('')

  return '// ==UserScript==\n' + meta + '// ==/UserScript==\n'
}
161992
public static Object getFieldValue(Object obj, String fieldName) throws UtilException {
		if (null == obj || StrUtil.isBlank(fieldName)) {
			return null;
		}
		return getFieldValue(obj, getField(obj.getClass(), fieldName));
	}
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);
        }
    }
584784
public static String toJsonString(Object obj, ClassLoader classLoader) {
        if (obj == null) {
            return "null";
        }
        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null) {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
        try {
            ObjectMapper mapper = poolMapper.borrowObject();
            if (mapper != null) {
                try {
                    return mapper.writeValueAsString(obj);
                } finally {
                    poolMapper.returnObject(mapper);
                }
            }
            throw new SerializationException("No ObjectMapper instance avaialble!");
        } catch (Exception e) {
            throw e instanceof SerializationException ? (SerializationException) e
                    : new SerializationException(e);
        } finally {
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
    }
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;
	}
1264201
public static String encodeAsString(Object obj,NamingStyle namingStyle){
		return encodeAsString(obj, namingStyle, true);
	}
1109018
@Override
    public void visitField(Field obj) {
        String fieldSig = obj.getSignature();
        if ("Ljavax/swing/JLabel;".equals(fieldSig)) {
            FieldAnnotation fa = FieldAnnotation.fromVisitedField(this);

            fieldLabels.add(XFactory.createXField(fa));
        }
    }
838387
public static Object getFieldValue(Object obj, Field field) throws UtilException {
		if (null == obj || null == field) {
			return null;
		}
		field.setAccessible(true);
		Object result = null;
		try {
			result = field.get(obj);
		} catch (IllegalAccessException e) {
			throw new UtilException(e, "IllegalAccess for {}.{}", obj.getClass(), field.getName());
		}
		return result;
	}
600820
public static String toJson(Object obj) {
		ObjectMapper mapper = new ObjectMapper();
		try {
			return mapper.writeValueAsString(obj);
		} catch (IOException e) {
			JK.throww(e);
			return null;
		}
	}
204628
public static Object getFieldValue(final Object obj, final String fieldName) {
		Field field = getAccessibleField(obj, fieldName);

		if (field == null) {
			throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]");
		}

		Object result = null;
		try {
			result = field.get(obj);
		} catch (IllegalAccessException e) {
			logger.error("不可能抛出的异常{}", e.getMessage());
		}
		return result;
	}
487370
public static String toXml(final Object obj) {
		final ByteArrayOutputStream out = new ByteArrayOutputStream();

		// XStream x = createXStream();
		// String xml = x.toXML(obj);
		// return xml;
		final XMLEncoder e = new XMLEncoder(out);
		e.setExceptionListener(new JKObjectUtil.XmlEncoderExceptionListener());
		// e.setPersistenceDelegate(Object.class, new MyPersistenceDelegate());
		e.writeObject(obj);
		e.close();
		return out.toString();
		// return null;
	}
1053675
public String toXml(Object obj, Class<?>... clas) {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		toXml(obj, out, clas);
		return out.toString();
	}