Browse Source

Merge pull request #9670 in DESIGN/design from release/11.0 to bugfix/11.0

* commit 'c5c80c930bc59a41eb1fac672803cf5f8242a40a':
  REPORT-74376 存储结构变化
bugfix/11.0
superman 2 years ago
parent
commit
7c00852c10
  1. 31
      designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java

31
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<String, SimpleDesignerConfig> configs = new HashMap<>();
private static final Map<String, SimpleDesignerConfig> configs = new HashMap<>();
private SimpleDesignerConfig(String name) {
this.name = name;
@ -31,42 +33,51 @@ public class SimpleDesignerConfig implements XMLable {
private String name = "";
private HashMap<String, String> content = new HashMap<>();
private JSONObject content = new JSONObject();
public void addAttr(String key, String value) {
content.put(key, value);
}
public Map<String, String> 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;
}
}

Loading…
Cancel
Save