commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject [05/11] [lang] modified appendDetail method for Object value in JsonToStringStyle class
Date Fri, 01 May 2015 21:57:01 GMT
modified appendDetail method for Object value in JsonToStringStyle class


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/cac52097
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/cac52097
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/cac52097

Branch: refs/heads/master
Commit: cac520971206093d32bf17925f880bd06d93f736
Parents: 2584b4a
Author: Jack <792626757@qq.com>
Authored: Fri May 1 14:13:13 2015 +0800
Committer: Jack <792626757@qq.com>
Committed: Fri May 1 14:13:13 2015 +0800

----------------------------------------------------------------------
 .../commons/lang3/builder/ToStringStyle.java    | 23 ++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/cac52097/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
index 1227018..6f51e1c 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java
@@ -2573,13 +2573,28 @@ public abstract class ToStringStyle implements Serializable {
                 return;
             }
 
-            if (value instanceof Number || value.getClass() == Boolean.class) {
+            if (value instanceof String || value instanceof Character) {
 
-                buffer.append(value);
+            	appendValueAsString(buffer, value.toString());
                 return;
             }
-
-            appendValueAsString(buffer, value.toString());
+            
+            if (value instanceof Number || value instanceof Boolean) {
+            
+            	buffer.append(value);
+            	return;
+            }
+            
+            final String try_value_str = value.toString();
+            if (try_value_str.startsWith(getContentStart()) && try_value_str.endsWith(getContentEnd())
+                    || try_value_str.startsWith(getArrayStart()) && try_value_str.startsWith(getArrayEnd())
+                ) {
+                
+            	buffer.append(value);
+            	return;
+            }
+            
+            appendDetail(buffer, fieldName, try_value_str);
         }
 
         /**


Mime
View raw message