From 36289f383129d5008e7c6147d0dd7dbf898e08e3 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Wed, 3 Aug 2022 22:26:07 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-74376=20=E5=AD=98=E5=82=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/SimpleDesignerConfig.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java index 37cfbb180b..0f14fef756 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.simple; +import com.fr.json.JSONObject; +import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; @@ -14,7 +16,7 @@ import java.util.Map; */ public class SimpleDesignerConfig implements XMLable { - private static final HashMap configs = new HashMap<>(); + private static final Map configs = new HashMap<>(); private SimpleDesignerConfig(String name) { this.name = name; @@ -22,7 +24,7 @@ public class SimpleDesignerConfig implements XMLable { public static SimpleDesignerConfig getInstance(String name) { SimpleDesignerConfig config = configs.get(name); - if(config == null) { + if (config == null) { config = new SimpleDesignerConfig(name); configs.put(name, config); } @@ -31,42 +33,51 @@ public class SimpleDesignerConfig implements XMLable { private String name = ""; - private HashMap content = new HashMap<>(); + private JSONObject content = new JSONObject(); public void addAttr(String key, String value) { content.put(key, value); } - public Map getContent() { + public JSONObject getContent() { return content; } + public void setContent(JSONObject content) { + this.content = content; + } + + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { - content.putAll(reader.getAttrs()); + String rawContent = reader.getAttrAsString("content", null); + if (StringUtils.isNotBlank(rawContent)) { + this.content = new JSONObject(rawContent); + } } } @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG(name); - content.forEach(writer::attr); + if (this.content != null) { + writer.attr("content", this.content.toString()); + } writer.end(); } @Override public Object clone() throws CloneNotSupportedException { SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); - cloned.content = new HashMap<>(content); + if (this.content != null) { + cloned.content = new JSONObject(this.content.toString()); + } + cloned.name = this.name; return cloned; } public String getName() { return name; } - - public void setName(String name) { - this.name = name; - } }